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

added include_moves option to join_voice_channel and leave_voice_channel

This commit is contained in:
Almeida 2021-05-08 14:45:38 +01:00 committed by almeidx
parent ec2eb4a8bb
commit f949a3825a
No known key found for this signature in database
GPG key ID: C5FF0C40763546C5
2 changed files with 20 additions and 8 deletions

View file

@ -7,17 +7,23 @@ interface JoinVoiceChannelResult {
} }
export const JoinVoiceChannelTrigger = automodTrigger<JoinVoiceChannelResult>()({ export const JoinVoiceChannelTrigger = automodTrigger<JoinVoiceChannelResult>()({
configType: t.union([t.string, t.array(t.string)]), configType: t.type({
channels: t.union([t.string, t.array(t.string)]),
include_moves: t.boolean,
}),
defaultConfig: "", defaultConfig: {},
async match({ triggerConfig, context }) { async match({ triggerConfig, context }) {
const matchedChannelId = context.voiceChannel?.joined?.id; const matchedChannelId = context.voiceChannel?.joined?.id;
if (!context.member || !matchedChannelId || context.voiceChannel?.left) { const includeMoves =
typeof triggerConfig === "object" && !Array.isArray(triggerConfig) && triggerConfig.include_moves;
if (!context.member || !matchedChannelId || (context.voiceChannel?.left && !includeMoves)) {
return; return;
} }
const triggerChannels = Array.isArray(triggerConfig) ? triggerConfig : [triggerConfig]; const triggerChannels = Array.isArray(triggerConfig.channels) ? triggerConfig.channels : [triggerConfig.channels];
if (!triggerChannels.includes(matchedChannelId)) { if (!triggerChannels.includes(matchedChannelId)) {
return; return;
} }

View file

@ -7,17 +7,23 @@ interface LeaveVoiceChannelResult {
} }
export const LeaveVoiceChannelTrigger = automodTrigger<LeaveVoiceChannelResult>()({ export const LeaveVoiceChannelTrigger = automodTrigger<LeaveVoiceChannelResult>()({
configType: t.union([t.string, t.array(t.string)]), configType: t.type({
channels: t.union([t.string, t.array(t.string)]),
include_moves: t.boolean,
}),
defaultConfig: "", defaultConfig: {},
async match({ triggerConfig, context }) { async match({ triggerConfig, context }) {
const matchedChannelId = context.voiceChannel?.left?.id; const matchedChannelId = context.voiceChannel?.left?.id;
if (!context.member || !matchedChannelId || context.voiceChannel?.joined) { const includeMoves =
typeof triggerConfig === "object" && !Array.isArray(triggerConfig) && triggerConfig.include_moves;
if (!context.member || !matchedChannelId || (context.voiceChannel?.joined && !includeMoves)) {
return; return;
} }
const triggerChannels = Array.isArray(triggerConfig) ? triggerConfig : [triggerConfig]; const triggerChannels = Array.isArray(triggerConfig.channels) ? triggerConfig.channels : [triggerConfig.channels];
if (!triggerChannels.includes(matchedChannelId)) { if (!triggerChannels.includes(matchedChannelId)) {
return; return;
} }