diff options
Diffstat (limited to 'src/lib/extensions')
-rw-r--r-- | src/lib/extensions/BushCommand.ts | 2 | ||||
-rw-r--r-- | src/lib/extensions/BushGuild.ts | 20 | ||||
-rw-r--r-- | src/lib/extensions/BushGuildMember.ts | 13 | ||||
-rw-r--r-- | src/lib/extensions/BushInhibitor.ts | 2 | ||||
-rw-r--r-- | src/lib/extensions/BushMessage.ts | 12 | ||||
-rw-r--r-- | src/lib/extensions/BushSlashMessage.ts (renamed from src/lib/extensions/BushInteractionMessage.ts) | 4 | ||||
-rw-r--r-- | src/lib/extensions/BushUser.ts | 17 |
7 files changed, 65 insertions, 5 deletions
diff --git a/src/lib/extensions/BushCommand.ts b/src/lib/extensions/BushCommand.ts index b62d26e..f22a628 100644 --- a/src/lib/extensions/BushCommand.ts +++ b/src/lib/extensions/BushCommand.ts @@ -4,8 +4,8 @@ import { ArgumentGenerator, ArgumentOptions, ArgumentPromptOptions, Command, Com import { Snowflake } from 'discord.js'; import { BushClient } from './BushClient'; import { BushCommandHandler } from './BushCommandHandler'; -import { BushSlashMessage } from './BushInteractionMessage'; import { BushMessage } from './BushMessage'; +import { BushSlashMessage } from './BushSlashMessage'; export interface BushArgumentOptions extends ArgumentOptions { id: string; diff --git a/src/lib/extensions/BushGuild.ts b/src/lib/extensions/BushGuild.ts new file mode 100644 index 0000000..470e93a --- /dev/null +++ b/src/lib/extensions/BushGuild.ts @@ -0,0 +1,20 @@ +import { Guild } from 'discord.js'; +import { Guild as GuildDB, GuildModel } from '../models/Guild'; +import { BushClient } from './BushClient'; + +export class BushGuild extends Guild { + public declare client: BushClient; + public constructor(client: BushClient, data: unknown) { + super(client, data); + } + + public async getSetting(setting: keyof GuildModel) { + return ((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id })).get(setting); + } + + public async setSetting<K extends keyof GuildModel>(setting: K, value: GuildDB[K]) { + const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }); + row[setting] = value; + return await row.save(); + } +} diff --git a/src/lib/extensions/BushGuildMember.ts b/src/lib/extensions/BushGuildMember.ts new file mode 100644 index 0000000..d193f9e --- /dev/null +++ b/src/lib/extensions/BushGuildMember.ts @@ -0,0 +1,13 @@ +import { GuildMember } from 'discord.js'; +import { BushClient } from './BushClient'; +import { BushGuild } from './BushGuild'; +import { BushUser } from './BushUser'; + +export class BushGuildMember extends GuildMember { + public declare client: BushClient; + public declare guild: BushGuild; + public declare BushUser: BushUser; + public constructor(client: BushClient, data: unknown, guild: BushGuild) { + super(client, data, guild); + } +} diff --git a/src/lib/extensions/BushInhibitor.ts b/src/lib/extensions/BushInhibitor.ts index 8a31abf..602ff65 100644 --- a/src/lib/extensions/BushInhibitor.ts +++ b/src/lib/extensions/BushInhibitor.ts @@ -2,8 +2,8 @@ import { Inhibitor } from 'discord-akairo'; import { BushClient } from './BushClient'; import { BushCommand } from './BushCommand'; -import { BushSlashMessage } from './BushInteractionMessage'; import { BushMessage } from './BushMessage'; +import { BushSlashMessage } from './BushSlashMessage'; export class BushInhibitor extends Inhibitor { public declare client: BushClient; diff --git a/src/lib/extensions/BushMessage.ts b/src/lib/extensions/BushMessage.ts index afa6bde..7dbeeb2 100644 --- a/src/lib/extensions/BushMessage.ts +++ b/src/lib/extensions/BushMessage.ts @@ -1,11 +1,17 @@ import { DMChannel, Message, NewsChannel, TextChannel } from 'discord.js'; import { BushClient } from './BushClient'; import { BushCommandUtil } from './BushCommandUtil'; +import { BushGuild } from './BushGuild'; +import { BushGuildMember } from './BushGuildMember'; +import { BushUser } from './BushUser'; export class BushMessage extends Message { - declare client: BushClient; - declare util: BushCommandUtil; - constructor(client: BushClient, data: unknown, channel: TextChannel | DMChannel | NewsChannel) { + public declare client: BushClient; + public declare util: BushCommandUtil; + public declare guild: BushGuild; + public declare member: BushGuildMember; + public declare author: BushUser; + public constructor(client: BushClient, data: unknown, channel: TextChannel | DMChannel | NewsChannel) { super(client, data, channel); this.client = client; this.channel = channel; diff --git a/src/lib/extensions/BushInteractionMessage.ts b/src/lib/extensions/BushSlashMessage.ts index 62d2519..33ca11f 100644 --- a/src/lib/extensions/BushInteractionMessage.ts +++ b/src/lib/extensions/BushSlashMessage.ts @@ -2,10 +2,14 @@ import { AkairoMessage } from 'discord-akairo'; import { CommandInteraction } from 'discord.js'; import { BushClient } from './BushClient'; import { BushCommandUtil } from './BushCommandUtil'; +import { BushGuild } from './BushGuild'; +import { BushUser } from './BushUser'; export class BushSlashMessage extends AkairoMessage { public declare client: BushClient; public declare util: BushCommandUtil; + public declare guild: BushGuild; + public declare author: BushUser; public constructor( client: BushClient, interaction: CommandInteraction, diff --git a/src/lib/extensions/BushUser.ts b/src/lib/extensions/BushUser.ts new file mode 100644 index 0000000..dd07b7d --- /dev/null +++ b/src/lib/extensions/BushUser.ts @@ -0,0 +1,17 @@ +import { User } from 'discord.js'; +import { BushClient } from './BushClient'; + +export class BushUser extends User { + public declare client: BushClient; + public constructor(client: BushClient, data: unknown) { + super(client, data); + } + + public isOwner(): boolean { + return this.client.isOwner(this); + } + + public isSuperUser(): boolean { + return this.client.isSuperUser(this); + } +} |