diff --git a/backend/src/commandTypes.ts b/backend/src/commandTypes.ts index 04ca71fa..29a69d11 100644 --- a/backend/src/commandTypes.ts +++ b/backend/src/commandTypes.ts @@ -1,4 +1,4 @@ -import { GuildChannel, GuildMember, User } from "discord.js"; +import { GuildChannel, GuildMember, Snowflake, User } from "discord.js"; import { baseCommandParameterTypeHelpers, baseTypeConverters, CommandContext, TypeConversionError } from "knub"; import { createTypeHelper } from "knub-command-manager"; import { @@ -72,16 +72,16 @@ export const commandTypes = { async anyId(value: string, context: CommandContext) { const userId = resolveUserId(context.pluginData.client, value); - if (userId) return userId; + if (userId) return userId as Snowflake; const channelIdMatch = value.match(channelMentionRegex); - if (channelIdMatch) return channelIdMatch[1]; + if (channelIdMatch) return channelIdMatch[1] as Snowflake; const roleIdMatch = value.match(roleMentionRegex); - if (roleIdMatch) return roleIdMatch[1]; + if (roleIdMatch) return roleIdMatch[1] as Snowflake; if (isValidSnowflake(value)) { - return value; + return value as Snowflake; } throw new TypeConversionError(`Could not parse ID: \`${disableInlineCode(value)}\``); @@ -112,7 +112,7 @@ export const commandTypeHelpers = { resolvedUserLoose: createTypeHelper>(commandTypes.resolvedUserLoose), resolvedMember: createTypeHelper>(commandTypes.resolvedMember), messageTarget: createTypeHelper>(commandTypes.messageTarget), - anyId: createTypeHelper>(commandTypes.anyId), + anyId: createTypeHelper>(commandTypes.anyId), regex: createTypeHelper(commandTypes.regex), timezone: createTypeHelper(commandTypes.timezone), }; diff --git a/backend/src/plugins/BotControl/commands/ReloadServerCmd.ts b/backend/src/plugins/BotControl/commands/ReloadServerCmd.ts index fb652b65..88193fba 100644 --- a/backend/src/plugins/BotControl/commands/ReloadServerCmd.ts +++ b/backend/src/plugins/BotControl/commands/ReloadServerCmd.ts @@ -11,7 +11,7 @@ export const ReloadServerCmd = botControlCmd({ }, signature: { - guildId: ct.string(), + guildId: ct.anyId(), }, async run({ pluginData, message: msg, args }) { diff --git a/backend/src/plugins/GuildConfigReloader/functions/reloadChangedGuilds.ts b/backend/src/plugins/GuildConfigReloader/functions/reloadChangedGuilds.ts index 65571b46..bc7eb6e9 100644 --- a/backend/src/plugins/GuildConfigReloader/functions/reloadChangedGuilds.ts +++ b/backend/src/plugins/GuildConfigReloader/functions/reloadChangedGuilds.ts @@ -1,3 +1,4 @@ +import { Snowflake } from "discord.js"; import { GlobalPluginData } from "knub"; import { SECONDS } from "../../../utils"; import { GuildConfigReloaderPluginType } from "../types"; @@ -11,7 +12,7 @@ export async function reloadChangedGuilds(pluginData: GlobalPluginData { const txtChannel = meta.pluginData.guild.channels.resolve(alert.channel_id as Snowflake) as TextChannel; - txtChannel.send( - `🔴 <@!${alert.requestor_id}> the user <@!${alert.user_id}> disconnected out of \`<#!${voiceChannel.id}>\``, - ); + txtChannel.send({ + content: `🔴 <@!${alert.requestor_id}> the user <@!${alert.user_id}> disconnected out of \`${voiceChannel.name}\``, + allowedMentions: { users: [alert.requestor_id as Snowflake] }, + }); }); } }, diff --git a/backend/src/plugins/LocateUser/utils/createOrReuseInvite.ts b/backend/src/plugins/LocateUser/utils/createOrReuseInvite.ts index 2853c7f0..3ac5dd1d 100644 --- a/backend/src/plugins/LocateUser/utils/createOrReuseInvite.ts +++ b/backend/src/plugins/LocateUser/utils/createOrReuseInvite.ts @@ -4,7 +4,7 @@ export async function createOrReuseInvite(vc: VoiceChannel) { const existingInvites = await vc.fetchInvites(); if (existingInvites.size !== 0) { - return existingInvites[0]; + return existingInvites.first()!; } else { return vc.createInvite(); } diff --git a/backend/src/plugins/ReactionRoles/events/ButtonInteractionEvt.ts b/backend/src/plugins/ReactionRoles/events/ButtonInteractionEvt.ts index 704b0b6a..7f366140 100644 --- a/backend/src/plugins/ReactionRoles/events/ButtonInteractionEvt.ts +++ b/backend/src/plugins/ReactionRoles/events/ButtonInteractionEvt.ts @@ -32,6 +32,10 @@ export const ButtonInteractionEvt = reactionRolesEvt({ }; if (context.stateless) { + if (context.roleOrMenu == null) { + // Not reaction from this plugin + return; + } const timeSinceCreation = moment.utc().valueOf() - idToTimestamp(int.message.id)!; if (timeSinceCreation >= BUTTON_INVALIDATION_TIME) { sendEphemeralReply( diff --git a/backend/src/plugins/ReactionRoles/util/buttonCustomIdFunctions.ts b/backend/src/plugins/ReactionRoles/util/buttonCustomIdFunctions.ts index ce1a9c3b..fa3644da 100644 --- a/backend/src/plugins/ReactionRoles/util/buttonCustomIdFunctions.ts +++ b/backend/src/plugins/ReactionRoles/util/buttonCustomIdFunctions.ts @@ -3,7 +3,7 @@ import { GuildPluginData } from "knub"; import { ReactionRolesPluginType } from "../types"; import { ButtonMenuActions } from "./buttonMenuActions"; -export const BUTTON_CONTEXT_SEPARATOR = "::"; +export const BUTTON_CONTEXT_SEPARATOR = ":rb:"; export async function getButtonAction(pluginData: GuildPluginData, roleOrMenu: string) { if (await pluginData.guild.roles.fetch(roleOrMenu as Snowflake).catch(() => false)) {