TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 1 | import { ButtonStyle, CommandInteraction, ComponentType, GuildMember, Message, MessageComponentInteraction } from "discord.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 2 | import type Discord from "discord.js"; |
| 3 | import { Collection, MongoClient } from "mongodb"; |
pineafan | a2e39c7 | 2023-02-21 18:37:32 +0000 | [diff] [blame] | 4 | import config from "../config/main.js"; |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 5 | import client from "../utils/client.js"; |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 6 | import * as crypto from "crypto"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 7 | |
| 8 | const mongoClient = new MongoClient(config.mongoUrl); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 9 | await mongoClient.connect(); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 10 | const database = mongoClient.db("Nucleus"); |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 11 | |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 12 | export class Guilds { |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 13 | guilds: Collection<GuildConfig>; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 14 | defaultData: GuildConfig | null; |
| 15 | |
| 16 | constructor() { |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 17 | this.guilds = database.collection<GuildConfig>("guilds"); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 18 | this.defaultData = null; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 19 | } |
| 20 | |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 21 | async setup(): Promise<Guilds> { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 22 | this.defaultData = (await import("../config/default.json", { assert: { type: "json" } })) |
| 23 | .default as unknown as GuildConfig; |
| 24 | return this; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 25 | } |
| 26 | |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 27 | async read(guild: string): Promise<GuildConfig> { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 28 | const entry = await this.guilds.findOne({ id: guild }); |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 29 | return Object.assign({}, this.defaultData, entry); |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 30 | } |
| 31 | |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 32 | async write(guild: string, set: object | null, unset: string[] | string = []) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 33 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 34 | const uo: Record<string, any> = {}; |
| 35 | if (!Array.isArray(unset)) unset = [unset]; |
| 36 | for (const key of unset) { |
pineafan | 0bc0416 | 2022-07-25 17:22:26 +0100 | [diff] [blame] | 37 | uo[key] = null; |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 38 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 39 | const out = { $set: {}, $unset: {} }; |
| 40 | if (set) out.$set = set; |
| 41 | if (unset.length) out.$unset = uo; |
pineafan | 0bc0416 | 2022-07-25 17:22:26 +0100 | [diff] [blame] | 42 | await this.guilds.updateOne({ id: guild }, out, { upsert: true }); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 43 | } |
| 44 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 45 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 46 | async append(guild: string, key: string, value: any) { |
| 47 | if (Array.isArray(value)) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 48 | await this.guilds.updateOne( |
| 49 | { id: guild }, |
| 50 | { |
| 51 | $addToSet: { [key]: { $each: value } } |
| 52 | }, |
| 53 | { upsert: true } |
| 54 | ); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 55 | } else { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 56 | await this.guilds.updateOne( |
| 57 | { id: guild }, |
| 58 | { |
| 59 | $addToSet: { [key]: value } |
| 60 | }, |
| 61 | { upsert: true } |
| 62 | ); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 66 | async remove( |
| 67 | guild: string, |
| 68 | key: string, |
Skyler Grey | c634e2b | 2022-08-06 17:50:48 +0100 | [diff] [blame] | 69 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 70 | value: any, |
| 71 | innerKey?: string | null |
| 72 | ) { |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 73 | if (innerKey) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 74 | await this.guilds.updateOne( |
| 75 | { id: guild }, |
| 76 | { |
| 77 | $pull: { [key]: { [innerKey]: { $eq: value } } } |
| 78 | }, |
| 79 | { upsert: true } |
| 80 | ); |
pineafan | 0bc0416 | 2022-07-25 17:22:26 +0100 | [diff] [blame] | 81 | } else if (Array.isArray(value)) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 82 | await this.guilds.updateOne( |
| 83 | { id: guild }, |
| 84 | { |
| 85 | $pullAll: { [key]: value } |
| 86 | }, |
| 87 | { upsert: true } |
| 88 | ); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 89 | } else { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 90 | await this.guilds.updateOne( |
| 91 | { id: guild }, |
| 92 | { |
| 93 | $pullAll: { [key]: [value] } |
| 94 | }, |
| 95 | { upsert: true } |
| 96 | ); |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 97 | } |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 98 | } |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 99 | |
| 100 | async delete(guild: string) { |
| 101 | await this.guilds.deleteOne({ id: guild }); |
| 102 | } |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 103 | } |
| 104 | |
TheCodedProf | cfe8e9a | 2023-02-26 17:28:09 -0500 | [diff] [blame] | 105 | interface TranscriptEmbed { |
| 106 | title?: string; |
| 107 | description?: string; |
| 108 | fields?: { |
| 109 | name: string; |
| 110 | value: string; |
| 111 | inline: boolean; |
| 112 | }[]; |
| 113 | footer?: { |
| 114 | text: string; |
| 115 | iconURL?: string; |
| 116 | }; |
| 117 | } |
| 118 | |
| 119 | interface TranscriptComponent { |
| 120 | type: number; |
| 121 | style?: ButtonStyle; |
| 122 | label?: string; |
| 123 | description?: string; |
| 124 | placeholder?: string; |
| 125 | emojiURL?: string; |
| 126 | } |
| 127 | |
| 128 | interface TranscriptAuthor { |
| 129 | username: string; |
| 130 | discriminator: number; |
| 131 | nickname?: string; |
| 132 | id: string; |
| 133 | iconURL?: string; |
| 134 | topRole: { |
| 135 | color: number; |
| 136 | badgeURL?: string; |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 137 | }; |
| 138 | bot: boolean; |
TheCodedProf | cfe8e9a | 2023-02-26 17:28:09 -0500 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | interface TranscriptAttachment { |
| 142 | url: string; |
| 143 | filename: string; |
| 144 | size: number; |
| 145 | log?: string; |
| 146 | } |
| 147 | |
| 148 | interface TranscriptMessage { |
| 149 | id: string; |
| 150 | author: TranscriptAuthor; |
| 151 | content?: string; |
| 152 | embeds?: TranscriptEmbed[]; |
| 153 | components?: TranscriptComponent[][]; |
| 154 | editedTimestamp?: number; |
| 155 | createdTimestamp: number; |
| 156 | flags?: string[]; |
| 157 | attachments?: TranscriptAttachment[]; |
| 158 | stickerURLs?: string[]; |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 159 | referencedMessage?: string | [string, string, string]; // the message id, the channel id, the guild id |
TheCodedProf | cfe8e9a | 2023-02-26 17:28:09 -0500 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | interface TranscriptSchema { |
| 163 | code: string; |
| 164 | for: TranscriptAuthor; |
| 165 | type: "ticket" | "purge" |
| 166 | guild: string; |
| 167 | channel: string; |
| 168 | messages: TranscriptMessage[]; |
| 169 | createdTimestamp: number; |
| 170 | createdBy: TranscriptAuthor; |
| 171 | } |
| 172 | |
| 173 | export class Transcript { |
| 174 | transcripts: Collection<TranscriptSchema>; |
| 175 | |
| 176 | constructor() { |
| 177 | this.transcripts = database.collection<TranscriptSchema>("transcripts"); |
| 178 | } |
| 179 | |
| 180 | async create(transcript: Omit<TranscriptSchema, "code">) { |
| 181 | let code; |
| 182 | do { |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 183 | code = crypto.randomBytes(64).toString("base64").replace(/=/g, "").replace(/\//g, "_").replace(/\+/g, "-"); |
TheCodedProf | cfe8e9a | 2023-02-26 17:28:09 -0500 | [diff] [blame] | 184 | } while (await this.transcripts.findOne({ code: code })); |
| 185 | |
| 186 | const doc = await this.transcripts.insertOne(Object.assign(transcript, { code: code })); |
| 187 | if(doc.acknowledged) return code; |
| 188 | else return null; |
| 189 | } |
| 190 | |
| 191 | async read(code: string) { |
| 192 | return await this.transcripts.findOne({ code: code }); |
| 193 | } |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 194 | |
| 195 | async createTranscript(messages: Message[], interaction: MessageComponentInteraction | CommandInteraction, member: GuildMember) { |
| 196 | const interactionMember = await interaction.guild?.members.fetch(interaction.user.id) |
| 197 | const newOut: Omit<TranscriptSchema, "code"> = { |
| 198 | type: "ticket", |
| 199 | for: { |
| 200 | username: member!.user.username, |
| 201 | discriminator: parseInt(member!.user.discriminator), |
| 202 | id: member!.user.id, |
| 203 | topRole: { |
| 204 | color: member!.roles.highest.color |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 205 | }, |
| 206 | iconURL: member!.user.displayAvatarURL({ forceStatic: true}), |
| 207 | bot: member!.user.bot |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 208 | }, |
| 209 | guild: interaction.guild!.id, |
| 210 | channel: interaction.channel!.id, |
| 211 | messages: [], |
| 212 | createdTimestamp: Date.now(), |
| 213 | createdBy: { |
| 214 | username: interaction.user.username, |
| 215 | discriminator: parseInt(interaction.user.discriminator), |
| 216 | id: interaction.user.id, |
| 217 | topRole: { |
| 218 | color: interactionMember?.roles.highest.color ?? 0x000000 |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 219 | }, |
| 220 | iconURL: interaction.user.displayAvatarURL({ forceStatic: true}), |
| 221 | bot: interaction.user.bot |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 222 | } |
| 223 | } |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 224 | if(member.nickname) newOut.for.nickname = member.nickname; |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 225 | if(interactionMember?.roles.icon) newOut.createdBy.topRole.badgeURL = interactionMember.roles.icon.iconURL()!; |
| 226 | messages.reverse().forEach((message) => { |
| 227 | const msg: TranscriptMessage = { |
| 228 | id: message.id, |
| 229 | author: { |
| 230 | username: message.author.username, |
| 231 | discriminator: parseInt(message.author.discriminator), |
| 232 | id: message.author.id, |
| 233 | topRole: { |
| 234 | color: message.member!.roles.highest.color |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 235 | }, |
| 236 | iconURL: member!.user.displayAvatarURL({ forceStatic: true}), |
| 237 | bot: message.author.bot |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 238 | }, |
| 239 | createdTimestamp: message.createdTimestamp |
| 240 | }; |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 241 | if(message.member?.nickname) msg.author.nickname = message.member.nickname; |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 242 | if (message.member!.roles.icon) msg.author.topRole.badgeURL = message.member!.roles.icon.iconURL()!; |
| 243 | if (message.content) msg.content = message.content; |
| 244 | if (message.embeds.length > 0) msg.embeds = message.embeds.map(embed => { |
| 245 | const obj: TranscriptEmbed = {}; |
| 246 | if (embed.title) obj.title = embed.title; |
| 247 | if (embed.description) obj.description = embed.description; |
| 248 | if (embed.fields.length > 0) obj.fields = embed.fields.map(field => { |
| 249 | return { |
| 250 | name: field.name, |
| 251 | value: field.value, |
| 252 | inline: field.inline ?? false |
| 253 | } |
| 254 | }); |
| 255 | if (embed.footer) obj.footer = { |
| 256 | text: embed.footer.text, |
| 257 | }; |
| 258 | if (embed.footer?.iconURL) obj.footer!.iconURL = embed.footer.iconURL; |
| 259 | return obj; |
| 260 | }); |
| 261 | if (message.components.length > 0) msg.components = message.components.map(component => component.components.map(child => { |
| 262 | const obj: TranscriptComponent = { |
| 263 | type: child.type |
| 264 | } |
| 265 | if (child.type === ComponentType.Button) { |
| 266 | obj.style = child.style; |
| 267 | obj.label = child.label ?? ""; |
| 268 | } else if (child.type > 2) { |
| 269 | obj.placeholder = child.placeholder ?? ""; |
| 270 | } |
| 271 | return obj |
| 272 | })); |
| 273 | if (message.editedTimestamp) msg.editedTimestamp = message.editedTimestamp; |
| 274 | msg.flags = message.flags.toArray(); |
| 275 | |
| 276 | if (message.stickers.size > 0) msg.stickerURLs = message.stickers.map(sticker => sticker.url); |
| 277 | if (message.reference) msg.referencedMessage = [message.reference.guildId ?? "", message.reference.channelId, message.reference.messageId ?? ""]; |
| 278 | newOut.messages.push(msg); |
| 279 | }); |
| 280 | return newOut; |
| 281 | } |
| 282 | |
| 283 | toHumanReadable(transcript: Omit<TranscriptSchema, "code">): string { |
| 284 | let out = ""; |
| 285 | for (const message of transcript.messages) { |
| 286 | if (message.referencedMessage) { |
| 287 | if (Array.isArray(message.referencedMessage)) { |
| 288 | out += `> [Crosspost From] ${message.referencedMessage[0]} in ${message.referencedMessage[1]} in ${message.referencedMessage[2]}\n`; |
| 289 | } |
| 290 | else out += `> [Reply To] ${message.referencedMessage}\n`; |
| 291 | } |
| 292 | out += `${message.author.nickname ?? message.author.username}#${message.author.discriminator} (${message.author.id}) (${message.id}) `; |
| 293 | out += `[${new Date(message.createdTimestamp).toISOString()}] `; |
| 294 | if (message.editedTimestamp) out += `[Edited: ${new Date(message.editedTimestamp).toISOString()}] `; |
| 295 | out += "\n"; |
| 296 | if (message.content) out += `[Content]\n${message.content}\n\n`; |
| 297 | if (message.embeds) { |
| 298 | for (const embed of message.embeds) { |
| 299 | out += `[Embed]\n`; |
| 300 | if (embed.title) out += `| Title: ${embed.title}\n`; |
| 301 | if (embed.description) out += `| Description: ${embed.description}\n`; |
| 302 | if (embed.fields) { |
| 303 | for (const field of embed.fields) { |
| 304 | out += `| Field: ${field.name} - ${field.value}\n`; |
| 305 | } |
| 306 | } |
| 307 | if (embed.footer) { |
| 308 | out += `|Footer: ${embed.footer.text}\n`; |
| 309 | } |
| 310 | out += "\n"; |
| 311 | } |
| 312 | } |
| 313 | if (message.components) { |
| 314 | for (const component of message.components) { |
| 315 | out += `[Component]\n`; |
| 316 | for (const button of component) { |
| 317 | out += `| Button: ${button.label ?? button.description}\n`; |
| 318 | } |
| 319 | out += "\n"; |
| 320 | } |
| 321 | } |
| 322 | if (message.attachments) { |
| 323 | for (const attachment of message.attachments) { |
| 324 | out += `[Attachment] ${attachment.filename} (${attachment.size} bytes) ${attachment.url}\n`; |
| 325 | } |
| 326 | } |
TheCodedProf | 088b1b2 | 2023-02-28 17:31:11 -0500 | [diff] [blame] | 327 | out += "\n\n" |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 328 | } |
| 329 | return out |
| 330 | } |
TheCodedProf | cfe8e9a | 2023-02-26 17:28:09 -0500 | [diff] [blame] | 331 | } |
| 332 | |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 333 | export class History { |
| 334 | histories: Collection<HistorySchema>; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 335 | |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 336 | constructor() { |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 337 | this.histories = database.collection<HistorySchema>("history"); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 338 | } |
| 339 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 340 | async create( |
| 341 | type: string, |
| 342 | guild: string, |
| 343 | user: Discord.User, |
| 344 | moderator: Discord.User | null, |
| 345 | reason: string | null, |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 346 | before?: string | null, |
| 347 | after?: string | null, |
| 348 | amount?: string | null |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 349 | ) { |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 350 | await this.histories.insertOne({ |
| 351 | type: type, |
| 352 | guild: guild, |
| 353 | user: user.id, |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 354 | moderator: moderator ? moderator.id : null, |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 355 | reason: reason, |
| 356 | occurredAt: new Date(), |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 357 | before: before ?? null, |
| 358 | after: after ?? null, |
| 359 | amount: amount ?? null |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 360 | }); |
| 361 | } |
| 362 | |
| 363 | async read(guild: string, user: string, year: number) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 364 | const entry = (await this.histories |
| 365 | .find({ |
| 366 | guild: guild, |
| 367 | user: user, |
| 368 | occurredAt: { |
| 369 | $gte: new Date(year - 1, 11, 31, 23, 59, 59), |
| 370 | $lt: new Date(year + 1, 0, 1, 0, 0, 0) |
| 371 | } |
| 372 | }) |
| 373 | .toArray()) as HistorySchema[]; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 374 | return entry; |
| 375 | } |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 376 | |
| 377 | async delete(guild: string) { |
| 378 | await this.histories.deleteMany({ guild: guild }); |
| 379 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 380 | } |
| 381 | |
TheCodedProf | b5e9d55 | 2023-01-29 15:43:26 -0500 | [diff] [blame] | 382 | interface ScanCacheSchema { |
| 383 | addedAt: Date; |
| 384 | hash: string; |
| 385 | data: boolean; |
| 386 | tags: string[]; |
| 387 | } |
| 388 | |
| 389 | export class ScanCache { |
| 390 | scanCache: Collection<ScanCacheSchema>; |
| 391 | |
| 392 | constructor() { |
| 393 | this.scanCache = database.collection<ScanCacheSchema>("scanCache"); |
| 394 | } |
| 395 | |
| 396 | async read(hash: string) { |
| 397 | return await this.scanCache.findOne({ hash: hash }); |
| 398 | } |
| 399 | |
| 400 | async write(hash: string, data: boolean, tags?: string[]) { |
TheCodedProf | 1f67504 | 2023-02-16 17:01:29 -0500 | [diff] [blame] | 401 | await this.scanCache.insertOne({ hash: hash, data: data, tags: tags ?? [], addedAt: new Date() }); |
TheCodedProf | b5e9d55 | 2023-01-29 15:43:26 -0500 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | async cleanup() { |
| 405 | await this.scanCache.deleteMany({ addedAt: { $lt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 31)) }, hash: { $not$text: "http"} }); |
| 406 | } |
| 407 | } |
| 408 | |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 409 | export class PerformanceTest { |
| 410 | performanceData: Collection<PerformanceDataSchema>; |
| 411 | |
| 412 | constructor() { |
| 413 | this.performanceData = database.collection<PerformanceDataSchema>("performance"); |
| 414 | } |
| 415 | |
| 416 | async record(data: PerformanceDataSchema) { |
| 417 | data.timestamp = new Date(); |
| 418 | await this.performanceData.insertOne(data); |
| 419 | } |
| 420 | async read() { |
| 421 | return await this.performanceData.find({}).toArray(); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | export interface PerformanceDataSchema { |
| 426 | timestamp?: Date; |
| 427 | discord: number; |
| 428 | databaseRead: number; |
| 429 | resources: { |
| 430 | cpu: number; |
| 431 | memory: number; |
| 432 | temperature: number; |
| 433 | } |
| 434 | } |
| 435 | |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 436 | export class ModNotes { |
| 437 | modNotes: Collection<ModNoteSchema>; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 438 | |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 439 | constructor() { |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 440 | this.modNotes = database.collection<ModNoteSchema>("modNotes"); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | async create(guild: string, user: string, note: string | null) { |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 444 | await this.modNotes.updateOne({ guild: guild, user: user }, { $set: { note: note } }, { upsert: true }); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | async read(guild: string, user: string) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 448 | const entry = await this.modNotes.findOne({ guild: guild, user: user }); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 449 | return entry?.note ?? null; |
| 450 | } |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 451 | |
| 452 | async delete(guild: string) { |
| 453 | await this.modNotes.deleteMany({ guild: guild }); |
| 454 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 455 | } |
| 456 | |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 457 | export class Premium { |
| 458 | premium: Collection<PremiumSchema>; |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 459 | cache: Map<string, [boolean, string, number, boolean, Date]>; // Date indicates the time one hour after it was created |
| 460 | cacheTimeout = 1000 * 60 * 60; // 1 hour |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 461 | |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 462 | constructor() { |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 463 | this.premium = database.collection<PremiumSchema>("premium"); |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 464 | this.cache = new Map<string, [boolean, string, number, boolean, Date]>(); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 465 | } |
| 466 | |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 467 | async updateUser(user: string, level: number) { |
| 468 | if(!(await this.userExists(user))) await this.createUser(user, level); |
| 469 | await this.premium.updateOne({ user: user }, { $set: { level: level } }, { upsert: true }); |
| 470 | } |
| 471 | |
| 472 | async userExists(user: string): Promise<boolean> { |
| 473 | const entry = await this.premium.findOne({ user: user }); |
| 474 | return entry ? true : false; |
| 475 | } |
| 476 | |
| 477 | async createUser(user: string, level: number) { |
| 478 | await this.premium.insertOne({ user: user, appliesTo: [], level: level }); |
| 479 | } |
| 480 | |
TheCodedProf | aa3fe99 | 2023-02-25 21:53:09 -0500 | [diff] [blame] | 481 | async hasPremium(guild: string): Promise<[boolean, string, number, boolean] | null> { |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 482 | // [Has premium, user giving premium, level, is mod: if given automatically] |
| 483 | const cached = this.cache.get(guild); |
| 484 | if (cached && cached[4].getTime() < Date.now()) return [cached[0], cached[1], cached[2], cached[3]]; |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 485 | const entries = await this.premium.find({}).toArray(); |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 486 | const members = (await client.guilds.fetch(guild)).members.cache |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 487 | for(const {user} of entries) { |
| 488 | const member = members.get(user); |
TheCodedProf | aa3fe99 | 2023-02-25 21:53:09 -0500 | [diff] [blame] | 489 | if(member) { //TODO: Notify user if they've given premium to a server that has since gotten premium via a mod. |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 490 | const modPerms = //TODO: Create list in config for perms |
| 491 | member.permissions.has("Administrator") || |
| 492 | member.permissions.has("ManageChannels") || |
| 493 | member.permissions.has("ManageRoles") || |
| 494 | member.permissions.has("ManageEmojisAndStickers") || |
| 495 | member.permissions.has("ManageWebhooks") || |
| 496 | member.permissions.has("ManageGuild") || |
| 497 | member.permissions.has("KickMembers") || |
| 498 | member.permissions.has("BanMembers") || |
| 499 | member.permissions.has("ManageEvents") || |
| 500 | member.permissions.has("ManageMessages") || |
| 501 | member.permissions.has("ManageThreads") |
| 502 | const entry = entries.find(e => e.user === member.id); |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 503 | if(entry && (entry.level === 3) && modPerms) { |
| 504 | this.cache.set(guild, [true, member.id, entry.level, true, new Date(Date.now() + this.cacheTimeout)]); |
| 505 | return [true, member.id, entry.level, true]; |
| 506 | } |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 507 | } |
| 508 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 509 | const entry = await this.premium.findOne({ |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 510 | appliesTo: { |
| 511 | $elemMatch: { |
| 512 | $eq: guild |
| 513 | } |
| 514 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 515 | }); |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 516 | this.cache.set(guild, [entry ? true : false, entry?.user ?? "", entry?.level ?? 0, false, new Date(Date.now() + this.cacheTimeout)]); |
TheCodedProf | aa3fe99 | 2023-02-25 21:53:09 -0500 | [diff] [blame] | 517 | return entry ? [true, entry.user, entry.level, false] : null; |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 518 | } |
| 519 | |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 520 | async fetchUser(user: string): Promise<PremiumSchema | null> { |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 521 | const entry = await this.premium.findOne({ user: user }); |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 522 | if (!entry) return null; |
| 523 | return entry; |
| 524 | } |
| 525 | |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 526 | async checkAllPremium(member?: GuildMember) { |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 527 | const entries = await this.premium.find({}).toArray(); |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 528 | if(member) { |
| 529 | const entry = entries.find(e => e.user === member.id); |
| 530 | if(entry) { |
| 531 | const expiresAt = entry.expiresAt; |
| 532 | if(expiresAt) expiresAt < Date.now() ? await this.premium.deleteOne({user: member.id}) : null; |
| 533 | } |
| 534 | const roles = member.roles; |
| 535 | let level = 0; |
| 536 | if (roles.cache.has("1066468879309750313")) { |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 537 | level = 99; |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 538 | } else if (roles.cache.has("1066465491713003520")) { |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 539 | level = 1; |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 540 | } else if (roles.cache.has("1066439526496604194")) { |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 541 | level = 2; |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 542 | } else if (roles.cache.has("1066464134322978912")) { |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 543 | level = 3; |
| 544 | } |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 545 | await this.updateUser(member.id, level); |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 546 | if (level > 0) { |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 547 | await this.premium.updateOne({ user: member.id }, {$unset: { expiresAt: ""}}) |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 548 | } else { |
TheCodedProf | 94ff6de | 2023-02-22 17:47:26 -0500 | [diff] [blame] | 549 | await this.premium.updateOne({ user: member.id }, {$set: { expiresAt: (Date.now() + (1000*60*60*24*3)) }}) |
| 550 | } |
| 551 | } else { |
| 552 | const members = await (await client.guilds.fetch('684492926528651336')).members.fetch(); |
| 553 | for(const {roles, id} of members.values()) { |
| 554 | const entry = entries.find(e => e.user === id); |
| 555 | if(entry) { |
| 556 | const expiresAt = entry.expiresAt; |
| 557 | if(expiresAt) expiresAt < Date.now() ? await this.premium.deleteOne({user: id}) : null; |
| 558 | } |
| 559 | let level: number = 0; |
| 560 | if (roles.cache.has("1066468879309750313")) { |
| 561 | level = 99; |
| 562 | } else if (roles.cache.has("1066465491713003520")) { |
| 563 | level = 1; |
| 564 | } else if (roles.cache.has("1066439526496604194")) { |
| 565 | level = 2; |
| 566 | } else if (roles.cache.has("1066464134322978912")) { |
| 567 | level = 3; |
| 568 | } |
| 569 | await this.updateUser(id, level); |
| 570 | if (level > 0) { |
| 571 | await this.premium.updateOne({ user: id }, {$unset: { expiresAt: ""}}) |
| 572 | } else { |
| 573 | await this.premium.updateOne({ user: id }, {$set: { expiresAt: (Date.now() + (1000*60*60*24*3)) }}) |
| 574 | } |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 575 | } |
| 576 | } |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 577 | } |
| 578 | |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 579 | async addPremium(user: string, guild: string) { |
| 580 | const { level } = (await this.fetchUser(user))!; |
| 581 | this.cache.set(guild, [true, user, level, false, new Date(Date.now() + this.cacheTimeout)]); |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 582 | return this.premium.updateOne({ user: user }, { $addToSet: { appliesTo: guild } }, { upsert: true }); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 583 | } |
TheCodedProf | fc420b7 | 2023-01-24 17:14:38 -0500 | [diff] [blame] | 584 | |
| 585 | removePremium(user: string, guild: string) { |
TheCodedProf | 9c51a7e | 2023-02-27 17:11:13 -0500 | [diff] [blame] | 586 | this.cache.set(guild, [false, "", 0, false, new Date(Date.now() + this.cacheTimeout)]); |
TheCodedProf | fc420b7 | 2023-01-24 17:14:38 -0500 | [diff] [blame] | 587 | return this.premium.updateOne({ user: user }, { $pull: { appliesTo: guild } }); |
| 588 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 589 | } |
| 590 | |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 591 | export interface GuildConfig { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 592 | id: string; |
| 593 | version: number; |
PineaFan | 100df68 | 2023-01-02 13:26:08 +0000 | [diff] [blame] | 594 | singleEventNotifications: Record<string, boolean>; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 595 | filters: { |
| 596 | images: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 597 | NSFW: boolean; |
| 598 | size: boolean; |
| 599 | }; |
| 600 | malware: boolean; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 601 | wordFilter: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 602 | enabled: boolean; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 603 | words: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 604 | strict: string[]; |
| 605 | loose: string[]; |
| 606 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 607 | allowed: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 608 | users: string[]; |
| 609 | roles: string[]; |
| 610 | channels: string[]; |
| 611 | }; |
| 612 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 613 | invite: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 614 | enabled: boolean; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 615 | allowed: { |
| 616 | channels: string[]; |
| 617 | roles: string[]; |
| 618 | users: string[]; |
| 619 | }; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 620 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 621 | pings: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 622 | mass: number; |
| 623 | everyone: boolean; |
| 624 | roles: boolean; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 625 | allowed: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 626 | roles: string[]; |
| 627 | rolesToMention: string[]; |
| 628 | users: string[]; |
| 629 | channels: string[]; |
| 630 | }; |
| 631 | }; |
TheCodedProf | ad0b820 | 2023-02-14 14:27:09 -0500 | [diff] [blame] | 632 | clean: { |
| 633 | channels: string[]; |
| 634 | allowed: { |
| 635 | user: string[]; |
| 636 | roles: string[]; |
| 637 | } |
| 638 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 639 | }; |
TheCodedProf | baee2c1 | 2023-02-18 16:11:06 -0500 | [diff] [blame] | 640 | autoPublish: { |
| 641 | enabled: boolean; |
| 642 | channels: string[]; |
| 643 | } |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 644 | welcome: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 645 | enabled: boolean; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 646 | role: string | null; |
| 647 | ping: string | null; |
| 648 | channel: string | null; |
| 649 | message: string | null; |
| 650 | }; |
| 651 | stats: Record<string, { name: string; enabled: boolean }>; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 652 | logging: { |
| 653 | logs: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 654 | enabled: boolean; |
| 655 | channel: string | null; |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 656 | toLog: string; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 657 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 658 | staff: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 659 | channel: string | null; |
| 660 | }; |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 661 | attachments: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 662 | channel: string | null; |
| 663 | saved: Record<string, string>; |
| 664 | }; |
| 665 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 666 | verify: { |
PineaFan | df4996f | 2023-01-01 14:20:06 +0000 | [diff] [blame] | 667 | enabled: boolean; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 668 | role: string | null; |
| 669 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 670 | tickets: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 671 | enabled: boolean; |
| 672 | category: string | null; |
Skyler Grey | ad00217 | 2022-08-16 18:48:26 +0100 | [diff] [blame] | 673 | types: string; |
| 674 | customTypes: string[] | null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 675 | useCustom: boolean; |
| 676 | supportRole: string | null; |
| 677 | maxTickets: number; |
| 678 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 679 | moderation: { |
| 680 | mute: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 681 | timeout: boolean; |
| 682 | role: string | null; |
| 683 | text: string | null; |
| 684 | link: string | null; |
| 685 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 686 | kick: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 687 | text: string | null; |
| 688 | link: string | null; |
| 689 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 690 | ban: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 691 | text: string | null; |
| 692 | link: string | null; |
| 693 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 694 | softban: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 695 | text: string | null; |
| 696 | link: string | null; |
| 697 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 698 | warn: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 699 | text: string | null; |
| 700 | link: string | null; |
| 701 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 702 | role: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 703 | role: string | null; |
TheCodedProf | d9636e8 | 2023-01-17 22:13:06 -0500 | [diff] [blame] | 704 | text: null; |
| 705 | link: null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 706 | }; |
PineaFan | e6ba788 | 2023-01-18 20:41:16 +0000 | [diff] [blame] | 707 | nick: { |
| 708 | text: string | null; |
| 709 | link: string | null; |
| 710 | } |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 711 | }; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 712 | tracks: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 713 | name: string; |
| 714 | retainPrevious: boolean; |
| 715 | nullable: boolean; |
| 716 | track: string[]; |
| 717 | manageableBy: string[]; |
| 718 | }[]; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 719 | roleMenu: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 720 | enabled: boolean; |
| 721 | allowWebUI: boolean; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 722 | options: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 723 | name: string; |
| 724 | description: string; |
| 725 | min: number; |
| 726 | max: number; |
pineafan | 6fb3e07 | 2022-05-20 19:27:23 +0100 | [diff] [blame] | 727 | options: { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 728 | name: string; |
| 729 | description: string | null; |
| 730 | role: string; |
| 731 | }[]; |
| 732 | }[]; |
| 733 | }; |
| 734 | tags: Record<string, string>; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 735 | } |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 736 | |
| 737 | export interface HistorySchema { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 738 | type: string; |
| 739 | guild: string; |
| 740 | user: string; |
| 741 | moderator: string | null; |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 742 | reason: string | null; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 743 | occurredAt: Date; |
| 744 | before: string | null; |
| 745 | after: string | null; |
| 746 | amount: string | null; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | export interface ModNoteSchema { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 750 | guild: string; |
| 751 | user: string; |
pineafan | 3a02ea3 | 2022-08-11 21:35:04 +0100 | [diff] [blame] | 752 | note: string | null; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 753 | } |
| 754 | |
pineafan | 73a7c4a | 2022-07-24 10:38:04 +0100 | [diff] [blame] | 755 | export interface PremiumSchema { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 756 | user: string; |
| 757 | level: number; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 758 | appliesTo: string[]; |
TheCodedProf | 633866f | 2023-02-03 17:06:00 -0500 | [diff] [blame] | 759 | expiresAt?: number; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 760 | } |