mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21: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));
|
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);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue