3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 14:11:50 +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)); const member = newState.member ?? oldState.member ?? (await guild.members.fetch(newState.id).catch(noop));
if (!member) return; if (!member) return;
const context: AutomodContext = {
member,
timestamp,
voiceChannel: {},
user: member.user,
};
let addToQueue = false;
if (!oldChannel && newChannel) { if (!oldChannel && newChannel) {
const context: AutomodContext = { context.voiceChannel!.joined = newChannel;
member, addToQueue = true;
timestamp,
voiceChannel: {
joined: newChannel,
},
user: member.user,
};
pluginData.state.queue.add(() => {
runAutomod(pluginData, context);
});
} else if (oldChannel && !newChannel) { } else if (oldChannel && !newChannel) {
const context: AutomodContext = { context.voiceChannel!.left = oldChannel;
member, addToQueue = true;
timestamp,
voiceChannel: {
left: oldChannel,
},
user: member.user,
};
pluginData.state.queue.add(() => {
runAutomod(pluginData, context);
});
} else if (oldChannel?.id && newChannel?.id && oldChannel.id === newChannel.id) { } else if (oldChannel?.id && newChannel?.id && oldChannel.id === newChannel.id) {
const context: AutomodContext = { context.voiceChannel!.left = oldChannel;
member, context.voiceChannel!.joined = newChannel;
timestamp, addToQueue = true;
voiceChannel: { }
left: oldChannel,
joined: newChannel,
},
user: member.user,
};
if (addToQueue) {
pluginData.state.queue.add(() => { pluginData.state.queue.add(() => {
runAutomod(pluginData, context); runAutomod(pluginData, context);
}); });