diff --git a/backend/src/plugins/Automod/AutomodPlugin.ts b/backend/src/plugins/Automod/AutomodPlugin.ts index a5bb50dd..b8d9be04 100644 --- a/backend/src/plugins/Automod/AutomodPlugin.ts +++ b/backend/src/plugins/Automod/AutomodPlugin.ts @@ -20,7 +20,7 @@ import { AntiraidClearCmd } from "./commands/AntiraidClearCmd"; import { SetAntiraidCmd } from "./commands/SetAntiraidCmd"; import { ViewAntiraidCmd } from "./commands/ViewAntiraidCmd"; import { runAutomodOnCounterTrigger } from "./events/runAutomodOnCounterTrigger"; -import { RunAutomodOnJoinEvt, RunAutomodOnLeaveEvt } from "./events/RunAutomodOnJoinLeaveEvt"; +import { RunAutomodOnJoinEvt, RunAutomodOnLeaveEvt } from "./events/runAutomodOnJoinLeaveEvt"; import { RunAutomodOnMemberUpdate } from "./events/runAutomodOnMemberUpdate"; import { runAutomodOnMessage } from "./events/runAutomodOnMessage"; import { runAutomodOnModAction } from "./events/runAutomodOnModAction"; diff --git a/backend/src/plugins/Automod/events/runAutomodOnVoiceEvents.ts b/backend/src/plugins/Automod/events/runAutomodOnVoiceEvents.ts deleted file mode 100644 index fd0db61f..00000000 --- a/backend/src/plugins/Automod/events/runAutomodOnVoiceEvents.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { guildEventListener } from "knub"; -import { AutomodContext, AutomodPluginType } from "../types"; -import { runAutomod } from "../functions/runAutomod"; - -export const RunAutomodOnVoiceJoin = guildEventListener()( - "voiceChannelJoin", - ({ pluginData, args: { member, newChannel } }) => { - const context: AutomodContext = { - member, - timestamp: Date.now(), - voiceChannel: { - joined: newChannel, - }, - user: member.user, - }; - - pluginData.state.queue.add(() => { - runAutomod(pluginData, context); - }); - }, -); - -export const RunAutomodOnVoiceLeave = guildEventListener()( - "voiceChannelLeave", - ({ pluginData, args: { member, oldChannel } }) => { - const context: AutomodContext = { - member, - timestamp: Date.now(), - voiceChannel: { - left: oldChannel, - }, - user: member.user, - }; - - pluginData.state.queue.add(() => { - runAutomod(pluginData, context); - }); - }, -); - -export const RunAutomodOnVoiceSwitch = guildEventListener()( - "voiceChannelSwitch", - ({ pluginData, args: { member, oldChannel, newChannel } }) => { - const context: AutomodContext = { - member, - timestamp: Date.now(), - voiceChannel: { - left: oldChannel, - joined: newChannel, - }, - user: member.user, - }; - - pluginData.state.queue.add(() => { - runAutomod(pluginData, context); - }); - }, -); diff --git a/backend/src/plugins/Automod/triggers/joinVoiceChannel.ts b/backend/src/plugins/Automod/triggers/joinVoiceChannel.ts index 55ff01ac..f594dd3d 100644 --- a/backend/src/plugins/Automod/triggers/joinVoiceChannel.ts +++ b/backend/src/plugins/Automod/triggers/joinVoiceChannel.ts @@ -1,6 +1,6 @@ import * as t from "io-ts"; +import { ChannelTypeStrings } from "../../../types"; import { automodTrigger } from "../helpers"; -import { Constants } from "eris"; interface JoinVoiceChannelResult { matchedChannelId: string; @@ -36,11 +36,11 @@ export const JoinVoiceChannelTrigger = automodTrigger()( }, renderMatchInformation({ matchResult, pluginData, contexts }) { - const channel = pluginData.guild.channels.get(matchResult.extra.matchedChannelId); - const channelName = channel?.name || "Unknown"; + const channel = pluginData.guild.channels.resolve(matchResult.extra.matchedChannelId); + const channelName = channel?.name ?? "Unknown"; const member = contexts[0].member!; const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`; - const voiceOrStage = channel?.type === Constants.ChannelTypes.GUILD_STAGE ? "stage" : "voice"; + const voiceOrStage = channel?.type === ChannelTypeStrings.STAGE ? "stage" : "voice"; return `${memberName} has joined the ${channelName} (\`${matchResult.extra.matchedChannelId}\`) ${voiceOrStage} channel`; }, }); diff --git a/backend/src/plugins/Automod/triggers/leaveVoiceChannel.ts b/backend/src/plugins/Automod/triggers/leaveVoiceChannel.ts index 91ffb27d..2e83e423 100644 --- a/backend/src/plugins/Automod/triggers/leaveVoiceChannel.ts +++ b/backend/src/plugins/Automod/triggers/leaveVoiceChannel.ts @@ -1,5 +1,5 @@ -import { Constants } from "eris"; import * as t from "io-ts"; +import { ChannelTypeStrings } from "../../../types"; import { automodTrigger } from "../helpers"; interface LeaveVoiceChannelResult { @@ -36,11 +36,11 @@ export const LeaveVoiceChannelTrigger = automodTrigger( }, renderMatchInformation({ matchResult, pluginData, contexts }) { - const channel = pluginData.guild.channels.get(matchResult.extra.matchedChannelId); - const channelName = channel?.name || "Unknown"; + const channel = pluginData.guild.channels.resolve(matchResult.extra.matchedChannelId); + const channelName = channel?.name ?? "Unknown"; const member = contexts[0].member!; const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`; - const voiceOrStage = channel?.type === Constants.ChannelTypes.GUILD_STAGE ? "stage" : "voice"; + const voiceOrStage = channel?.type === ChannelTypeStrings.STAGE ? "stage" : "voice"; return `${memberName} has left the ${channelName} (\`${matchResult.extra.matchedChannelId}\`) ${voiceOrStage} channel`; }, });