aboutsummaryrefslogtreecommitdiff
path: root/src/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'src/tasks')
-rw-r--r--src/tasks/removeExpiredPunishements.ts1
-rw-r--r--src/tasks/updateCache.ts15
2 files changed, 4 insertions, 12 deletions
diff --git a/src/tasks/removeExpiredPunishements.ts b/src/tasks/removeExpiredPunishements.ts
index c079363..d787063 100644
--- a/src/tasks/removeExpiredPunishements.ts
+++ b/src/tasks/removeExpiredPunishements.ts
@@ -59,6 +59,7 @@ export default class RemoveExpiredPunishmentsTask extends BushTask {
case ActivePunishmentType.ROLE: {
if (!member) continue;
const role = guild?.roles?.cache?.get(entry.extraInfo);
+ if (!role) throw new Error(`Cannot unmute ${member.user.tag} because I cannot find the mute role.`);
const result = await member.removeRole({
reason: 'Punishment expired.',
role: role,
diff --git a/src/tasks/updateCache.ts b/src/tasks/updateCache.ts
index 910088f..7fb7eb3 100644
--- a/src/tasks/updateCache.ts
+++ b/src/tasks/updateCache.ts
@@ -24,20 +24,11 @@ export class UpdateCacheTask extends BushTask {
private static async updateGlobalCache(client: BushClient): Promise<void> {
const environment = config.environment;
- const row = (
- (await Global.findByPk(environment)) ||
- (await Global.create({
- environment,
- superUsers: [],
- blacklistedChannels: [],
- blacklistedGuilds: [],
- blacklistedUsers: [],
- disabledCommands: []
- }))
- ).toJSON();
+ const row = ((await Global.findByPk(environment)) ?? (await Global.create({ environment }))).toJSON();
for (const option in row) {
- if (Object.keys(client.cache.global).includes(option)) client.cache.global[option] = row[option];
+ if (Object.keys(client.cache.global).includes(option))
+ client.cache.global[option as keyof typeof client.cache.global] = row[option as keyof typeof row];
}
}