From ed3760313f507326f588353e023e26b9c51e379b Mon Sep 17 00:00:00 2001 From: Dragory Date: Sun, 17 Feb 2019 15:19:55 +0200 Subject: [PATCH] Update to Knub 17.0.1, remove all d.nonBlocking() calls --- package-lock.json | 13 ++++++------- package.json | 2 +- src/plugins/Logs.ts | 3 --- src/plugins/MessageSaver.ts | 26 ++++++++++---------------- src/plugins/ModActions.ts | 6 ------ src/plugins/NameHistory.ts | 1 - src/plugins/Persist.ts | 2 -- src/plugins/PingableRoles.ts | 24 +++++++++++------------- src/plugins/ReactionRoles.ts | 1 - src/plugins/Slowmode.ts | 21 ++++++++++----------- src/plugins/Starboard.ts | 2 -- src/plugins/Utility.ts | 2 -- 12 files changed, 38 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6de13013..02005d42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2187,9 +2187,9 @@ "dev": true }, "knub": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/knub/-/knub-16.4.0.tgz", - "integrity": "sha512-kPWa306o4inVazFacyD5kiv4j1RR2iKuIkrGdqSlhoCAq4tYplqiXxnabl15EDAlHZzXKj9f7aSF8f9mCio/vA==", + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/knub/-/knub-17.0.1.tgz", + "integrity": "sha512-SUHm/Rgi2PlUFbZSQrFyeGt1BMO2HT3orErHMJGZzvMouzy6V5vGurbX9AvIcHY2BNWsHIb/v7UwPcmc5NPBbA==", "requires": { "escape-string-regexp": "^1.0.5", "lodash.at": "^4.6.0", @@ -2481,10 +2481,9 @@ } }, "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" }, "lodash.at": { "version": "4.6.0", diff --git a/package.json b/package.json index a3829ea1..6d30a0d7 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "escape-string-regexp": "^1.0.5", "humanize-duration": "^3.15.0", "js-yaml": "^3.12.0", - "knub": "^16.4.0", + "knub": "^17.0.1", "lodash.at": "^4.6.0", "lodash.chunk": "^4.2.0", "lodash.difference": "^4.5.0", diff --git a/src/plugins/Logs.ts b/src/plugins/Logs.ts index a36ecd1a..4a78e3f6 100644 --- a/src/plugins/Logs.ts +++ b/src/plugins/Logs.ts @@ -193,7 +193,6 @@ export class LogsPlugin extends Plugin { } @d.event("guildBanAdd") - @d.nonBlocking() async onMemberBan(_, user) { const relevantAuditLogEntry = await findRelevantAuditLogEntry( this.guild, @@ -213,7 +212,6 @@ export class LogsPlugin extends Plugin { } @d.event("guildBanRemove") - @d.nonBlocking() async onMemberUnban(_, user) { const relevantAuditLogEntry = await findRelevantAuditLogEntry( this.guild, @@ -233,7 +231,6 @@ export class LogsPlugin extends Plugin { } @d.event("guildMemberUpdate") - @d.nonBlocking() async onMemberUpdate(_, member: Member, oldMember: Member) { if (!oldMember) return; diff --git a/src/plugins/MessageSaver.ts b/src/plugins/MessageSaver.ts index 90be12f1..a489a52c 100644 --- a/src/plugins/MessageSaver.ts +++ b/src/plugins/MessageSaver.ts @@ -11,17 +11,17 @@ export class MessageSaverPlugin extends Plugin { getDefaultOptions() { return { permissions: { - manage: false + manage: false, }, overrides: [ { level: ">=100", permissions: { - manage: true - } - } - ] + manage: true, + }, + }, + ], }; } @@ -30,7 +30,6 @@ export class MessageSaverPlugin extends Plugin { } @d.event("messageCreate", "guild", false) - @d.nonBlocking() async onMessageCreate(msg: Message) { // Only save regular chat messages if (msg.type !== 0) { @@ -41,7 +40,6 @@ export class MessageSaverPlugin extends Plugin { } @d.event("messageDelete", "guild", false) - @d.nonBlocking() async onMessageDelete(msg: Message) { if (msg.type != null && msg.type !== 0) { return; @@ -51,7 +49,6 @@ export class MessageSaverPlugin extends Plugin { } @d.event("messageUpdate", "guild", false) - @d.nonBlocking() async onMessageUpdate(msg: Message) { if (msg.type !== 0) { return; @@ -61,7 +58,6 @@ export class MessageSaverPlugin extends Plugin { } @d.event("messageDeleteBulk", "guild", false) - @d.nonBlocking() async onMessageBulkDelete(messages: Message[]) { const ids = messages.map(m => m.id); await this.savedMessages.markBulkAsDeleted(ids); @@ -91,13 +87,12 @@ export class MessageSaverPlugin extends Plugin { return { savedCount: ids.length - failed.length, - failed + failed, }; } @d.command("save_messages_to_db", " ") @d.permission("manage") - @d.nonBlocking() async saveMessageCmd(msg: Message, args: { channel: GuildChannel & TextChannel; ids: string[] }) { await msg.channel.createMessage("Saving specified messages..."); @@ -107,8 +102,8 @@ export class MessageSaverPlugin extends Plugin { msg.channel.createMessage( successMessage( `Saved ${savedCount} messages. The following messages could not be saved: ${failed.join(", ")} - ` - ) + `, + ), ); } else { msg.channel.createMessage(successMessage(`Saved ${savedCount} messages!`)); @@ -117,7 +112,6 @@ export class MessageSaverPlugin extends Plugin { @d.command("save_pins_to_db", "") @d.permission("manage") - @d.nonBlocking() async savePinsCmd(msg: Message, args: { channel: GuildChannel & TextChannel }) { await msg.channel.createMessage(`Saving pins from <#${args.channel.id}>...`); @@ -128,8 +122,8 @@ export class MessageSaverPlugin extends Plugin { msg.channel.createMessage( successMessage( `Saved ${savedCount} messages. The following messages could not be saved: ${failed.join(", ")} - ` - ) + `, + ), ); } else { msg.channel.createMessage(successMessage(`Saved ${savedCount} messages!`)); diff --git a/src/plugins/ModActions.ts b/src/plugins/ModActions.ts index b74f267b..9515edb1 100644 --- a/src/plugins/ModActions.ts +++ b/src/plugins/ModActions.ts @@ -135,7 +135,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { * Attempts to find the ban's details in the audit log. */ @d.event("guildBanAdd") - @d.nonBlocking() async onGuildBanAdd(guild: Guild, user: User) { if (this.isEventIgnored(IgnoredEventType.Ban, user.id)) { this.clearIgnoredEvent(IgnoredEventType.Ban, user.id); @@ -173,7 +172,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { * Attempts to find the unban's details in the audit log. */ @d.event("guildBanRemove") - @d.nonBlocking() async onGuildBanRemove(guild: Guild, user: User) { if (this.isEventIgnored(IgnoredEventType.Unban, user.id)) { this.clearIgnoredEvent(IgnoredEventType.Unban, user.id); @@ -210,7 +208,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { * Show an alert if a member with prior notes joins the server */ @d.event("guildMemberAdd") - @d.nonBlocking() async onGuildMemberAdd(_, member: Member) { if (!this.configValue("alert_on_rejoin")) return; @@ -230,7 +227,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { } @d.event("guildMemberRemove") - @d.nonBlocking() async onGuildMemberRemove(_, member: Member) { if (this.isEventIgnored(IgnoredEventType.Kick, member.id)) { this.clearIgnoredEvent(IgnoredEventType.Kick, member.id); @@ -301,7 +297,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { options: [{ name: "mod", type: "member" }], }) @d.permission("warn") - @d.nonBlocking() async warnCmd(msg: Message, args: any) { // Make sure we're allowed to warn this member if (!this.canActOn(msg.member, args.member)) { @@ -857,7 +852,6 @@ export class ModActionsPlugin extends ZeppelinPlugin { @d.command("massban", "") @d.permission("massban") - @d.nonBlocking() async massbanCmd(msg: Message, args: { userIds: string[] }) { // Limit to 100 users at once (arbitrary?) if (args.userIds.length > 100) { diff --git a/src/plugins/NameHistory.ts b/src/plugins/NameHistory.ts index 03c94434..4da744db 100644 --- a/src/plugins/NameHistory.ts +++ b/src/plugins/NameHistory.ts @@ -73,7 +73,6 @@ export class NameHistoryPlugin extends Plugin { } @d.event("guildMemberAdd") - @d.nonBlocking() async onGuildMemberAdd(_, member: Member) { const latestEntry = await this.nameHistory.getLastEntryByType(member.id, NameHistoryEntryTypes.Username); const username = `${member.user.username}#${member.user.discriminator}`; diff --git a/src/plugins/Persist.ts b/src/plugins/Persist.ts index ac6a47aa..40c97a58 100644 --- a/src/plugins/Persist.ts +++ b/src/plugins/Persist.ts @@ -28,7 +28,6 @@ export class PersistPlugin extends Plugin { } @d.event("guildMemberRemove") - @d.nonBlocking() onGuildMemberRemove(_, member: Member) { let persist = false; const persistData: IPartialPersistData = {}; @@ -58,7 +57,6 @@ export class PersistPlugin extends Plugin { } @d.event("guildMemberAdd") - @d.nonBlocking() async onGuildMemberAdd(_, member: Member) { const persistedData = await this.persistedData.find(member.id); if (!persistedData) return; diff --git a/src/plugins/PingableRoles.ts b/src/plugins/PingableRoles.ts index ac1e80cf..e1b8bc19 100644 --- a/src/plugins/PingableRoles.ts +++ b/src/plugins/PingableRoles.ts @@ -17,17 +17,17 @@ export class PingableRoles extends Plugin { getDefaultOptions() { return { permissions: { - use: false + use: false, }, overrides: [ { level: ">=100", permissions: { - use: true - } - } - ] + use: true, + }, + }, + ], }; } @@ -59,7 +59,7 @@ export class PingableRoles extends Plugin { this.cache.delete(args.channelId); msg.channel.createMessage( - successMessage(`**${args.role.name}** is no longer set as pingable in <#${args.channelId}>`) + successMessage(`**${args.role.name}** is no longer set as pingable in <#${args.channelId}>`), ); } @@ -69,7 +69,7 @@ export class PingableRoles extends Plugin { const existingPingableRole = await this.pingableRoles.getByChannelAndRoleId(args.channelId, args.role.id); if (existingPingableRole) { msg.channel.createMessage( - errorMessage(`**${args.role.name}** is already set as pingable in <#${args.channelId}>`) + errorMessage(`**${args.role.name}** is already set as pingable in <#${args.channelId}>`), ); return; } @@ -81,7 +81,6 @@ export class PingableRoles extends Plugin { } @d.event("typingStart") - @d.nonBlocking() async onTypingStart(channel: TextableChannel, user: User) { const pingableRoles = await this.getPingableRolesForChannel(channel.id); if (pingableRoles.length === 0) return; @@ -99,7 +98,6 @@ export class PingableRoles extends Plugin { } @d.event("messageCreate") - @d.nonBlocking() async onMessageCreate(msg: Message) { const pingableRoles = await this.getPingableRolesForChannel(msg.channel.id); if (pingableRoles.length === 0) return; @@ -118,9 +116,9 @@ export class PingableRoles extends Plugin { role.edit( { - mentionable: true + mentionable: true, }, - "Enable pingable role" + "Enable pingable role", ); } } @@ -132,9 +130,9 @@ export class PingableRoles extends Plugin { role.edit( { - mentionable: false + mentionable: false, }, - "Disable pingable role" + "Disable pingable role", ); } } diff --git a/src/plugins/ReactionRoles.ts b/src/plugins/ReactionRoles.ts index 6f216824..16227e6f 100644 --- a/src/plugins/ReactionRoles.ts +++ b/src/plugins/ReactionRoles.ts @@ -193,7 +193,6 @@ export class ReactionRolesPlugin extends ZeppelinPlugin { } @d.event("messageReactionAdd") - @d.nonBlocking() async onAddReaction(msg: Message, emoji: CustomEmoji, userId: string) { const matchingReactionRole = await this.reactionRoles.getByMessageAndEmoji(msg.id, emoji.id || emoji.name); if (!matchingReactionRole) return; diff --git a/src/plugins/Slowmode.ts b/src/plugins/Slowmode.ts index 16a707bc..2a6eb05f 100644 --- a/src/plugins/Slowmode.ts +++ b/src/plugins/Slowmode.ts @@ -14,7 +14,7 @@ export class SlowmodePlugin extends Plugin { return { permissions: { manage: false, - affected: true + affected: true, }, overrides: [ @@ -22,10 +22,10 @@ export class SlowmodePlugin extends Plugin { level: ">=50", permissions: { manage: true, - affected: false - } - } - ] + affected: false, + }, + }, + ], }; } @@ -109,8 +109,8 @@ export class SlowmodePlugin extends Plugin { if (failedUsers.length) { msg.channel.createMessage( successMessage( - `Slowmode disabled! Failed to remove slowmode from the following users:\n\n<@!${failedUsers.join(">\n<@!")}>` - ) + `Slowmode disabled! Failed to remove slowmode from the following users:\n\n<@!${failedUsers.join(">\n<@!")}>`, + ), ); } else { msg.channel.createMessage(successMessage("Slowmode disabled!")); @@ -133,8 +133,8 @@ export class SlowmodePlugin extends Plugin { await this.removeSlowmodeFromUserId(args.channel, args.user.id); msg.channel.createMessage( successMessage( - `Slowmode cleared from **${args.user.username}#${args.user.discriminator}** in <#${args.channel.id}>` - ) + `Slowmode cleared from **${args.user.username}#${args.user.discriminator}** in <#${args.channel.id}>`, + ), ); } @@ -157,7 +157,7 @@ export class SlowmodePlugin extends Plugin { const humanizedSlowmodeTime = humanizeDuration(seconds * 1000); msg.channel.createMessage( - successMessage(`Slowmode enabled for <#${channel.id}> (1 message in ${humanizedSlowmodeTime})`) + successMessage(`Slowmode enabled for <#${channel.id}> (1 message in ${humanizedSlowmodeTime})`), ); } @@ -168,7 +168,6 @@ export class SlowmodePlugin extends Plugin { */ @d.event("messageCreate") @d.permission("affected") - @d.nonBlocking() async onMessageCreate(msg: Message) { if (msg.author.bot) return; diff --git a/src/plugins/Starboard.ts b/src/plugins/Starboard.ts index 1132575e..973a2f38 100644 --- a/src/plugins/Starboard.ts +++ b/src/plugins/Starboard.ts @@ -59,7 +59,6 @@ export class StarboardPlugin extends ZeppelinPlugin { */ @d.command("starboard create") @d.permission("manage") - @d.nonBlocking() async setupCmd(msg: Message) { const cancelMsg = () => msg.channel.createMessage("Cancelled"); @@ -330,7 +329,6 @@ export class StarboardPlugin extends ZeppelinPlugin { } @d.command("starboard migrate_pins", " ") - @d.nonBlocking() async migratePinsCmd(msg: Message, args: { pinChannelId: string; starboardChannelId }) { const starboard = await this.starboards.getStarboardByChannelId(args.starboardChannelId); if (!starboard) { diff --git a/src/plugins/Utility.ts b/src/plugins/Utility.ts index 6cba018a..3f1a98d7 100644 --- a/src/plugins/Utility.ts +++ b/src/plugins/Utility.ts @@ -459,7 +459,6 @@ export class UtilityPlugin extends ZeppelinPlugin { @d.command("ping") @d.permission("ping") - @d.nonBlocking() async pingCmd(msg: Message) { const times = []; const messages: Message[] = []; @@ -496,7 +495,6 @@ export class UtilityPlugin extends ZeppelinPlugin { @d.command("source", "") @d.permission("source") - @d.nonBlocking() async sourceCmd(msg: Message, args: { messageId: string }) { const savedMessage = await this.savedMessages.find(args.messageId); if (!savedMessage) {