Some servers have a channel named 'counting'. It's where the members of the server work together and count together, to reach some kind of number goal. Sometimes people make mistakes without noticing it, for example they accidentally miss a digit (i.e. they say 12234 instead of 12345). This bot automatically deletes the message if it's not the expected answer.
//slowmode is recommended
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let message = context.params.event.content
let current_num = await lib.utils.kv['@0.1.16'].get({
key: `currentnum`,
defaultValue: 1
});
let isAdmin = (context.params.event.member.permissions & (1<<3)) === (1<<3);
if (context.params.event.channel_id == 'COUNTING_CHANNEL_ID') { //replace with real counting channel id
if (context.params.event.content.startsWith('-reset') && isAdmin) {
await lib.utils.kv['@0.1.16'].set({
key: `currentnum`,
value: 1
});
} else if (parseInt(message.split(' ')[0]) !== parseInt(current_num)) {
await lib.discord.channels['@0.1.1'].messages.destroy({
message_id: `${context.params.event.id}`,
channel_id: `${context.params.event.channel_id}`
});
} else {
await lib.utils.kv['@0.1.16'].set({
key: `currentnum`,
value: parseInt(message.split(' ')[0]) + 1
});
}
}