mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 13:51:51 +00:00
cleaned up the event
This commit is contained in:
parent
9c437a9a98
commit
5ad461260a
1 changed files with 17 additions and 33 deletions
|
@ -13,43 +13,27 @@ export const RunAutomodOnVoiceStateUpdate = typedGuildEventListener<AutomodPlugi
|
|||
const member = newState.member ?? oldState.member ?? (await guild.members.fetch(newState.id).catch(noop));
|
||||
if (!member) return;
|
||||
|
||||
const context: AutomodContext = {
|
||||
member,
|
||||
timestamp,
|
||||
voiceChannel: {},
|
||||
user: member.user,
|
||||
};
|
||||
let addToQueue = false;
|
||||
|
||||
if (!oldChannel && newChannel) {
|
||||
const context: AutomodContext = {
|
||||
member,
|
||||
timestamp,
|
||||
voiceChannel: {
|
||||
joined: newChannel,
|
||||
},
|
||||
user: member.user,
|
||||
};
|
||||
|
||||
pluginData.state.queue.add(() => {
|
||||
runAutomod(pluginData, context);
|
||||
});
|
||||
context.voiceChannel!.joined = newChannel;
|
||||
addToQueue = true;
|
||||
} else if (oldChannel && !newChannel) {
|
||||
const context: AutomodContext = {
|
||||
member,
|
||||
timestamp,
|
||||
voiceChannel: {
|
||||
left: oldChannel,
|
||||
},
|
||||
user: member.user,
|
||||
};
|
||||
|
||||
pluginData.state.queue.add(() => {
|
||||
runAutomod(pluginData, context);
|
||||
});
|
||||
context.voiceChannel!.left = oldChannel;
|
||||
addToQueue = true;
|
||||
} else if (oldChannel?.id && newChannel?.id && oldChannel.id === newChannel.id) {
|
||||
const context: AutomodContext = {
|
||||
member,
|
||||
timestamp,
|
||||
voiceChannel: {
|
||||
left: oldChannel,
|
||||
joined: newChannel,
|
||||
},
|
||||
user: member.user,
|
||||
};
|
||||
context.voiceChannel!.left = oldChannel;
|
||||
context.voiceChannel!.joined = newChannel;
|
||||
addToQueue = true;
|
||||
}
|
||||
|
||||
if (addToQueue) {
|
||||
pluginData.state.queue.add(() => {
|
||||
runAutomod(pluginData, context);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue