This snippet allows premium members to "summon" another specified member if they use a specific reaction emoji.
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const event = context.params.event;
const emojiId = event.emoji.id;
const user = event.user_id;
// You can set multiple roles here seperated with a comma
const roleIds = new Set(['0000000000000000000']);
const hasRole = event.member.roles.some((r) => roleIds.has(r));
const sendMessage = (content = '', description = '', embeds = []) =>
lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${event.channel_id}`,
content: content,
tts: false,
message_reference: {
message_id: `${event.message_id}`,
},
embeds: embeds,
});
if (hasRole) {
if (emojiId == `0000000000000000000`) {
// My emoji id
await sendMessage(`<@${user}> has summoned <@0000000000000000000>`);
}
}