Use this snippet to make a slash command that makes the bot make their own invite link to the channel you put in the slash command. For this to work you'll need to go to https://autocode.com/tools/discord/command-builder/ and make a command, name the command `create-invite` and make one option for channel and name it `channel`.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const event = context.params.event;
let isAdmin = (context.params.event.member.permissions & (1 << 3)) === 1 << 3;
// This checkes what channel to make the link for.
let channel = '';
if (event.data.options[0] !== undefined)
channel = event.data.options[0].value;
// checks if the user is admin.
if (isAdmin) {
// This makes the link.
const invite = await lib.discord.invites['@0.1.0'].create({
channel_id: `${channel}`,
max_age: 0,
max_uses: 0,
temporary: false,
unique: false,
target_type: 'GUILD',
});
// This sends the message.
await lib.discord.channels['@0.2.1'].messages.create({
channel_id: `${event.channel_id}`,
content: `<@${event.member.user.id}> Here is my invite link for <#${channel}> as requested: https://discord.gg/${invite.code} `,
});
// This sends message if the person isn't admin.
} else {
await lib.discord.channels['@0.2.1'].messages.create({
channel_id: `${event.channel_id}`,
content: `Sorry, this command is admin only!`,
});
}