E-mail any person to their Gmail ID. Create a command like this: `/email <gmail-id> <subject> <content>` all set to required with `string` as an input for those options.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let email = context.params.event.data.options[0].value;
let subject = context.params.event.data.options[1].value;
let text = context.params.event.data.options[2].value;
if (context.params.event.member.user.id == process.env.OwnerID) { // Checking who's using the command
// Sending mail to the inputted email ID
await lib.gmail.messages['@0.2.8'].create({
to: `${email}`,
subject: `${subject}`,
text: `${text}`,
});
// Confirming that the email is sent
await lib.discord.interactions['@1.0.1'].followups.ephemeral.create({
token: `${context.params.event.token}`,
content: `Email sent to **${email}**\nSubject: **${subject}**\nContent: ${text}`,
});
} else {
// Denying the use of command if the user using the command is not you
await lib.discord.interactions['@1.0.1'].responses.ephemeral.create({
token: `${context.params.event.token}`,
content: `You don't have the permission to use the command.`,
response_type: 'CHANNEL_MESSAGE_WITH_SOURCE',
});
}