This snippet adds a role to the person who has been sniped. Its like small game in which you snipe a person and he gets muted for 5-10 seconds but the person can be revived using `!revive`.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const sleep = async (ms) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, ms || 0);
});
};
let role = `936842265580679268`;//Role id for the person to use it [Removable, if you are removing it then remove line 17 too].
let roleId = `936823874195185674`;//Sniped role aka Mute or anything you want to add when person is sniped
let mentions = context.params.event.mentions;
let mention = mentions[0];
if (context.params.event.content.startsWith(`${process.env.PREFIX}snipe`)) {//snipe command
if (context.params.event.member.roles.includes(role)) {
await lib.discord.guilds['@0.2.2'].members.roles.update({
role_id: `${roleId}`,
user_id: `${mention.id}`,
guild_id: `${context.params.event.guild_id}`,
});
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
embeds: [
{
type: 'rich',
title: `SNIPED`,
description: `<@${mention.id}> has been sniped by <@${context.params.event.author.id}> from a long range.`,
color: 0x0a0a0a,
},
],
});
await sleep(5000);
await lib.discord.guilds['@0.2.2'].members.roles.destroy({
role_id: `${roleId}`,
user_id: `${mention.id}`,
guild_id: `${context.params.event.guild_id}`,
});
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
embeds: [
{
type: 'rich',
title: `DEAD`,
description: `<@${mention.id}> is dead because of loss of blood, sad no one came to help!!`,
color: 0x0a0a0a,
},
],
});
}
}
if (context.params.event.content.startsWith(`${process.env.PREFIX}revive`)) {
if (context.params.event.member.roles.includes(role)) {
await lib.discord.guilds['@0.2.2'].members.roles.destroy({
role_id: `${roleId}`,
user_id: `${mention.id}`,
guild_id: `${context.params.event.guild_id}`,
});
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
embeds: [
{
type: 'rich',
title: `REVIVE`,
description: `<@${mention.id}> Has been revived by <@${context.params.event.author.id}>`,
color: 0x0a0a0a,
},
],
});
}
}
//if you get any error or want to change anything, feel free to ping @DeathManager in Autocode discord server.