Skip to content

Commit 77987f3

Browse files
committed
tweak: improved discord bot dangerous perms warning message
1 parent d192eff commit 77987f3

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

core/modules/DiscordBot/index.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,19 @@ export default class DiscordBot {
339339
.map((x) => x[0])
340340
if (prohibitedPermsInUse.length) {
341341
const name = this.#client.user.username;
342-
const perms = prohibitedPermsInUse.includes('Administrator')
343-
? 'Administrator'
344-
: prohibitedPermsInUse.join(', ');
345-
return sendError(
346-
`This bot (${name}) has dangerous permissions (${perms}) and for your safety the bot has been disabled.`,
347-
{ code: 'DangerousPermission' }
348-
);
342+
if(prohibitedPermsInUse.includes('Administrator')) {
343+
return sendError(
344+
`This bot (\`${name}\`) has \`Administrator\` permission and for your safety the bot has been disabled.`,
345+
{ code: 'DangerousPermission' }
346+
);
347+
} else {
348+
const permsList = prohibitedPermsInUse.map((x) => `\`${x}\``).join(', ');
349+
const plural = prohibitedPermsInUse.length > 1 ? 'has dangerous permissions' : 'has a dangerous permission';
350+
return sendError(
351+
`This bot (\`${name}\`) ${plural} (${permsList}) and for your safety the bot has been disabled.`,
352+
{ code: 'DangerousPermission' }
353+
);
354+
}
349355
}
350356

351357
//Fetching announcements channel

core/routes/settings/saveConfigs.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,8 @@ const handleDiscordCard: CardHandler = async (inputConfig, sendTypedResp) => {
377377
- **Bot is not in the server:** you need to [INVITE THE BOT](${inviteUrl}) to join the server.
378378
- **Wrong bot:** you may be using the token of another discord bot.`;
379379
} else if (errorCode === 'DangerousPermission') {
380-
extraContext = `You need to remove the permissions listed above to be able to enable this bot.
381-
This should be done in the Discord Server role configuration page and not in the Dev Portal.
382-
Check every single role that the bot has in the server.
383-
384-
Please keep in mind that:
380+
extraContext = `To enable the bot, you need to remove the permissions listed above, which can be done in the Discord Server role configuration page. Please check every single role that the bot has, including the \`@everyone\` role.
381+
**Please keep in mind that:**
385382
- These permissions are dangerous because if the bot token leaks, an attacker can cause permanent damage to your server.
386383
- No bot should have more permissions than strictly needed, especially \`Administrator\`.
387384
- You should never have multiple bots using the same token, create a new one for each bot.`;

0 commit comments

Comments
 (0)