3
0
Fork 0
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:
almeidx 2021-08-14 16:33:01 +01:00
parent 9c437a9a98
commit 5ad461260a
No known key found for this signature in database
GPG key ID: C5FF0C40763546C5

View file

@ -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);
});