Skip to content

Commit

Permalink
Add editors config
Browse files Browse the repository at this point in the history
  • Loading branch information
Senither committed Oct 11, 2017
1 parent 2f7701b commit 2f48094
Show file tree
Hide file tree
Showing 89 changed files with 699 additions and 693 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*]
root = true
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
16 changes: 8 additions & 8 deletions src/main/java/com/avairebot/orion/Orion.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public Orion() throws IOException, SQLException {

logger.info(" - Registering database table migrations");
database.getMigrations().register(
new CreateGuildTableMigration(),
new CreateGuildTypeTableMigration(),
new CreateBlacklistTableMigration(),
new CreatePlayerExperiencesTableMigration(),
new CreateFeedbackTableMigration(),
new CreateMusicPlaylistsTableMigration(),
new CreateStatisticsTableMigration(),
new CreateShardsTableMigration()
new CreateGuildTableMigration(),
new CreateGuildTypeTableMigration(),
new CreateBlacklistTableMigration(),
new CreatePlayerExperiencesTableMigration(),
new CreateFeedbackTableMigration(),
new CreateMusicPlaylistsTableMigration(),
new CreateStatisticsTableMigration(),
new CreateShardsTableMigration()
);
database.getMigrations().up();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/avairebot/orion/audio/AudioHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static synchronized GuildMusicManager getGuildAudioPlayer(Guild guild) {

public static int getQueueSize(GuildMusicManager manager) {
return manager.getPlayer().getPlayingTrack() == null ?
manager.getScheduler().getQueue().size() :
manager.getScheduler().getQueue().size() + 1;
manager.getScheduler().getQueue().size() :
manager.getScheduler().getQueue().size() + 1;
}
}
10 changes: 5 additions & 5 deletions src/main/java/com/avairebot/orion/audio/TrackScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ public AudioTrackContainer getAudioTrackContainer() {

protected void sendNowPlaying(AudioTrackContainer container) {
MessageFactory.makeSuccess(manager.getLastActiveMessage(), "Now playing: [%s](%s)\n`%s` - Requested by <@%s>",
container.getAudioTrack().getInfo().title,
container.getAudioTrack().getInfo().uri,
container.getFormattedDuration(),
container.getRequester().getId()
container.getAudioTrack().getInfo().title,
container.getAudioTrack().getInfo().uri,
container.getFormattedDuration(),
container.getRequester().getId()
).queue();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ private boolean writeTo(File file, Object value, long seconds) {
private File generateCacheFile(String string) {
String cacheToken = encrypt(string);
File cachePath = new File(storagePath,
cacheToken.substring(0, 2) + File.separator
+ cacheToken.substring(2, 4) + File.separator
cacheToken.substring(0, 2) + File.separator
+ cacheToken.substring(2, 4) + File.separator
);

if (!cachePath.exists()) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/avairebot/orion/chat/SimplePaginator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public SimplePaginator(List<?> items, int perPage, String currentPage) {

public String generateFooter(String command) {
return String.format("Page **%s** out of **%s** pages.\n`%s [page]`",
getCurrentPage(),
getPages(),
command
getCurrentPage(),
getPages(),
command
);
}
}
24 changes: 12 additions & 12 deletions src/main/java/com/avairebot/orion/commands/CommandMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ public CommandMessage(Message message, boolean mentionableCommand) {

this.mentionableCommand = mentionableCommand;
this.setContent(prepareRawContent(message.getRawContent()))
.setAuthor(message.getAuthor())
.setTime(message.getCreationTime())
.setEditedTime(message.getEditedTime())
.setAttachments(message.getAttachments())
.setEmbeds(message.getEmbeds())
.setMentionedChannels(message.getMentionedChannels())
.setMentionedRoles(message.getMentionedRoles())
.setMentionedUsers(prepareMentionedUsers(message.getMentionedUsers()))
.setMentionsEveryone(message.mentionsEveryone())
.setReactions(message.getReactions())
.setPinned(message.isPinned())
.setTTS(message.isTTS());
.setAuthor(message.getAuthor())
.setTime(message.getCreationTime())
.setEditedTime(message.getEditedTime())
.setAttachments(message.getAttachments())
.setEmbeds(message.getEmbeds())
.setMentionedChannels(message.getMentionedChannels())
.setMentionedRoles(message.getMentionedRoles())
.setMentionedUsers(prepareMentionedUsers(message.getMentionedUsers()))
.setMentionsEveryone(message.mentionsEveryone())
.setReactions(message.getReactions())
.setPinned(message.isPinned())
.setTTS(message.isTTS());
}

public CommandMessage(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public List<String> getTriggers() {
@Override
public List<String> getMiddleware() {
return Arrays.asList(
"require:user,general.administrator",
"throttle:guild,1,5"
"require:user,general.administrator",
"throttle:guild,1,5"
);
}

Expand All @@ -64,7 +64,7 @@ public boolean onCommand(Message message, String[] args) {
Role role = RoleUtil.getRoleFromMentionsOrName(message, args[0]);
if (role == null) {
MessageFactory.makeWarning(message, "<@%s> Invalid role, I couldn't find any role called **%s**",
message.getAuthor().getId(), args[0]
message.getAuthor().getId(), args[0]
).queue();
return false;
}
Expand All @@ -78,13 +78,13 @@ public boolean onCommand(Message message, String[] args) {

transformer.getSelfAssignableRoles().put(role.getId(), role.getName().toLowerCase());
orion.database.newQueryBuilder(Constants.GUILD_TABLE_NAME)
.where("id", message.getGuild().getId())
.update(statement -> {
statement.set("claimable_roles", new Gson().toJson(transformer.getSelfAssignableRoles()));
});
.where("id", message.getGuild().getId())
.update(statement -> {
statement.set("claimable_roles", new Gson().toJson(transformer.getSelfAssignableRoles()));
});

MessageFactory.makeSuccess(message, "Role **%s** role has been added to the self-assignable list.",
role.getName()
role.getName()
).queue();

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public String getDescription() {
@Override
public List<String> getUsageInstructions() {
return Arrays.asList(
"`:command` - Displays the current auto assignable role if one is set.",
"`:command <role>` - The role that should be auto assignable.",
"`:command disable` - Disables the auto assignable role."
"`:command` - Displays the current auto assignable role if one is set.",
"`:command <role>` - The role that should be auto assignable.",
"`:command disable` - Disables the auto assignable role."
);
}

Expand All @@ -53,9 +53,9 @@ public List<String> getTriggers() {
@Override
public List<String> getMiddleware() {
return Arrays.asList(
"require:bot,general.manage_roles",
"require:user,general.administrator",
"throttle:guild,1,5"
"require:bot,general.manage_roles",
"require:user,general.administrator",
"throttle:guild,1,5"
);
}

Expand All @@ -75,26 +75,26 @@ public boolean onCommand(Message message, String[] args) {
List<Role> roles = message.getGuild().getRolesByName(args[0], true);
if (roles.isEmpty()) {
MessageFactory.makeWarning(message, "<@%s> Invalid role, I couldn't find any role called **%s**",
message.getAuthor().getId(), args[0]
message.getAuthor().getId(), args[0]
).queue();
return false;
}

Role role = roles.get(0);
if (RoleUtil.isRoleHierarchyHigher(message.getMember().getRoles(), role)) {
MessageFactory.makeWarning(message,
"<@%s> The **%s** role is positioned higher in the hierarchy than any role you have, you can't add roles with a higher ranking than you have.",
message.getAuthor().getId(),
role.getName()
"<@%s> The **%s** role is positioned higher in the hierarchy than any role you have, you can't add roles with a higher ranking than you have.",
message.getAuthor().getId(),
role.getName()
).queue();
return false;
}

if (RoleUtil.isRoleHierarchyHigher(message.getGuild().getSelfMember().getRoles(), role)) {
MessageFactory.makeWarning(message,
"<@%s> The **%s** role is positioned higher in the hierarchy, I can't give/remove this role from users.",
message.getAuthor().getId(),
role.getName()
"<@%s> The **%s** role is positioned higher in the hierarchy, I can't give/remove this role from users.",
message.getAuthor().getId(),
role.getName()
).queue();
return false;
}
Expand All @@ -103,8 +103,8 @@ public boolean onCommand(Message message, String[] args) {
updateAutorole(transformer, message, role.getId());

MessageFactory.makeSuccess(message, "<@%s> **Auto assign role** on user join has been **enabled** and set to **%s**",
message.getAuthor().getId(),
role.getName()
message.getAuthor().getId(),
role.getName()
).queue();
} catch (SQLException e) {
e.printStackTrace();
Expand All @@ -117,8 +117,8 @@ private boolean disableAutoRole(Message message, GuildTransformer transformer) {
try {
transformer.setAutorole(null);
orion.database.newQueryBuilder(Constants.GUILD_TABLE_NAME)
.where("id", message.getGuild().getId())
.update(statement -> statement.set("autorole", null));
.where("id", message.getGuild().getId())
.update(statement -> statement.set("autorole", null));

MessageFactory.makeWarning(message, "<@%s> **Auto assign role** on user join is now **disabled**.", message.getAuthor().getId()).queue();
} catch (SQLException e) {
Expand Down Expand Up @@ -146,14 +146,14 @@ private RestAction<Message> sendCurrentAutoRole(Message message, GuildTransforme
}

return MessageFactory.makeSuccess(message, "<@%s> The **auto assign role** is currently set to **%s**",
message.getAuthor().getId(), role.getName()
message.getAuthor().getId(), role.getName()
);
}

private void updateAutorole(GuildTransformer transformer, Message message, String value) throws SQLException {
transformer.setAutorole(value);
orion.database.newQueryBuilder(Constants.GUILD_TABLE_NAME)
.where("id", message.getGuild().getId())
.update(statement -> statement.set("autorole", value));
.where("id", message.getGuild().getId())
.update(statement -> statement.set("autorole", value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ private boolean banUser(Message message, User user, String[] args) {
String reason = generateMessage(args);
message.getGuild().getController().ban(user, 7, reason).queue(aVoid -> {
MessageFactory.makeSuccess(message, "**%s** was permanently banned by <@%s> for \"%s\"",
user.getName() + "#" + user.getDiscriminator(),
message.getAuthor().getId(),
reason
user.getName() + "#" + user.getDiscriminator(),
message.getAuthor().getId(),
reason
).queue();
}, throwable -> MessageFactory.makeWarning(message, "Failed to ban **%s** due to an error: %s",
user.getName() + "#" + user.getDiscriminator(),
throwable.getMessage()
user.getName() + "#" + user.getDiscriminator(),
throwable.getMessage()
).queue());

return true;
Expand All @@ -89,7 +89,7 @@ private boolean userHasHigherRole(User user, Member author) {

private String generateMessage(String[] args) {
return args.length < 2 ?
"No reason was given." :
String.join(" ", Arrays.copyOfRange(args, 1, args.length));
"No reason was given." :
String.join(" ", Arrays.copyOfRange(args, 1, args.length));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ public String getName() {
@Override
public String getDescription() {
return "Sets the prefix that should be used for all commands in a given category, if no prefix is provided the category prefix will be reset back to the default instead.\n" +
"**Note:** Command prefixes cannot contain spaces and if multiple categories are using the same prefix, some commands triggers may not run the indented command since multiple commands share the same triggers but has a different prefix by default.";
"**Note:** Command prefixes cannot contain spaces and if multiple categories are using the same prefix, some commands triggers may not run the indented command since multiple commands share the same triggers but has a different prefix by default.";
}

@Override
public List<String> getUsageInstructions() {
return Arrays.asList(
"`:command <category>` - Resets the category prefix back to its default prefix.",
"`:command <category> [prefix]` - Sets the category prefix to the given prefix.");
"`:command <category>` - Resets the category prefix back to its default prefix.",
"`:command <category> [prefix]` - Sets the category prefix to the given prefix.");
}

@Override
public String getExampleUsage() {
return String.join("\n", Arrays.asList(
"`:command fun`",
"`:command admin /`",
"`:command utility %`"
"`:command fun`",
"`:command admin /`",
"`:command utility %`"
));
}

Expand All @@ -56,8 +56,8 @@ public List<String> getTriggers() {
@Override
public List<String> getMiddleware() {
return Arrays.asList(
"require:user,general.administrator",
"throttle:guild,1,5"
"require:user,general.administrator",
"throttle:guild,1,5"
);
}

Expand Down Expand Up @@ -91,7 +91,7 @@ public boolean onCommand(Message message, String[] args) {
transformer.getPrefixes().put(category.getName().toLowerCase(), prefix);
updateGuildPrefixes(message, transformer);
MessageFactory.makeSuccess(message, "All commands in the `%s` command category now uses the `%s` prefix.",
category.getName(), prefix
category.getName(), prefix
).queue();

return true;
Expand All @@ -108,7 +108,7 @@ private boolean removeCustomPrefix(Message message, GuildTransformer transformer
try {
updateGuildPrefixes(message, transformer);
MessageFactory.makeSuccess(message, "All commands in the `%s` command category has been reset to use the `%s` prefix.",
category.getName(), category.getPrefix()
category.getName(), category.getPrefix()
).queue();

return true;
Expand All @@ -120,10 +120,10 @@ private boolean removeCustomPrefix(Message message, GuildTransformer transformer

private void updateGuildPrefixes(Message message, GuildTransformer transformer) throws SQLException {
orion.database.newQueryBuilder(Constants.GUILD_TABLE_NAME)
.where("id", message.getGuild().getId())
.update(statement -> {
statement.set("prefixes", new Gson().toJson(transformer.getPrefixes()));
});
.where("id", message.getGuild().getId())
.update(statement -> {
statement.set("prefixes", new Gson().toJson(transformer.getPrefixes()));
});

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public boolean onCommand(Message message, String[] args) {
}

MessageFactory.makeSuccess(message, "<@%s> :id: of the <#%s> channel is `%s`",
message.getAuthor().getId(),
channel.getId(), channel.getId()
message.getAuthor().getId(),
channel.getId(), channel.getId()
).queue();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public boolean onCommand(Message message, String[] args) {
Role role = RoleUtil.getRoleFromMentionsOrName(message, args[0]);
if (role == null) {
MessageFactory.makeWarning(message, "<@%s> Invalid role, I couldn't find any role called **%s**",
message.getAuthor().getId(), args[0]
message.getAuthor().getId(), args[0]
).queue();
return false;
}

GuildTransformer transformer = GuildController.fetchGuild(orion, message);
if (!transformer.getSelfAssignableRoles().containsValue(role.getName().toLowerCase())) {
MessageFactory.makeWarning(message, "<@%s> Invalid role, **%s** is not a self-assignable role.",
message.getAuthor().getId(), args[0]
message.getAuthor().getId(), args[0]
).queue();
return false;
}
Expand All @@ -70,7 +70,7 @@ public boolean onCommand(Message message, String[] args) {
}

MessageFactory.makeSuccess(message, "<@%s> You now have the **%s** role!",
message.getAuthor().getId(), role.getName()
message.getAuthor().getId(), role.getName()
).queue();
return true;
}
Expand Down
Loading

0 comments on commit 2f48094

Please sign in to comment.