This is a fun slash command which returns a random number between 1 - 100 to display a percentage of a user being suspicious. Make sure to register a slash command named "sus" via the [command builder](https://autocode.com/tools/discord/command-builder/) with a User option named "user" and keep it optional.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let event = context.params.event;
// if a user was passed through the option, grabs their id otherwise the command executor's
let user_id = event.data.options.length
? event.data.options[0].value
: event.member.user.id;
let member = await lib.discord.guilds['@0.1.0'].members.retrieve({
user_id,
guild_id: event.guild_id,
});
let channel = await lib.discord.channels['@0.3.0'].retrieve({
channel_id: event.channel_id,
});
// gets a random int between 1 - 100
let rNum = Math.floor(Math.random() * 100) + 1;
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: event.channel_id,
content: `${member.user.username} is ${rNum}% sus`,
});
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: process.env.CMDLOGS_CHANNEL,
content: `Command Usage`,
tts: false,
embeds: [
{
type: 'rich',
title: '',
description: '',
color: 0x0dedcf,
fields: [
{
name: `Author`,
value: `<@${event.member.user.id}> (${event.member.user.username}#${event.member.user.discriminator})`,
},
{
name: `Channel`,
value: `<#${event.channel_id}> (#${channel.name})`,
},
{
name: `Command`,
value: event.data.name,
},
],
},
],
});