3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 22:21:51 +00:00

eris leftovers

This commit is contained in:
almeidx 2021-08-14 16:23:05 +01:00
parent bb27680a96
commit dcbe8c9eb2
No known key found for this signature in database
GPG key ID: C5FF0C40763546C5
4 changed files with 9 additions and 67 deletions

View file

@ -20,7 +20,7 @@ import { AntiraidClearCmd } from "./commands/AntiraidClearCmd";
import { SetAntiraidCmd } from "./commands/SetAntiraidCmd"; import { SetAntiraidCmd } from "./commands/SetAntiraidCmd";
import { ViewAntiraidCmd } from "./commands/ViewAntiraidCmd"; import { ViewAntiraidCmd } from "./commands/ViewAntiraidCmd";
import { runAutomodOnCounterTrigger } from "./events/runAutomodOnCounterTrigger"; import { runAutomodOnCounterTrigger } from "./events/runAutomodOnCounterTrigger";
import { RunAutomodOnJoinEvt, RunAutomodOnLeaveEvt } from "./events/RunAutomodOnJoinLeaveEvt"; import { RunAutomodOnJoinEvt, RunAutomodOnLeaveEvt } from "./events/runAutomodOnJoinLeaveEvt";
import { RunAutomodOnMemberUpdate } from "./events/runAutomodOnMemberUpdate"; import { RunAutomodOnMemberUpdate } from "./events/runAutomodOnMemberUpdate";
import { runAutomodOnMessage } from "./events/runAutomodOnMessage"; import { runAutomodOnMessage } from "./events/runAutomodOnMessage";
import { runAutomodOnModAction } from "./events/runAutomodOnModAction"; import { runAutomodOnModAction } from "./events/runAutomodOnModAction";

View file

@ -1,58 +0,0 @@
import { guildEventListener } from "knub";
import { AutomodContext, AutomodPluginType } from "../types";
import { runAutomod } from "../functions/runAutomod";
export const RunAutomodOnVoiceJoin = guildEventListener<AutomodPluginType>()(
"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<AutomodPluginType>()(
"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<AutomodPluginType>()(
"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);
});
},
);

View file

@ -1,6 +1,6 @@
import * as t from "io-ts"; import * as t from "io-ts";
import { ChannelTypeStrings } from "../../../types";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
import { Constants } from "eris";
interface JoinVoiceChannelResult { interface JoinVoiceChannelResult {
matchedChannelId: string; matchedChannelId: string;
@ -36,11 +36,11 @@ export const JoinVoiceChannelTrigger = automodTrigger<JoinVoiceChannelResult>()(
}, },
renderMatchInformation({ matchResult, pluginData, contexts }) { renderMatchInformation({ matchResult, pluginData, contexts }) {
const channel = pluginData.guild.channels.get(matchResult.extra.matchedChannelId); const channel = pluginData.guild.channels.resolve(matchResult.extra.matchedChannelId);
const channelName = channel?.name || "Unknown"; const channelName = channel?.name ?? "Unknown";
const member = contexts[0].member!; const member = contexts[0].member!;
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`; 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`; return `${memberName} has joined the ${channelName} (\`${matchResult.extra.matchedChannelId}\`) ${voiceOrStage} channel`;
}, },
}); });

View file

@ -1,5 +1,5 @@
import { Constants } from "eris";
import * as t from "io-ts"; import * as t from "io-ts";
import { ChannelTypeStrings } from "../../../types";
import { automodTrigger } from "../helpers"; import { automodTrigger } from "../helpers";
interface LeaveVoiceChannelResult { interface LeaveVoiceChannelResult {
@ -36,11 +36,11 @@ export const LeaveVoiceChannelTrigger = automodTrigger<LeaveVoiceChannelResult>(
}, },
renderMatchInformation({ matchResult, pluginData, contexts }) { renderMatchInformation({ matchResult, pluginData, contexts }) {
const channel = pluginData.guild.channels.get(matchResult.extra.matchedChannelId); const channel = pluginData.guild.channels.resolve(matchResult.extra.matchedChannelId);
const channelName = channel?.name || "Unknown"; const channelName = channel?.name ?? "Unknown";
const member = contexts[0].member!; const member = contexts[0].member!;
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`; 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`; return `${memberName} has left the ${channelName} (\`${matchResult.extra.matchedChannelId}\`) ${voiceOrStage} channel`;
}, },
}); });