Mutes a user and sends you an ephemeral message back. You need to fill in "your_mute_role_id" with the ID of your Mute role. Also you need to go to the Slash Command Builder and make a mute command. Then add a user option (the user you want to mute) and a string option (reason). If you mute a user, the muted user will get an Info that he/she got muted and you receive a ephemeral messages that you successfully muted a user!
// authenticates you with the API standard library
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let isKICK_MEMBERS =
(context.params.event.member.permissions & (1 << 1)) === 1 << 1;
if (isKICK_MEMBERS) {
let userId = context.params.event.data.options[0].value;
let reason = context.params.event.data.options[1].value;
let roleId = `Your_Mute_Role_ID`;
let result = await lib.discord.guilds['@0.1.0'].members.roles.update({
role_id: roleId, // required
user_id: userId, // required
guild_id: context.params.event.guild_id, // required
});
await lib.http.request['@1.1.6'].post({
url: `https://discord.com/api/webhooks/${context.params.event.application_id}/${context.params.event.token}`,
params: {
content: ``,
flags: 64,
embeds: [
{
type: 'rich',
title: ``,
description: `**You have successfully muted <@${userId}>! <:yessir:881145598387048448>**`,
color: 0xf1e0b7,
},
],
},
});
// make API request
// make API request
let guild = await lib.discord.guilds['@0.1.0'].retrieve({
guild_id: context.params.event.guild_id, // required
});
await lib.discord.users['@0.1.4'].dms.create({
recipient_id: `${userId}`,
content: '',
embed: {
type: 'rich',
title: `**You were muted!**`,
description: `
*In:* **${guild.name}**
*For:* **${reason}**
*Moderator:* **<@${context.params.event.member.user.id}>**`,
color: 131644,
footer: {
text: `If you think you have been muted for no reason, please create a ticket!`,
},
},
});
} else {
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `**<@${context.params.event.member.user.id}> You dont have permissions to use this command!**`,
});
}
//inspired by TheZeno