Check permission before sending typing

This commit is contained in:
Sebastien 2019-09-10 09:09:37 +02:00
parent 05735ff833
commit 4f2fe337e4

View File

@ -27,6 +27,7 @@ public class Init {
/** /**
* Initialize all bot functionality * Initialize all bot functionality
*
* @param token bot user token * @param token bot user token
* @return JDA object * @return JDA object
*/ */
@ -37,12 +38,9 @@ public class Init {
//Bot démarrer sans token //Bot démarrer sans token
if (token == null) { if (token == null) {
logger.fatal("Please enter bot token as an argument."); logger.fatal("Please enter bot token as an argument.");
} } else {
else
{
//Token présent //Token présent
try try {
{
logger.info("Connecting to Discord api..."); logger.info("Connecting to Discord api...");
//connection au bot //connection au bot
@ -58,9 +56,9 @@ public class Init {
jda.getPresence().setPresence(OnlineStatus.DO_NOT_DISTURB, Activity.playing("Loading...")); jda.getPresence().setPresence(OnlineStatus.DO_NOT_DISTURB, Activity.playing("Loading..."));
jda.getTextChannels().forEach(textChannel -> { jda.getTextChannels().forEach(textChannel -> {
try { if (textChannel.canTalk())
textChannel.sendTyping().queue(); textChannel.sendTyping().complete();
}catch (Exception ignored){}
}); });
@ -75,9 +73,7 @@ public class Init {
} }
} } catch (LoginException | InterruptedException e) {
catch (LoginException | InterruptedException e)
{
logger.catching(e); logger.catching(e);
} }
} }