mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 18:25:03 +00:00
added join and leave voice channel triggers
This commit is contained in:
parent
8445c37f64
commit
03ead92c19
7 changed files with 207 additions and 1 deletions
37
backend/src/plugins/Automod/triggers/joinVoiceChannel.ts
Normal file
37
backend/src/plugins/Automod/triggers/joinVoiceChannel.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import * as t from "io-ts";
|
||||
import { automodTrigger } from "../helpers";
|
||||
|
||||
interface JoinVoiceChannelResult {
|
||||
matchedChannelId: string;
|
||||
}
|
||||
|
||||
export const JoinVoiceChannelTrigger = automodTrigger<JoinVoiceChannelResult>()({
|
||||
configType: t.union([t.string, t.array(t.string)]),
|
||||
|
||||
defaultConfig: "",
|
||||
|
||||
async match({ triggerConfig, context }) {
|
||||
if (!context.member || !context.voiceChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const triggerChannels = Array.isArray(triggerConfig) ? triggerConfig : [triggerConfig];
|
||||
if (!triggerChannels.includes(context.voiceChannel.id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
extra: {
|
||||
matchedChannelId: context.voiceChannel.id,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult, pluginData, contexts }) {
|
||||
const channel = pluginData.guild.channels.get(matchResult.extra.matchedChannelId);
|
||||
const channelName = channel?.name || "Unknown";
|
||||
const member = contexts[0].member!;
|
||||
const memberName = `**${member.user.username}#${member.user.discriminator}** (\`${member.id}\`)`;
|
||||
return `${memberName} has joined the ${channelName} (\`${matchResult.extra.matchedChannelId}\`) voice channel`;
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue