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