Skip to content

Commit

Permalink
Formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichailiK committed Oct 11, 2024
1 parent 96ffcd8 commit 58a9e76
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
29 changes: 18 additions & 11 deletions src/main/java/com/jagrosh/jmusicbot/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
public class Listener extends ListenerAdapter
{
private final Bot bot;

public Listener(Bot bot)
{
this.bot = bot;
}

@Override
public void onReady(ReadyEvent event)
public void onReady(ReadyEvent event)
{
if(event.getJDA().getGuildCache().isEmpty())
{
Expand All @@ -56,7 +56,7 @@ public void onReady(ReadyEvent event)
log.warn(event.getJDA().getInviteUrl(JMusicBot.RECOMMENDED_PERMS));
}
credit(event.getJDA());
event.getJDA().getGuilds().forEach((guild) ->
event.getJDA().getGuilds().forEach((guild) ->
{
try
{
Expand All @@ -71,7 +71,7 @@ public void onReady(ReadyEvent event)
});
if(bot.getConfig().useUpdateAlerts())
{
bot.getThreadpool().scheduleWithFixedDelay(() ->
bot.getThreadpool().scheduleWithFixedDelay(() ->
{
try
{
Expand All @@ -93,13 +93,20 @@ public void onReady(ReadyEvent event)
if (data != null)
{
PrivateChannel channel = bot.getJDA().openPrivateChannelById(bot.getConfig().getOwnerId()).complete();
channel.sendMessage("# DO NOT AUTHORISE THIS WITH YOUR MAIN GOOGLE ACCOUNT!!!\n" + "## Create or use an alternative/burner Google account!\n" + "To give JMusicBot access to your Google account, go to " + data.getAuthorisationUrl() + " and enter the code **" + data.getCode() + "**").queue();
channel
.sendMessage(
"# DO NOT AUTHORISE THIS WITH YOUR MAIN GOOGLE ACCOUNT!!!\n"
+ "## Create or use an alternative/burner Google account!\n"
+ "To give JMusicBot access to your Google account, go to "
+ data.getAuthorisationUrl()
+ " and enter the code **" + data.getCode() + "**")
.queue();
}
}
}

@Override
public void onGuildMessageDelete(GuildMessageDeleteEvent event)
public void onGuildMessageDelete(GuildMessageDeleteEvent event)
{
bot.getNowplayingHandler().onMessageDelete(event.getGuild(), event.getMessageIdLong());
}
Expand All @@ -111,17 +118,17 @@ public void onGuildVoiceUpdate(@NotNull GuildVoiceUpdateEvent event)
}

@Override
public void onShutdown(ShutdownEvent event)
public void onShutdown(ShutdownEvent event)
{
bot.shutdown();
}

@Override
public void onGuildJoin(GuildJoinEvent event)
public void onGuildJoin(GuildJoinEvent event)
{
credit(event.getJDA());
}

// make sure people aren't adding clones to dbots
private void credit(JDA jda)
{
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason
public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception)
{
if (exception.getMessage().equals("Sign in to confirm you're not a bot"))
LOGGER.error("Track {} has failed to play: {}. You will need to sign in to Google to play YouTube tracks. More info: https://jmusicbot.com/youtube-oauth2", track.getIdentifier(), exception.getMessage());
LOGGER.error(
"Track {} has failed to play: Sign in to confirm you're not a bot."
+ "You will need to sign in to Google to play YouTube tracks. More info: https://jmusicbot.com/youtube-oauth2",
track.getIdentifier()
);
else
LOGGER.error("Track {} has failed to play", track.getIdentifier(), exception);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@ public FilterReply decide(Marker marker, Logger logger, Level level, String form
}
if (format.equals("OAUTH INTEGRATION: Token retrieved successfully. Store your refresh token as this can be reused. ({})"))
{
LOGGER.info("Authorization successful & retrieved token! Storing the token in {}", OtherUtil.getPath("youtubetoken.txt").toAbsolutePath());
LOGGER.info(
"Authorization successful & retrieved token! Storing the token in {}",
OtherUtil.getPath("youtubetoken.txt").toAbsolutePath()
);

try
{
Files.write(OtherUtil.getPath("youtubetoken.txt"), params[0].toString().getBytes());
}
catch (Exception e)
{
LOGGER.error(
"Failed to write the YouTube OAuth2 refresh token to storage! You will need to authorize again on the next reboot",
e
"Failed to write the YouTube OAuth2 refresh token to storage! You will need to authorize again on the next reboot",
e
);
}
return FilterReply.DENY;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
<root level="INFO">
<appender-ref ref="Simple"/>
</root>

</configuration>

0 comments on commit 58a9e76

Please sign in to comment.