Allows members with the ADMINISTRATOR permission to send a DM with a custom title and content to a user of their choice. To set this up, go to the Slash Command Builder and make a dmembed command with a user option named user, a string option named title, and another string option named content (all of them are required). Then, to use to command, just type: /dmembed USER TITLE CONTENT, the bot will send a message in the channel once the message has sent. The user who recieves the message will get a DM that has your title, who sent the message, from which server the message was sent, and your custom content (it will be in that order on the embed, from top to bottom). IF YOU NEED HELP SETTING UP, you can ping @Zeno in the Autocode Discord for support. I think this is a very cool command, and I really hope you enjoy using it!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const event = context.params.event;
if (event.member.permission_names.includes('ADMINISTRATOR')) {
let userId = event.data.options[0].value;
let title = event.data.options[1].value;
let content = event.data.options[2].value;
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: '',
tts: false,
embed: {
type: 'rich',
title: `**${title}**`,
description: `You recieved a message!
*From:* **<@${context.params.event.member.user.id}>**
*In:* **${guild.name}**
*Message:* **${content}**`,
color: 131644,
},
});
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `**<@${context.params.event.member.user.id}> - Successfully sent your message!**`,
});
} 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 need the ADMINISTRATOR permission to use the DM Embed command!**`,
});
}