forked from SokoraDesu/Sokora
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { getDatabase } from "."; | ||
import { TableDefinition } from "./types"; | ||
|
||
const tableDefinition: TableDefinition = { | ||
name: "blocklist", | ||
definition: { | ||
id: "INTEGER" | ||
} | ||
}; | ||
|
||
const database = getDatabase(tableDefinition); | ||
const checkQuery = database.query("SELECT * FROM blocklist WHERE id = $1;"); | ||
export function check(userID: string) { | ||
return checkQuery.all(userID).length == 0; | ||
} | ||
|
||
const addQuery = database.query("INSERT INTO blocklist (id) VALUES (?1);"); | ||
export function add(userID: string) { | ||
addQuery.run(userID); | ||
} | ||
|
||
const removeQuery = database.query("DELETE FROM blocklist WHERE id = $1;"); | ||
export function remove(userID: string) { | ||
removeQuery.run(userID); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { EmbedBuilder, type DMChannel, type Guild, type GuildMember } from "discord.js"; | ||
import { genColor } from "./colorGen"; | ||
import { check } from "./database/blocklist"; | ||
|
||
export async function leavePlease(guild: Guild, owner: GuildMember, embedText?: string) { | ||
if (check(owner.id)) return; | ||
if (embedText) { | ||
const dmChannel = (await owner.createDM().catch(() => null)) as DMChannel | undefined; | ||
if (dmChannel) | ||
await dmChannel.send({ | ||
embeds: [new EmbedBuilder().setTitle(embedText).setColor(genColor(0))] | ||
}); | ||
} | ||
|
||
return await guild.leave(); | ||
} |