Improve error message when primary channel is improperly defined (#4586)

* Improve message verboseness when primary channel is improperly defined

* Clarify primary channel behavior
This commit is contained in:
Josh Roy 2021-10-20 08:09:56 -04:00 committed by GitHub
parent 90e4845627
commit 58b0fb089f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -256,6 +256,8 @@ discordErrorLoggerNoPerms=Discord console logger has been disabled due to insuff
discordErrorNoGuild=Invalid or missing server ID! Please follow the tutorial in the config in order to setup the plugin.
discordErrorNoGuildSize=Your bot is not in any servers! Please follow the tutorial in the config in order to setup the plugin.
discordErrorNoPerms=Your bot cannot see or talk in any channel! Please make sure your bot has read and write permissions in all channels you wish to use.
discordErrorNoPrimary=You did not define a primary channel or your defined primary channel is invalid. Falling back to the default channel: #{0}.
discordErrorNoPrimaryPerms=Your bot cannot speak in your primary channel, #{0}. Please make sure your bot has read and write permissions in all channels you wish to use.
discordErrorNoToken=No token provided! Please follow the tutorial in the config in order to setup the plugin.
discordErrorWebhook=An error occurred while sending messages to your console channel\! This was likely caused by accidentally deleting your console webhook. This can usually by fixed by ensuring your bot has the "Manage Webhooks" permission and running "/ess reload".
discordLoggingIn=Attempting to login to Discord...

View File

@ -179,7 +179,9 @@ and `staff`. If you only completed the initial setup, the `staff` channel defini
most situations however, as the message system will always fallback to the `primary` channel if a channel ID is
invalid.
Now on to the types of messages you can receive themselves (which is where you're going to use these channel
**Note:** If you do not define a `primary` channel, the default channel of your server will be used.
Now on to the types of messages you can receive themselves (which is where you're going to use these channel
definitions). In the `message-types` section of the config, you can see a list of message types (join/leave/chat/etc.)
on the left (as the key), and on the right there is a channel definition.

View File

@ -278,9 +278,14 @@ public class JDADiscordService implements DiscordService, IEssentialsModule {
TextChannel channel = guild.getTextChannelById(plugin.getSettings().getPrimaryChannelId());
if (channel == null) {
channel = guild.getDefaultChannel();
if (channel == null || !channel.canTalk()) {
if (channel == null) {
throw new RuntimeException(tl("discordErrorNoPerms"));
}
logger.warning(tl("discordErrorNoPrimary", channel.getName()));
}
if (!channel.canTalk()) {
throw new RuntimeException(tl("discordErrorNoPrimaryPerms", channel.getName()));
}
primaryChannel = channel;
}