diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 6 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushCommand.ts | 11 | ||||
-rw-r--r-- | src/lib/models/Guild.ts | 34 | ||||
-rw-r--r-- | src/lib/utils/BushConstants.ts | 15 |
4 files changed, 59 insertions, 7 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 3feae96..ee92ded 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -21,8 +21,10 @@ import { exit } from 'process'; import readline from 'readline'; import { Sequelize } from 'sequelize'; import { contentWithDurationTypeCaster } from '../../../arguments/contentWithDuration'; +import { discordEmojiTypeCaster } from '../../../arguments/discordEmoji'; import { durationTypeCaster } from '../../../arguments/duration'; import { permissionTypeCaster } from '../../../arguments/permission'; +import { snowflakeTypeCaster } from '../../../arguments/snowflake'; import { UpdateCacheTask } from '../../../tasks/updateCache'; import { ActivePunishment } from '../../models/ActivePunishment'; import { Global } from '../../models/Global'; @@ -250,7 +252,9 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re this.commandHandler.resolver.addTypes({ duration: durationTypeCaster, contentWithDuration: contentWithDurationTypeCaster, - permission: permissionTypeCaster + permission: permissionTypeCaster, + snowflake: snowflakeTypeCaster, + discordEmoji: discordEmojiTypeCaster }); // loads all the handlers const loaders = { diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 0eaa5e0..7ecb679 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -6,7 +6,7 @@ import { BushClient } from './BushClient'; import { BushCommandHandler } from './BushCommandHandler'; import { BushSlashMessage } from './BushSlashMessage'; -export type BushArgumentType = +export type BaseBushArgumentType = | 'string' | 'lowercase' | 'uppercase' @@ -61,7 +61,12 @@ export type BushArgumentType = | 'listener' | 'duration' | 'contentWithDuration' - | 'permission'; + | 'permission' + | 'snowflake' + | 'discordEmoji'; + +export type BushArgumentType = BaseBushArgumentType | RegExp; + interface BaseBushArgumentOptions extends Omit<ArgumentOptions, 'type'> { id: string; description?: string; @@ -116,7 +121,7 @@ export interface BushArgumentOptions extends BaseBushArgumentOptions { * - `contentWithDuration` tries to parse duration in milliseconds and returns the remaining content with the duration * removed */ - type?: BushArgumentType; + type?: BushArgumentType | BaseBushArgumentType[]; } export interface CustomBushArgumentOptions extends BaseBushArgumentOptions { /** diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts index 3473ea4..dfba90c 100644 --- a/src/lib/models/Guild.ts +++ b/src/lib/models/Guild.ts @@ -15,6 +15,7 @@ export interface GuildModel { disabledCommands: string[]; lockdownChannels: Snowflake[]; autoModPhases: string[]; + enabledFeatures: string[]; } export interface GuildModelCreationAttributes { @@ -29,8 +30,20 @@ export interface GuildModelCreationAttributes { disabledCommands?: string[]; lockdownChannels?: Snowflake[]; autoModPhases?: string[]; + enabledFeatures?: string[]; } +export const guildSettings = { + prefix: { type: 'string' }, + autoPublishChannels: { type: 'channel-array' }, + welcomeChannel: { type: 'channel-array' }, + muteRole: { type: 'role' }, + punishmentEnding: { type: 'string' }, + lockdownChannels: { type: 'channel-array' } +}; + +export const guildFeatures = ['automodEnabled', 'supportThreads', 'stickyRoles']; + const NEVER_USED = 'This should never be executed'; export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> implements GuildModel { @@ -144,6 +157,16 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i throw new Error(NEVER_USED); } + /** + * The features enabled in a guild + */ + public get enabledFeatures(): string[] { + throw new Error(NEVER_USED); + } + public set enabledFeatures(_: string[]) { + throw new Error(NEVER_USED); + } + public static initModel(sequelize: Sequelize, client: BushClient): void { Guild.init( { @@ -233,6 +256,17 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i }, allowNull: false, defaultValue: '[]' + }, + enabledFeatures: { + type: DataTypes.TEXT, + get: function () { + return JSON.parse(this.getDataValue('enabledFeatures') as unknown as string); + }, + set: function (val: string[]) { + return this.setDataValue('enabledFeatures', JSON.stringify(val) as unknown as string[]); + }, + allowNull: false, + defaultValue: '[]' } }, { sequelize: sequelize } diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index 68393c4..bcc34ae 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -21,12 +21,13 @@ interface bushColors { black: '#000000'; orange: '#E86100'; } + export class BushConstants { public static emojis = { - success: '<:checkmark:837109864101707807>', + success: '<:success:837109864101707807>', warn: '<:warn:848726900876247050>', error: '<:error:837123021016924261>', - successFull: '<:checkmark_full:850118767576088646>', + successFull: '<:success_full:850118767576088646>', warnFull: '<:warn_full:850118767391539312>', errorFull: '<:error_full:850118767295201350>', mad: '<:mad:783046135392239626>', @@ -36,7 +37,9 @@ export class BushConstants { offlineCircle: '<:offline:787550565382750239>', dndCircle: '<:dnd:787550487633330176>', idleCircle: '<:idle:787550520956551218>', - onlineCircle: '<:online:787550449435803658>' + onlineCircle: '<:online:787550449435803658>', + cross: '<:cross:878319362539421777>', + check: '' }; public static colors: bushColors = { @@ -99,6 +102,12 @@ export class BushConstants { } }; + public static regex = { + snowflake: /\d{15,21}/im, + // eslint-disable-next-line no-useless-escape + discordEmoji: /<a?:(?<name>[a-zA-Z0-9\_]+):(?<id>\d{15,21})>/im + }; + /** A bunch of mappings */ public static mappings = { guilds: { |