This slash command sends a message to the channel you set as the environment variable `CMDLOGS_CHANNEL_ID`, which includes mention of who used the command and what they suggested. The bot sends a confirmation message after the suggestion was sent to the channel you set as `SUGGESTIONS_CHANNEL_ID` to the user who used the command. Remember to register a slash command named "/suggest" with a required `String` option named `suggestion`. This snippet is a updated version of @justCallMeJade's "Discord Suggestion Command" snippet.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let event = context.params.event;
let suggestion = event.data.options[0].value;
let message = await lib.discord.channels['@0.2.0'].messages.create({
channel_id: process.env.SUGGESTIONS_CHANNEL_ID,
content: `New Suggestion`,
tts: false,
embeds: [
{
type: 'rich',
title: '',
description: suggestion,
color: 0xffffff,
author: {
name: event.member.user.username,
icon_url: `https://cdn.discordapp.com/avatars/${event.member.user.id}/${event.member.user.avatar}.png`,
},
},
],
});
await lib.discord.channels['@0.1.1'].messages.reactions.create({
emoji: process.env.UPVOTE_EMOJI_ID,
message_id: message.id,
channel_id: process.env.SUGGESTIONS_CHANNEL_ID,
});
await lib.discord.channels['@0.1.1'].messages.reactions.create({
emoji: process.env.DOWNVOTE_EMOJI_ID,
message_id: message.id,
channel_id: process.env.SUGGESTIONS_CHANNEL_ID,
});
// DM response to the user who suggested
await lib.discord.users['@0.1.5'].dms.create({
recipient_id: event.member.user.id,
content: ``,
tts: false,
embeds: [
{
type: 'rich',
title: `Hey ${event.member.user.username}, your suggestion has been sent!`,
description: `"\`\`\`\n${suggestion}\n\`\`\`"`,
color: 0x5865f2,
},
],
});
// Command Logs
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: process.env.CMDLOGS_CHANNEL_ID,
content: `Command Usage`,
tts: false,
embeds: [
{
type: 'rich',
title: '',
description: '',
color: 0x0dedcf,
fields: [
{
name: `Author`,
value: `<@${event.member.user.id}>`,
},
{
name: `Command`,
value: `\`/suggest\``,
},
{
name: `Suggestion`,
value: `\`\`\`\n${suggestion}\n\`\`\``,
},
],
},
],
});