Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix *infinite embed scroll* on android #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/corebot/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class Commands{

builder.addField("Downloads", args[0] + (args[0].endsWith("/") ? "" : "/") + "releases", false);

messages.channel.getGuild().getTextChannelById(pluginChannelID).sendMessage(builder.build()).queue();
messages.guild.getTextChannelById(pluginChannelID).sendMessage(builder.build()).queue();

messages.text("*Plugin posted.*");
}catch(IOException e){
Expand Down Expand Up @@ -147,7 +147,7 @@ public class Commands{

if(map.description != null) builder.setFooter(map.description);

messages.channel.getGuild().getTextChannelById(mapsChannelID).sendFile(mapFile).addFile(imageFile.file()).embed(builder.build()).queue();
messages.guild.getTextChannelById(mapsChannelID).sendFile(mapFile).addFile(imageFile.file()).embed(builder.build()).queue();

messages.text("*Map posted successfully.*");
}catch(Exception e){
Expand Down Expand Up @@ -244,7 +244,7 @@ public class Commands{
messages.text("**@**, you've been warned *@*.", user.getAsMention(), warningStrings[Mathf.clamp(warnings - 1, 0, warningStrings.length - 1)]);
prefs.put("warnings-" + l, warnings + "");
if(warnings >= 3){
messages.lastMessage.getGuild().getTextChannelById(moderationChannelID)
messages.guild.getTextChannelById(moderationChannelID)
.sendMessage("User " + user.getAsMention() + " has been warned 3 or more times!").queue();
}
}catch(Exception e){
Expand Down Expand Up @@ -368,7 +368,8 @@ void handle(Message message){

EmbedBuilder builder = new EmbedBuilder().setColor(messages.normalColor).setColor(messages.normalColor)
.setImage("attachment://" + previewFile.getName())
.setAuthor(message.getAuthor().getName(), message.getAuthor().getAvatarUrl(), message.getAuthor().getAvatarUrl()).setTitle(schem.name());
.setAuthor(message.getAuthor().getName(), message.getAuthor().getAvatarUrl(), message.getAuthor().getEffectiveAvatarUrl())
.setTitle(schem.name());

if(!schem.description().isEmpty()) builder.setFooter(schem.description());

Expand Down
13 changes: 4 additions & 9 deletions src/corebot/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private static String durFormat(Duration duration){
if(duration.toHours() > 0) return duration.toHours() + "h";
return duration.toMinutes() + "m";
}

@Override
public void onMessageReceived(MessageReceivedEvent event){
try{
Expand Down Expand Up @@ -172,13 +172,12 @@ public void sendCrash(JsonValue value){
}

public void text(String text, Object... args){
lastSentMessage = channel.sendMessage(format(text, args)).complete();
lastSentMessage = channel.sendMessage(Strings.format(text, args)).complete();
}

public void info(String title, String text, Object... args){
MessageEmbed object = new EmbedBuilder()
.addField(title, format(text, args), true).setColor(normalColor).build();

.setTitle(title).setDescription(Strings.format(text, args)).setColor(normalColor).build();
skykatik marked this conversation as resolved.
Show resolved Hide resolved
lastSentMessage = channel.sendMessage(object).complete();
}

Expand All @@ -188,11 +187,7 @@ public void err(String text, Object... args){

public void err(String title, String text, Object... args){
MessageEmbed e = new EmbedBuilder()
.addField(title, format(text, args), true).setColor(errorColor).build();
.setTitle(title).setDescription(Strings.format(text, args)).setColor(errorColor).build();
lastSentMessage = channel.sendMessage(e).complete();
}

private String format(String text, Object... args){
return Strings.format(text, args);
}
}