Only allow users to send integers in a specific channel
// Set your channel ID here
const channel_id = process.env.CHANNEL_ID
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const event = context.params.event
const isChannel = event.channel_id === channel_id
const isInteger = isInt(event.content)
// Delete message if it's not an integer
if (!(isChannel && isInteger)) {
await lib.discord.channels['@0.1.2'].messages.destroy({
channel_id: event.channel_id,
message_id: event.id,
});
}
function isInt(value) {
return !isNaN(value) &&
parseInt(Number(value)) == value &&
!isNaN(parseInt(value, 10));
}