aboutsummaryrefslogtreecommitdiff
path: root/src/commands/config/blacklist.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-17 12:31:09 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-08-17 12:31:09 -0400
commitd40527d0a2d9f209905750258f71bedff1cdf089 (patch)
treee017fd844c2135bfc85228d00ef2617d24ce0a3f /src/commands/config/blacklist.ts
parentd431ad00754f3f250103deedea495b9bcee73fc0 (diff)
downloadtanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.tar.gz
tanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.tar.bz2
tanzanite-d40527d0a2d9f209905750258f71bedff1cdf089.zip
turned on ts strict option
Diffstat (limited to 'src/commands/config/blacklist.ts')
-rw-r--r--src/commands/config/blacklist.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts
index 864081c..57c3015 100644
--- a/src/commands/config/blacklist.ts
+++ b/src/commands/config/blacklist.ts
@@ -75,9 +75,12 @@ export default class BlacklistCommand extends BushCommand {
const targetID = target.id;
if (global) {
- if (action === 'toggle') {
- const blacklistedUsers = (await Global.findByPk(client.config.environment)).blacklistedUsers;
- const blacklistedChannels = (await Global.findByPk(client.config.environment)).blacklistedChannels;
+ if ((action as 'blacklist' | 'unblacklist' | 'toggle') === 'toggle') {
+ const globalDB =
+ (await Global.findByPk(client.config.environment)) ??
+ (await Global.create({ environment: client.config.environment }));
+ const blacklistedUsers = globalDB.blacklistedUsers;
+ const blacklistedChannels = globalDB.blacklistedChannels;
action = blacklistedUsers.includes(targetID) || blacklistedChannels.includes(targetID) ? 'unblacklist' : 'blacklist';
}
const success = await util
@@ -99,9 +102,11 @@ export default class BlacklistCommand extends BushCommand {
});
// guild disable
} else {
+ if (!message.guild)
+ return await message.util.reply(`${util.emojis.error} You have to be in a guild to disable commands.`);
const blacklistedChannels = (await message.guild.getSetting('blacklistedChannels')) ?? [];
const blacklistedUsers = (await message.guild.getSetting('blacklistedUsers')) ?? [];
- if (action === 'toggle') {
+ if ((action as 'blacklist' | 'unblacklist' | 'toggle') === 'toggle') {
action = blacklistedChannels.includes(targetID) ?? blacklistedUsers.includes(targetID) ? 'unblacklist' : 'blacklist';
}
const newValue = util.addOrRemoveFromArray(