This command sends suggestions (for example, related to the growth of the server) to a designated channel named #suggestions. If no channel named #suggestions exists, this command will create one. The command will auto-delete the suggestion message after sending so that no one can see the suggestion anywhere other then the designated channel!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const message = context.params.event;
let sleep = async (ms) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, ms || 0);
});
};
if (message.content.startsWith(`${process.env.PREFIX}suggest`)) {
await sleep(1500);
await lib.discord.channels['@0.2.0'].messages.destroy({
channel_id: context.params.event.channel_id,
message_id: context.params.event.id,
});
const args = message.content.split(' ').slice(1);
if (!args.length)
return lib.discord.channels['@0.2.0'].messages.create({
content: '< | Wrong command usage, ``',
channel_id: message.channel_id,
});
const suggestion = args.join(' ');
let channel = await lib.discord.guilds['@0.1.0'].channels.list({
guild_id: message.guild_id,
});
channel = channel.find(
(x) => x.name === 'suggestion' || x.name === 'suggestions'
);
if (!channel)
channel = await lib.discord.guilds['@0.1.0'].channels.create({
guild_id: message.guild_id,
name: `suggestions`,
});
const msg = await lib.discord.channels['@0.2.0'].messages.create({
content: ``,
embed: {
author: {
name: ` | ${context.params.event.author.username}#${context.params.event.author.discriminator}`,
icon_url: `https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}`,
},
color: 0xff0000,
description: suggestion,
},
channel_id: channel.id,
});
await sleep(1000);
for (let emoji of [
'⬆️',
'⬇️',
]) {
await lib.discord.channels['@0.2.0'].messages.reactions.create({
emoji,
message_id: msg.id,
channel_id: msg.channel_id,
});
}
await lib.discord.channels['@0.2.0'].messages.create({
content: `<#${channel.id}> | Thanks for the suggestion, we really appreciate it :)`,
channel_id: message.channel_id,
});
}