Skip to content

Commit 0f2692b

Browse files
committed
fix: added some comments and deleting old messages from the bot in rules channel
1 parent f3eb29e commit 0f2692b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utils/reactionHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,21 @@ export async function sendReactionRoleMessage(client: Client) {
9090

9191
console.debug('Got messages');
9292

93+
// Get an existing message with identical contents
9394
let message = messages
9495
.filter((item) => item.content === messageBody)
9596
.last();
9697

9798
if (message && message.author.id == message.client.user.id) {
9899
console.debug('Attempting to edit message...');
100+
// Edit the message
99101
await message.edit(messageBody);
100102
console.debug('Message edited');
101103
} else {
104+
// Delete old messages from the bot
105+
messages.filter((item) => item.author.id == item.client.user.id).forEach((item) => item.delete())
102106
console.debug('Attempting to send message...');
107+
// Send the message
103108
message = await channel.send(messageBody);
104109
console.debug('Message sent');
105110
}

0 commit comments

Comments
 (0)