diff --git a/src/main.ts b/src/main.ts index c902627..b02102c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,7 @@ import {Client, DMChannel, Events, GatewayIntentBits, Message, OmitPartialGroupDMChannel} from "discord.js"; -import config from "../config.json" with { type: "json" }; +import config from "../config.json" with {type: "json"}; import Database from 'better-sqlite3'; + const client = new Client({ intents: Object.keys(GatewayIntentBits).map((a) => { return GatewayIntentBits[a] @@ -19,6 +20,7 @@ db.exec(` string_list TEXT CHECK (json_array_length(string_list) <= 3) ) `); + function addOrUpdate(id: string, secondId: string): boolean | "duplicate" { const stmt = db.prepare('SELECT * FROM strikes WHERE id = ?'); const row = stmt.get(id) as TableRow | undefined; @@ -57,7 +59,7 @@ async function strike(message: OmitPartialGroupDMChannel>) { if (repliedmember.roles.cache.has(config.strikerroleid)) return; let result: boolean | "duplicate"; try { - result = addOrUpdate(message.author.id, repliedmessage.author.id) + result = addOrUpdate(repliedmessage.author.id, message.author.id) } catch (e) { message.reply('user SHOULD be already banned,,, idk lmao'); return; @@ -65,7 +67,7 @@ async function strike(message: OmitPartialGroupDMChannel>) { if (result === "duplicate") { message.reply('you have already striked this person.'); } - if (result === true){ + if (result === true) { await repliedmember.ban({reason: "ban by strike"}); await (await client.channels.fetch(config.publiclog) as DMChannel).send("user " + repliedmember.user.globalName + "was banned due to having 3 strikes. "); }