Skip to content

Commit

Permalink
Update NBot 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
NeutronStars committed Jun 5, 2018
1 parent 7960888 commit 49241b9
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ repositories {
}

dependencies {
compile 'net.dv8tion:JDA:3.6.0_354'
compile 'net.dv8tion:JDA:3.6.0_373'
}
2 changes: 1 addition & 1 deletion src/main/java/fr/neutronstars/nbot/NBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
public final class NBot
{
private static final String NAME = "NBot", VERSION = "2.1.0", AUTHOR = "NeutronStars", JDA_VERSION = "3.6.0_354";
private static final String NAME = "NBot", VERSION = "2.1.1", AUTHOR = "NeutronStars", JDA_VERSION = "3.6.0_373";
private static final NBotLogger logger = StaticLoggerBinder.getSingleton().getLoggerFactory().getLogger("NBot");
private static NBotServer server;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,13 @@ private void info(SelfUser user, Channel channel)
EmbedBuilder builder = new EmbedBuilder();
builder.setAuthor(user.getName(), "https://discordapp.com/oauth2/authorize?client_id=" + user.getId() + "&scope=bot&permissions=2146958583", user.getAvatarUrl() == null ? null : user.getAvatarUrl() + "?size=256");
builder.setDescription("To invite the bot to your guild, click on its name above.");
builder.addBlankField(false);
builder.addField("Guilds", "[>](1) " + NBot.getJDA().getGuilds().size(), true);
builder.addField("Users", "[>](1) " + NBot.getJDA().getUsers().size(), true);
builder.addField("Plugins", "[>](1) " + NBot.getPluginManager().getPlugins().size(), false);
builder.addBlankField(false);
builder.addField("Plugins", "[>](1) " + NBot.getPluginManager().getPlugins().size(), true);
builder.addField("JDA version", "[>](1) "+NBot.getJdaVersion(), true);
builder.addBlankField(false);
builder.setFooter("this bot use "+NBot.getName() + " v" + NBot.getVersion() + " developped by " + NBot.getAuthor(), null);
builder.setColor(Color.RED);
channel.sendMessageToChannel(builder.build());
Expand Down Expand Up @@ -221,4 +225,22 @@ else if(args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("-r"))
targetCommand.removeChannel(textChannel);
channel.sendMessageToChannel(user.getAsMention()+", removing channel "+textChannel.getName()+" for the command "+targetCommand.getSimpleName()+" !");
}

@Command(name = "jda", description = "Send the link from the JDA API in GitHub.", toPrivate = true)
private void onJDA(Channel channel)
{
channel.sendMessageToChannel("https://github.com/DV8FromTheWorld/JDA");
}

@Command(name = "nbot", description = "Send the link from the NBot API in GitHub.", toPrivate = true)
private void onNBot(Channel channel)
{
channel.sendMessageToChannel("https://github.com/NeutronStars/NBot_v2_0");
}

@Command(name = "jdadoc", description = "Send the link from the JDA documentation.", toPrivate = true)
private void onJDADoc(Channel channel)
{
channel.sendMessageToChannel("http://home.dv8tion.net:8080/job/JDA/javadoc/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private void onHelp(CommandSender sender, Channel channel, Guild guild)

Map<NBotPlugin, List<SimpleCommand>> pluginCommandsMap = CommandManager.getPluginCommands(false);
for(Map.Entry<NBotPlugin, List<SimpleCommand>> entry : pluginCommandsMap.entrySet())
sendPrivateHelp(entry.getKey().getName()+" Commands", (User) sender, CommandManager.getDefaultCommands(false));
sendPrivateHelp(entry.getKey().getName()+" Commands", (User) sender, entry.getValue());
return;
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/fr/neutronstars/nbot/entity/Guild.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.dv8tion.jda.core.managers.GuildManager;
import net.dv8tion.jda.core.managers.GuildManagerUpdatable;
import net.dv8tion.jda.core.requests.RestAction;
import net.dv8tion.jda.core.requests.restaction.MemberAction;
import net.dv8tion.jda.core.requests.restaction.pagination.AuditLogPaginationAction;
import net.dv8tion.jda.core.utils.cache.MemberCacheView;
import net.dv8tion.jda.core.utils.cache.SnowflakeCacheView;
Expand Down Expand Up @@ -74,6 +75,18 @@ public RestAction<EnumSet<Region>> retrieveRegions()
return guild.retrieveRegions();
}

@Override
public RestAction<EnumSet<Region>> retrieveRegions(boolean includeDeprecated)
{
return guild.retrieveRegions(includeDeprecated);
}

@Override
public MemberAction addMember(String accessToken, String userId)
{
return guild.addMember(accessToken, userId);
}

public String getName()
{
return guild.getName();
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/fr/neutronstars/nbot/listener/NBotListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.dv8tion.jda.core.events.ReadyEvent;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent;
import net.dv8tion.jda.core.hooks.EventListener;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import org.slf4j.impl.NBotLogger;

Expand All @@ -32,6 +33,12 @@ public void onReady(ReadyEvent event)
{
pluginManager.enablePlugins();

for(Object object : event.getJDA().getRegisteredListeners())
{
if(object instanceof EventListener && object != this)
((EventListener)object).onEvent(event);
}

StringBuilder builder = new StringBuilder("\n-------------------------------\n")
.append(event.getJDA().getSelfUser().getName()).append(" is Ready.\n-------------------------------");

Expand Down Expand Up @@ -89,10 +96,4 @@ private void deleteFile(File file)
}
file.delete();
}

@Override
public void onMessageReactionAdd(MessageReactionAddEvent event)
{
System.out.println(event.getReactionEmote());
}
}
2 changes: 1 addition & 1 deletion src/main/java/fr/neutronstars/nbot/plugin/NBotPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final String[] getAuthors()

public String getAuthorsToString()
{
StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder(32);
for(int i = 0; ; i++)
{
if(i == authors.length) return builder.length() > 0 ? builder.toString() : "Not author";
Expand Down

0 comments on commit 49241b9

Please sign in to comment.