Skip to content

Commit

Permalink
Merge pull request #80 from berkingurcan/fix-remaining-messages-del
Browse files Browse the repository at this point in the history
Fix remaining messages del
  • Loading branch information
CristinaEche authored Oct 11, 2024
2 parents b500343 + 1e899e3 commit c3e04e1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "discord-bot",
"type": "module",
"version": "0.3.5",
"version": "0.3.6",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
43 changes: 38 additions & 5 deletions src/lib/startAutoPosting.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,53 @@ export const startAutoPosting = async (client, redisClient) => {
continue;
}

const surveyPrefixes = [
'# :ballot_box:',
':page_facing_up:',
':thought_balloon:',
':speech_balloon:',
'## :new:',
':timer:',
':green_circle:',
// Number Emojis
':zero:',
':one:',
':two:',
':three:',
':four:',
':five:',
':six:',
':seven:',
':eight:',
':nine:',
// Letter Emojis
':regional_indicator_a:',
':regional_indicator_b:',
':regional_indicator_c:',
':regional_indicator_d:',
':regional_indicator_e:',
':regional_indicator_f:',
':regional_indicator_g:',
':regional_indicator_h:',
':regional_indicator_i:',
':regional_indicator_j:',
'▬▬▬▬'
];


try {
if (channel.isThread()) {
const messages = await channel.messages.fetch();

const surveyMessage = messages.find(
(msg) =>
msg.content.startsWith("# :ballot_box:") ||
msg.content.startsWith("## :new:"),
const surveyMessage = messages.find((msg) =>
surveyPrefixes.some((prefix) => msg.content.startsWith(prefix))
);

if (surveyMessage) {
await surveyMessage.delete();
log.debug(`Deleted survey message: ${surveyMessage.id}`);
} else {
log.debug(`No message starting with :ballot_box: found.`);
log.debug(`No survey message found with the specified prefixes.`);
}
}
} catch (error) {
Expand Down

0 comments on commit c3e04e1

Please sign in to comment.