I'm just a little daft for this one.
This commit is contained in:
+2
-17
@@ -1,7 +1,7 @@
|
|||||||
import sqlite3 from 'sqlite3';
|
import sqlite3 from 'sqlite3';
|
||||||
import { open, Database as SqliteDatabase } from 'sqlite';
|
import { open, Database as SqliteDatabase } from 'sqlite';
|
||||||
import { serializeMessage, wait } from '../utils';
|
import { serializeMessage, wait } from '../utils';
|
||||||
import { GuildSettings, LoggedMessage, TicketMessage, TicketPhrase, Note, Ban, GuildArraySetting, GithubUserMapping, KnowledgebaseItem, PrivateHelpTicket } from '../types';
|
import { GuildSettings, LoggedMessage, TicketMessage, TicketPhrase, Note, Ban, GuildArraySetting, GithubUserMapping, KnowledgebaseItem, PrivateHelpTicket, GuildSetting } from '../types';
|
||||||
import { Message } from '../events';
|
import { Message } from '../events';
|
||||||
|
|
||||||
const DB_SCHEMA = `
|
const DB_SCHEMA = `
|
||||||
@@ -114,21 +114,6 @@ export const enum PrivateHelpTicketStatus {
|
|||||||
CLOSED = 1
|
CLOSED = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
type GuildSettingKey =
|
|
||||||
| 'general_chat_id'
|
|
||||||
| 'tickets_channel_id'
|
|
||||||
| 'event_logs_channel_id'
|
|
||||||
| 'discord_logs_channel_id'
|
|
||||||
| 'audit_logs_channel_id'
|
|
||||||
| 'voice_logs_channel_id'
|
|
||||||
| 'new_member_channel_id'
|
|
||||||
| 'moderator_channel_id'
|
|
||||||
| 'admin_role_id'
|
|
||||||
| 'private_help_role_id'
|
|
||||||
| 'devwatch_role_id'
|
|
||||||
| 'github_release_channel'
|
|
||||||
| 'private_help_channel_id';
|
|
||||||
|
|
||||||
export class Database {
|
export class Database {
|
||||||
private static db: SqliteDatabase;
|
private static db: SqliteDatabase;
|
||||||
|
|
||||||
@@ -199,7 +184,7 @@ export class Database {
|
|||||||
await Database.db.run('INSERT INTO settings(guild_id) VALUES (?)', guildId);
|
await Database.db.run('INSERT INTO settings(guild_id) VALUES (?)', guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async updateGuildSettings(guildId: string, key: GuildSettingKey, value: string) {
|
static async updateGuildSettings(guildId: string, key: GuildSetting, value: string) {
|
||||||
await Database.db.run(`UPDATE settings SET ${key} = ? WHERE guild_id = ?`, value, guildId);
|
await Database.db.run(`UPDATE settings SET ${key} = ? WHERE guild_id = ?`, value, guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+80
-79
@@ -1,79 +1,80 @@
|
|||||||
export type LoggedMessage = {
|
export type LoggedMessage = {
|
||||||
id: string
|
id: string
|
||||||
author_id: string
|
author_id: string
|
||||||
author_name: string
|
author_name: string
|
||||||
channel_id: string
|
channel_id: string
|
||||||
attachments: string
|
attachments: string
|
||||||
stickers: string
|
stickers: string
|
||||||
content: string
|
content: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GuildSettings = {
|
export type GuildSettings = {
|
||||||
guild_id: string
|
guild_id: string
|
||||||
general_chat_id?: string
|
general_chat_id?: string
|
||||||
new_member_channel_id?: string
|
new_member_channel_id?: string
|
||||||
tickets_channel_id?: string
|
tickets_channel_id?: string
|
||||||
event_logs_channel_id?: string
|
event_logs_channel_id?: string
|
||||||
discord_logs_channel_id?: string
|
discord_logs_channel_id?: string
|
||||||
audit_logs_channel_id?: string
|
audit_logs_channel_id?: string
|
||||||
voice_logs_channel_id?: string
|
voice_logs_channel_id?: string
|
||||||
admin_role_id?: string
|
admin_role_id?: string
|
||||||
private_help_role_id?: string
|
private_help_role_id?: string
|
||||||
devwatch_role_id?: string
|
devwatch_role_id?: string
|
||||||
staff_categories?: string
|
staff_categories?: string
|
||||||
safe_channels?: string
|
safe_channels?: string
|
||||||
link_skip_channels?: string
|
link_skip_channels?: string
|
||||||
github_release_channel?: string
|
github_release_channel?: string
|
||||||
moderator_channel_id?: string
|
moderator_channel_id?: string
|
||||||
private_help_channel_id?: string
|
private_help_channel_id?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GuildArraySetting = 'staff_categories' | 'safe_channels' | 'link_skip_channels';
|
type GuildSetting = Exclude<keyof GuildSettings, 'guild_id'>
|
||||||
|
export type GuildArraySetting = 'staff_categories' | 'safe_channels' | 'link_skip_channels';
|
||||||
export type TicketMessage = {
|
|
||||||
id: number
|
export type TicketMessage = {
|
||||||
message_id: string
|
id: number
|
||||||
}
|
message_id: string
|
||||||
|
}
|
||||||
export type TicketPhrase = {
|
|
||||||
id: number
|
export type TicketPhrase = {
|
||||||
user_id: string
|
id: number
|
||||||
phrase: string
|
user_id: string
|
||||||
}
|
phrase: string
|
||||||
|
}
|
||||||
export type Note = {
|
|
||||||
id: number
|
export type Note = {
|
||||||
user_id: string
|
id: number
|
||||||
reason: string
|
user_id: string
|
||||||
mod_id: string
|
reason: string
|
||||||
timestamp: string
|
mod_id: string
|
||||||
}
|
timestamp: string
|
||||||
|
}
|
||||||
export type Ban = {
|
|
||||||
id: number
|
export type Ban = {
|
||||||
user_id: string
|
id: number
|
||||||
expires: 0 | 1
|
user_id: string
|
||||||
expires_at: string
|
expires: 0 | 1
|
||||||
full_ban: 0 | 1
|
expires_at: string
|
||||||
}
|
full_ban: 0 | 1
|
||||||
|
}
|
||||||
export type GithubUserMapping = {
|
|
||||||
id: number
|
export type GithubUserMapping = {
|
||||||
discord_id: string
|
id: number
|
||||||
github_username: string
|
discord_id: string
|
||||||
}
|
github_username: string
|
||||||
|
}
|
||||||
export type KnowledgebaseItem = {
|
|
||||||
id: number
|
export type KnowledgebaseItem = {
|
||||||
guild_id: string
|
id: number
|
||||||
name: string
|
guild_id: string
|
||||||
content: string
|
name: string
|
||||||
}
|
content: string
|
||||||
|
}
|
||||||
export type PrivateHelpTicket = {
|
|
||||||
id: number
|
export type PrivateHelpTicket = {
|
||||||
user_id: string
|
id: number
|
||||||
thread_id: string
|
user_id: string
|
||||||
status: PrivateHelpTicketStatus
|
thread_id: string
|
||||||
timestamp: string
|
status: PrivateHelpTicketStatus
|
||||||
}
|
timestamp: string
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user