🚑 bot delete in all channel counter word
This commit is contained in:
parent
8877d5dacd
commit
15646f4ea0
1 changed files with 12 additions and 10 deletions
|
@ -14,14 +14,6 @@ export default {
|
||||||
const messages = await message.channel.messages.fetch({ limit: 2 });
|
const messages = await message.channel.messages.fetch({ limit: 2 });
|
||||||
const lastMessage = messages.last();
|
const lastMessage = messages.last();
|
||||||
|
|
||||||
if (lastMessage?.author.id === author.id) {
|
|
||||||
logger.verbose(
|
|
||||||
`${author.username} sent the last message therefor not allowing again.`
|
|
||||||
);
|
|
||||||
await message.delete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { id: guildId } = guild;
|
const { id: guildId } = guild;
|
||||||
const { id: channelId } = channel;
|
const { id: channelId } = channel;
|
||||||
|
|
||||||
|
@ -30,20 +22,30 @@ export default {
|
||||||
channelId,
|
channelId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!counter) {
|
if (counter === null) {
|
||||||
logger.verbose(
|
logger.verbose(
|
||||||
`No counter found for guild ${guildId} and channel ${channelId}`
|
`No counter found for guild ${guildId} and channel ${channelId}`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
lastMessage?.author.id === author.id &&
|
||||||
|
channel.id === counter.channelId
|
||||||
|
) {
|
||||||
|
logger.verbose(
|
||||||
|
`${author.username} sent the last message therefor not allowing again.`
|
||||||
|
);
|
||||||
|
await message.delete();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (content !== counter.word) {
|
if (content !== counter.word) {
|
||||||
logger.verbose(
|
logger.verbose(
|
||||||
`Counter word ${counter.word} does not match message ${content}`
|
`Counter word ${counter.word} does not match message ${content}`
|
||||||
);
|
);
|
||||||
|
|
||||||
await message.delete();
|
await message.delete();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue