Highfive your friends with this simple command! To setup the command, simply go to https://autocode.com/tools/discord/command-builder/ and create a command called highfive. Then create an option called user (Make sure you select user, not string on the option). After that, you'll be good to go!
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let guild = await lib.discord.guilds['@0.1.0'].retrieve({
guild_id: context.params.event.guild_id,
});
let user = context.params.event.data.options[0].value;
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `<@!${context.params.event.member.user.id}>`,
embed: {
title: '✋',
description: `Highfive sent to <@${user}>!`,
color: 0xffec45,
footer: {
text: `To send another highfive, use /highfive`,
},
}
})
let threads = await lib.discord.channels['@0.2.0'].threads.create({
channel_id: `${context.params.event.channel_id}`, // required
name: `Highfive!`, // required
auto_archive_duration: 1440,
type: 'GUILD_PUBLIC_THREAD',
});
let thread = await lib.discord.channels['@0.2.0'].threads.members.create({
thread_id: `${threads.id}`,
user_id: `${context.params.event.member.user.id}`,
});
await lib.discord.channels['@0.2.0'].threads.update({
thread_id: `${threads.id}`,
rate_limit_per_user: 3,
});
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${threads.id}`,
content: `<@${user}> <@!${context.params.event.member.user.id}>
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you
- Rick Astley `,
embed: {
type: 'rich',
title: `**You got Rickrolled!**`,
description: `
By: **${context.params.event.member.user.username}**
For: **Autocode Community Challenge!**`,
color: 0xf73e1e,
}
})