From 921e98369c8a8aa58220a232eb8b711be59f9884 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 26 Aug 2021 21:53:51 -0400 Subject: start settings command --- .../extensions/discord-akairo/BushClientUtil.ts | 6 +- src/lib/models/Guild.ts | 79 +++++++++++++++++++--- 2 files changed, 69 insertions(+), 16 deletions(-) (limited to 'src/lib') diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index da98dac..ef51b63 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -1012,11 +1012,7 @@ export class BushClientUtil extends ClientUtil { * @param surroundChar2 - The character placed in the end of the element. Defaults to `surroundChar1`. */ public surroundArray(array: string[], surroundChar1: string, surroundChar2?: string): string[] { - const newArray: string[] = []; - array.forEach((a) => { - newArray.push(`${surroundChar1}${a}${surroundChar2 ?? surroundChar1}`); - }); - return newArray; + return array.map((a) => `${surroundChar1}${a}${surroundChar2 ?? surroundChar1}`); } public parseDuration(content: string, remove = true): { duration: number; contentWithoutTime: string | null } { diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts index 614bf15..66deddb 100644 --- a/src/lib/models/Guild.ts +++ b/src/lib/models/Guild.ts @@ -18,6 +18,7 @@ export interface GuildModel { autoModPhases: string[]; enabledFeatures: GuildFeatures[]; joinRoles: Snowflake[]; + automodLogChannel: Snowflake; } export interface GuildModelCreationAttributes { @@ -34,16 +35,58 @@ export interface GuildModelCreationAttributes { autoModPhases?: string[]; enabledFeatures?: GuildFeatures[]; joinRoles?: Snowflake[]; + automodLogChannel?: Snowflake; } export const guildSettings = { - prefix: { type: 'string' }, - autoPublishChannels: { type: 'channel-array' }, - welcomeChannel: { type: 'channel-array' }, - muteRole: { type: 'role' }, - punishmentEnding: { type: 'string' }, - lockdownChannels: { type: 'channel-array' }, - joinRoles: { type: 'role-array' } + prefix: { + name: 'Prefix', + description: 'description goes here', + type: 'string', + configurable: true + }, + autoPublishChannels: { + name: 'Auto Publish Channels', + description: 'description goes here', + type: 'channel-array', + configurable: true + }, + welcomeChannel: { + name: 'Welcome Channel', + description: 'description goes here', + type: 'channel-array', + configurable: true + }, + muteRole: { + name: 'Mute Role', + description: 'description goes here', + type: 'role', + configurable: true + }, + punishmentEnding: { + name: 'Punishment Ending', + description: 'description goes here', + type: 'string', + configurable: true + }, + lockdownChannels: { + name: 'Lockdown Channels', + description: 'description goes here', + type: 'channel-array', + configurable: false // not implemented yet + }, + joinRoles: { + name: 'Join Roles', + description: 'description goes here', + type: 'role-array', + configurable: true + }, + automodLogChannel: { + name: 'Automod Log Channel', + description: 'description goes here', + type: 'channel', + configurable: true + } }; export const guildFeaturesObj = { @@ -53,11 +96,11 @@ export const guildFeaturesObj = { }, autoPublish: { name: 'Auto Publish', - description: 'Auto publishes all messages in configured announcement channels.' + description: 'Publishes messages in configured announcement channels.' }, autoThread: { name: 'Auto Thread', - description: 'Automatically creates a new thread for every message in configured channels.' + description: 'Creates a new thread for messages in configured channels.' }, blacklistedFile: { name: 'Blacklisted File', @@ -73,7 +116,7 @@ export const guildFeaturesObj = { }, stickyRoles: { name: 'Sticky Roles', - description: "Stores users' roles when they leave the server and returns them when they rejoin." + description: 'Restores past roles to a user when they rejoin.' } }; @@ -211,6 +254,16 @@ export class Guild extends BaseModel i throw new Error(NEVER_USED); } + /** + * The channel to send automod logs to. + */ + public get automodLogChannel(): Snowflake { + throw new Error(NEVER_USED); + } + public set automodLogChannel(_: Snowflake) { + throw new Error(NEVER_USED); + } + public static initModel(sequelize: Sequelize, client: BushClient): void { Guild.init( { @@ -242,7 +295,11 @@ export class Guild extends BaseModel i lockdownChannels: jsonArrayInit('lockdownChannels'), autoModPhases: jsonArrayInit('autoModPhases'), enabledFeatures: jsonArrayInit('enabledFeatures'), - joinRoles: jsonArrayInit('joinRoles') + joinRoles: jsonArrayInit('joinRoles'), + automodLogChannel: { + type: DataTypes.STRING, + allowNull: true + } }, { sequelize: sequelize } ); -- cgit