Make suggestions using "!suggest" and the bot will send that suggestion to the #suggestions 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('!suggest')) {
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: 0xffa500,
description: suggestion,
},
channel_id: channel.id,
});
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 suggestions, We really appreciate it :)`,
channel_id: message.channel_id,
});
}