From b7164cf005c38f68fdba66fec28d2a1559050b81 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 29 Jul 2021 17:04:07 +0200 Subject: [PATCH] Fix privateChat with Bot --- .../steamwar/bungeecore/bot/AuthManager.java | 20 +++++++++++-------- .../bot/util/DiscordSchemAlert.java | 12 +++++++++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/bot/AuthManager.java b/src/de/steamwar/bungeecore/bot/AuthManager.java index e6cfa153..1502b681 100644 --- a/src/de/steamwar/bungeecore/bot/AuthManager.java +++ b/src/de/steamwar/bungeecore/bot/AuthManager.java @@ -65,16 +65,20 @@ public class AuthManager { builder.setContent(":white_check_mark: Dein Discord Konto wurde mit **" + user.getUserName() + "** verknüpft"); builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")), Button.danger("invalid", "Ich war das nicht"))); - member.getUser().openPrivateChannel().complete().sendMessage(builder.build()).complete(); - if(member.getNickname() == null) { - try { - member.getGuild().modifyNickname(member, user.getUserName()).complete(); - } catch (Exception e) { - // Ignored + try { + member.getUser().openPrivateChannel().complete().sendMessage(builder.build()).complete(); + if (member.getNickname() == null) { + try { + member.getGuild().modifyNickname(member, user.getUserName()).complete(); + } catch (Exception e) { + // Ignored + } } + TOKENS.remove(code); + return member; + } catch (Exception e) { + return null; } - TOKENS.remove(code); - return member; } else { return null; } diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java b/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java index a36135db..58933a66 100644 --- a/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java +++ b/src/de/steamwar/bungeecore/bot/util/DiscordSchemAlert.java @@ -46,7 +46,11 @@ public class DiscordSchemAlert { MessageBuilder messageBuilder = new MessageBuilder(); messageBuilder.setEmbeds(builder.build()); - dcUser.openPrivateChannel().complete().sendMessage(messageBuilder.build()).complete(); + try { + dcUser.openPrivateChannel().complete().sendMessage(messageBuilder.build()).complete(); + } catch (Exception e) { + // Ignored + } } } @@ -63,7 +67,11 @@ public class DiscordSchemAlert { MessageBuilder messageBuilder = new MessageBuilder(); messageBuilder.setEmbeds(builder.build()); messageBuilder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")))); - dcUser.openPrivateChannel().complete().sendMessage(messageBuilder.build()).complete(); + try { + dcUser.openPrivateChannel().complete().sendMessage(messageBuilder.build()).complete(); + } catch (Exception e) { + // Ignored + } } } }