mirror of
https://github.com/pacnpal/markov-discord.git
synced 2025-12-20 03:01:04 -05:00
Dynamically generate invite URL
This commit is contained in:
21
src/index.ts
21
src/index.ts
@@ -354,20 +354,31 @@ function helpMessage(): Discord.MessageOptions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateInviteUrl(): string {
|
||||||
|
return client.generateInvite({
|
||||||
|
scopes: ['bot', 'applications.commands'],
|
||||||
|
permissions: [
|
||||||
|
'VIEW_CHANNEL',
|
||||||
|
'SEND_MESSAGES',
|
||||||
|
'SEND_TTS_MESSAGES',
|
||||||
|
'ATTACH_FILES',
|
||||||
|
'READ_MESSAGE_HISTORY',
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function inviteMessage(): Discord.MessageOptions {
|
function inviteMessage(): Discord.MessageOptions {
|
||||||
const avatarURL = client.user.avatarURL() || undefined;
|
const avatarURL = client.user.avatarURL() || undefined;
|
||||||
|
const inviteUrl = generateInviteUrl();
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setAuthor(`Invite ${client.user?.username}`, avatarURL)
|
.setAuthor(`Invite ${client.user?.username}`, avatarURL)
|
||||||
.setThumbnail(avatarURL as string)
|
.setThumbnail(avatarURL as string)
|
||||||
.addField(
|
.addField('Invite', `[Invite ${client.user.username} to your server](${inviteUrl})`);
|
||||||
'Invite',
|
|
||||||
`[Invite ${client.user.username} to your server](https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=105472&scope=bot%20applications.commands)`
|
|
||||||
);
|
|
||||||
return { embeds: [embed] };
|
return { embeds: [embed] };
|
||||||
}
|
}
|
||||||
|
|
||||||
client.on('ready', async (readyClient) => {
|
client.on('ready', async (readyClient) => {
|
||||||
L.info('Bot logged in');
|
L.info({ inviteUrl: generateInviteUrl() }, 'Bot logged in');
|
||||||
|
|
||||||
await deployCommands(readyClient.user.id);
|
await deployCommands(readyClient.user.id);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user