diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/leveling/level.ts | 3 | ||||
-rw-r--r-- | src/commands/moderation/purge.ts | 3 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 2 | ||||
-rw-r--r-- | src/lib/models/Guild.ts | 44 |
4 files changed, 22 insertions, 30 deletions
diff --git a/src/commands/leveling/level.ts b/src/commands/leveling/level.ts index 33ad705..b219954 100644 --- a/src/commands/leveling/level.ts +++ b/src/commands/leveling/level.ts @@ -51,7 +51,6 @@ export default class LevelCommand extends BushCommand { } private async getImage(user: BushUser, guild: BushGuild): Promise<Buffer> { - // I added comments because this code is impossible to read const guildRows = await Level.findAll({ where: { guild: guild.id } }); const rank = guildRows.sort((a, b) => b.xp - a.xp); const userLevelRow = guildRows.find((a) => a.user === user.id); @@ -64,7 +63,7 @@ export default class LevelCommand extends BushCommand { const white = '#FFFFFF', gray = '#23272A', highlight = user.hexAccentColor ?? '#5865F2'; - // Load roboto font because yes + // Load roboto font canvas.registerFont(join(__dirname, '..', '..', '..', '..', 'lib', 'assets', 'Roboto-Regular.ttf'), { family: 'Roboto' }); diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index ace72f2..062dad0 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -1,5 +1,4 @@ -import Collection from '@discordjs/collection'; -import { Snowflake } from 'discord.js'; +import { Collection, Snowflake } from 'discord.js'; import { BushCommand, BushMessage } from '../../lib'; export default class PurgeCommand extends BushCommand { diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index c4f92e7..a053f00 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -353,7 +353,6 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re await UpdateCacheTask.init(this); void this.console.success('startup', `Successfully created <<cache>>.`, false); this.stats.commandsUsed = await UpdateStatsTask.init(); - this.taskHandler.startAll!(); } public async dbPreInit(): Promise<void> { @@ -401,6 +400,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re try { await this.#init(); await this.login(this.token!); + this.taskHandler.startAll(); } catch (e) { await this.console.error('start', util.inspect(e, { colors: true, depth: 1 }), false); } diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts index 47b4af9..997be6a 100644 --- a/src/lib/models/Guild.ts +++ b/src/lib/models/Guild.ts @@ -4,14 +4,15 @@ import { BushClient } from '../extensions/discord-akairo/BushClient'; import { BaseModel } from './BaseModel'; import { jsonArrayInit, jsonParseGet, jsonParseSet, NEVER_USED } from './__helpers'; -export const guildSettingsObj: { - [x in GuildSettings]: { - name: string; - description: string; - type: 'string' | 'custom' | 'channel' | 'role' | 'user' | 'channel-array' | 'role-array' | 'user-array'; - configurable: boolean; - }; -} = { +interface GuildSetting { + name: string; + description: string; + type: 'string' | 'custom' | 'channel' | 'role' | 'user' | 'channel-array' | 'role-array' | 'user-array'; + configurable: boolean; +} +const asGuildSetting = <T>(et: { [K in keyof T]: GuildSetting }) => et; + +export const guildSettingsObj = asGuildSetting({ prefix: { name: 'Prefix', description: 'The phrase required to trigger text commands in this server.', @@ -90,27 +91,20 @@ export const guildSettingsObj: { type: 'channel', configurable: true } -}; +}); -export type GuildSettings = - | 'prefix' - | 'autoPublishChannels' - | 'welcomeChannel' - | 'muteRole' - | 'punishmentEnding' - | 'lockdownChannels' - | 'joinRoles' - | 'bypassChannelBlacklist' - | 'logChannels' - | 'autoModPhases' - | 'noXpChannels' - | 'levelRoles' - | 'levelUpChannel'; +export type GuildSettings = keyof typeof guildSettingsObj; export const settingsArr = Object.keys(guildSettingsObj).filter( (s) => guildSettingsObj[s as GuildSettings].configurable ) as GuildSettings[]; -export const guildFeaturesObj = { +interface GuildFeature { + name: string; + description: string; +} +const asGuildFeature = <T>(gf: { [K in keyof T]: GuildFeature }) => gf; + +export const guildFeaturesObj = asGuildFeature({ automod: { name: 'Automod', description: 'Deletes offensive content as well as phishing links.' @@ -151,7 +145,7 @@ export const guildFeaturesObj = { name: 'Send Level Up Messages', description: 'Send a message when a user levels up.' } -}; +}); export const guildLogsObj = { automod: { |