diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-06 12:28:26 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-06 12:28:26 -0500 |
commit | a48dc88637d7b3e41a78eaeda91a19a967b278ff (patch) | |
tree | 6ef9f15683205fb10161c2db3d04fa35b2cc4238 /src/commands/info | |
parent | 10331e32e00116a4a82b4f86f668aaffa5ca903d (diff) | |
download | tanzanite-a48dc88637d7b3e41a78eaeda91a19a967b278ff.tar.gz tanzanite-a48dc88637d7b3e41a78eaeda91a19a967b278ff.tar.bz2 tanzanite-a48dc88637d7b3e41a78eaeda91a19a967b278ff.zip |
fix a few things, add level roles (finally)
Diffstat (limited to 'src/commands/info')
-rw-r--r-- | src/commands/info/guildInfo.ts | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index e543eee..7d3d170 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -1,4 +1,5 @@ -import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; +import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib'; +import assert from 'assert'; import { Constants, Guild, @@ -35,16 +36,20 @@ export default class GuildInfoCommand extends BushCommand { }); } - public override async exec(message: BushMessage | BushSlashMessage, args: { guild: ArgType<'guild'> | ArgType<'snowflake'> }) { - if (!args?.guild && !message.guild) { + public override async exec( + message: BushMessage | BushSlashMessage, + args: { guild: OptionalArgType<'guild'> | OptionalArgType<'snowflake'> } + ) { + if (!args.guild && !message.inGuild()) { return await message.util.reply( `${util.emojis.error} You must either provide an server to provide info about or run this command in a server.` ); } + const otherEmojis = client.consts.mappings.otherEmojis; let isPreview = false; - let _guild: ArgType<'guild'> | ArgType<'snowflake'> | GuildPreview = args.guild; - if (['number', 'string'].includes(typeof args?.guild)) { + let _guild: ArgType<'guild'> | ArgType<'snowflake'> | GuildPreview = args.guild ?? message.guild!; + if (typeof _guild === 'string') { const preview = await client.fetchGuildPreview(`${args.guild}` as Snowflake).catch(() => {}); if (preview) { _guild = preview; @@ -53,7 +58,9 @@ export default class GuildInfoCommand extends BushCommand { return await message.util.reply(`${util.emojis.error} That guild is not discoverable or does not exist.`); } } - const guild: Guild | GuildPreview = (_guild as Guild | GuildPreview) || (_guild as Guild); + + const guild: Guild | GuildPreview = _guild; + assert(guild); const emojis: string[] = []; const guildAbout: string[] = []; const guildStats: string[] = []; |