Skip to content

Commit

Permalink
2.6.3 - Art Pinning
Browse files Browse the repository at this point in the history
+ ArtPinning Module
+ AutoArtPinning Toggle (Requires ArtPinning to be true)
+ Art Channel
# ArtPinning allows users to attach a 📌reaction to an image post and
this will then pin the post saving up to the 25 most recent posts.
# AutoArtPinning means that any message sent to the art channel is
automatically pinned.
* fixed a bug preventing the shitpost channel warning from showing up.
* Status will now display "Recovered from Crash" if the autorecover
feature is activated for 30 mins and will then return to normal.
+ added total cc count to UserInfo command.
+ added tag <repError>{ReplaceWith}
  • Loading branch information
Vaerys-Dawn committed May 17, 2017
1 parent bf011d9 commit 228fe9a
Show file tree
Hide file tree
Showing 37 changed files with 896 additions and 544 deletions.
808 changes: 377 additions & 431 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.vaerys</groupId>
<artifactId>DiscordSAIL</artifactId>
<version>2.6.1</version>
<version>2.6.3</version>
<build>
<resources>
<resource>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.vaerys</groupId>
<artifactId>DiscordSAIL</artifactId>
<version>2.6.2</version>
<version>2.6.3</version>

<build>
<resources>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ChannelSettings/InitChannels.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static ArrayList<ChannelSetting> get() {
channelSettings.add(new Admin());
channelSettings.add(new AdminLog());
channelSettings.add(new ServerLog());
channelSettings.add(new Art());

//Channel Settings
channelSettings.add(new Shitpost());
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/ChannelSettings/Types/Art.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ChannelSettings.Types;

import Interfaces.ChannelSetting;
import Interfaces.Command;

/**
* Created by Vaerys on 12/05/2017.
*/
public class Art implements ChannelSetting {
@Override
public String type() {
return Command.CHANNEL_ART;
}

@Override
public boolean isSetting() {
return false;
}
}
79 changes: 79 additions & 0 deletions src/main/java/Commands/Admin/RewardRole.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package Commands.Admin;

import Commands.CommandObject;
import Interfaces.Command;
import Main.Constants;
import Main.Utility;
import Objects.SplitFirstObject;
import sx.blah.discord.handle.obj.Permissions;

/**
* Created by Vaerys on 11/05/2017.
*/
public class RewardRole implements Command{
@Override
public String execute(String args, CommandObject command) {
SplitFirstObject split = new SplitFirstObject(args);
return "in Development.";
}

@Override
public String[] names() {
return new String[]{"RewardRole"};
}

@Override
public String description() {
return "Adds or removes a reward role.";
}

@Override
public String usage() {
return "[Level] [RoleName] **or** [RoleName] **to remove.**" + spacer;
}

@Override
public String type() {
return TYPE_ADMIN;
}

@Override
public String channel() {
return null;
}

@Override
public Permissions[] perms() {
return new Permissions[0];
}

@Override
public boolean requiresArgs() {
return false;
}

@Override
public boolean doAdminLogging() {
return false;
}

@Override
public String dualDescription() {
return null;
}

@Override
public String dualUsage() {
return null;
}

@Override
public String dualType() {
return null;
}

@Override
public Permissions[] dualPerms() {
return new Permissions[0];
}
}
2 changes: 1 addition & 1 deletion src/main/java/Commands/CC/EditCC.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public String[] names() {
@Override
public String description() {
return "Allows you to edit a custom command.\n" +
"Modes: Replace, Append, toEmbed,DelCall\n" +
" Modes: Replace, Append, toEmbed, DelCall.\n" +
"**Admin Modes: **lock, Shitpost\n\n" +
"Mode is optional, defaults to replace.\n" +
"[Custom Command Guide](https://github.com/Vaerys-Dawn/DiscordSailv2/wiki/Custom-Command-Guide)";
Expand Down
1 change: 1 addition & 0 deletions src/main/java/Commands/CommandInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static ArrayList<Command> get() {
commands.add(new MaxMessages());
commands.add(new Module());
commands.add(new Mute());
// commands.add(new RewardRole());
commands.add(new SetAdminRole());
commands.add(new SetMutedRole());
commands.add(new SetTrustedRoles());
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/Commands/CommandObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class CommandObject {
public Servers servers;
public Competition competition;
public GuildUsers guildUsers;
public ChannelData channelData;

public ArrayList<Command> commands = new ArrayList<>();
public ArrayList<DMCommand> dmCommands = new ArrayList<>();
Expand All @@ -63,7 +64,6 @@ public class CommandObject {
final static Logger logger = LoggerFactory.getLogger(CommandObject.class);



public CommandObject(IMessage message) {
this.message = message;
guild = message.getGuild();
Expand All @@ -85,8 +85,8 @@ public CommandObject(DMCommandObject command) {
this.message = command.message;
this.channel = command.channel;
this.author = command.author;
for (IGuild g: command.client.getGuilds()){
if (g.getUsers().contains(command.author)){
for (IGuild g : command.client.getGuilds()) {
if (g.getUsers().contains(command.author)) {
this.guild = g;
}
}
Expand All @@ -99,7 +99,7 @@ private void init() {
guildSID = guild.getStringID();
channelSID = channel.getStringID();
authorSID = author.getStringID();
messageID = author.getLongID();
messageID = message.getLongID();
guildID = guild.getLongID();
channelID = channel.getLongID();
authorID = author.getLongID();
Expand All @@ -115,11 +115,11 @@ private void init() {
servers = guildContent.getServers();
competition = guildContent.getCompetition();
guildUsers = guildContent.getGuildUsers();
channelData = guildContent.getChannelData();
client = Globals.getClient();

commands = (ArrayList<Command>) Globals.getCommands().clone();
commandTypes = (ArrayList<String>) Globals.getCommandTypes().clone();
// channelTypes = (ArrayList<String>) Globals.getChannelTypes().clone();
channelSettings = (ArrayList<ChannelSetting>) Globals.getChannelSettings().clone();
guildToggles = (ArrayList<GuildToggle>) Globals.getGuildGuildToggles().clone();

Expand All @@ -134,9 +134,6 @@ private void init() {
for (GuildToggle g : guildToggles) {
testToggles += g.name() + ", ";
}
if (testToggles.contains(new ModuleServers().name())) {
logger.debug("Module Servers found.");
}
for (int i = 0; i < guildToggles.size(); i++) {
if (!guildToggles.get(i).get(guildConfig)) {
if (guildToggles.get(i).isModule()) {
Expand All @@ -148,7 +145,7 @@ private void init() {
//well this works I guess.
for (GuildToggle t : toRemove) {
for (int i = 0; i < guildToggles.size(); i++) {
if (t.name().equalsIgnoreCase(guildToggles.get(i).name())){
if (t.name().equalsIgnoreCase(guildToggles.get(i).name())) {
guildToggles.remove(i);
}
}
Expand All @@ -166,22 +163,24 @@ private void validate() throws IllegalStateException {
if (author == null) throw new IllegalStateException("author can't be null");
}

public void setAuthor(IUser author) {
public CommandObject setAuthor(IUser author) {
this.author = author;
authorSID = author.getStringID();
authorUserName = author.getName() + "#" + author.getDiscriminator();
authorDisplayName = author.getDisplayName(guild);
authorColour = Utility.getUsersColour(author, guild);
authorRoles = author.getRolesForGuild(guild);
notAllowed = "> I'm sorry " + author.getDisplayName(guild) + ", I'm afraid I can't let you do that.";
return this;
}

public void setChannel(IChannel channel) {
public CommandObject setChannel(IChannel channel) {
this.channel = channel;
channelSID = channel.getStringID();
return this;
}

public void setGuild(IGuild guild) {
public CommandObject setGuild(IGuild guild) {
this.guild = guild;
guildSID = guild.getStringID();
GuildContentObject contentObject = Globals.getGuildContent(guildSID);
Expand All @@ -196,11 +195,13 @@ public void setGuild(IGuild guild) {
authorDisplayName = author.getDisplayName(guild);
notAllowed = "> I'm sorry " + author.getDisplayName(guild) + ", I'm afraid I can't let you do that.";
}
return this;
}

public void setMessage(IMessage message) {
public CommandObject setMessage(IMessage message) {
this.message = message;
messageSID = message.getStringID();
return this;
}

public void removeCommandsByType(String type) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/Commands/Creator/GetMessageData.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public String execute(String args, CommandObject command) {
topUser = user.getID();
}
totalMessage += user.getXP();
totalMessageAvg += user.getXP() / (user.getLevel() + 1);
totalAvg += user.getXP() / (user.getLevel() + 1);
totalGlobalUsers++;
totalUsers++;
}
Expand Down
35 changes: 28 additions & 7 deletions src/main/java/Commands/General/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import Interfaces.Command;
import Main.Utility;
import Objects.ChannelSettingObject;
import Objects.ChannelTypeObject;
import sx.blah.discord.api.internal.json.objects.WebhookObject;
import sx.blah.discord.handle.impl.obj.Webhook;
import sx.blah.discord.handle.impl.events.guild.channel.message.MessagePinEvent;
import sx.blah.discord.handle.obj.IMessage;
import sx.blah.discord.handle.obj.Permissions;

Expand All @@ -17,11 +15,34 @@ public class Test implements Command {

@Override
public String execute(String args, CommandObject command) {
String channels = "Channel Settings: \n";
for (ChannelSettingObject c : command.guildConfig.getChannelSettings()) {
channels += c.getType() + ": " + Utility.listFormatter(c.mentionChannelIDs(), true) + "\n";
try {
long msgId = Long.parseUnsignedLong(args);
IMessage message = command.client.getMessageByID(msgId);
if (message != null) {
System.out.println("Embeds: " + message.getEmbeds().size());
System.out.println("Attachments: " + message.getAttachments().size());
System.out.println("Channels: " + message.getChannelMentions().size());
System.out.println("Mentions: " + message.getMentions().size());
System.out.println("RoleMentions: " + message.getRoleMentions().size());
System.out.println("Reactions: " + message.getReactions().size());
System.out.println("Charactes: " + message.getContent().length());
System.out.println("Words: " + message.getContent().split(" ").length);
System.out.println("Content: " + message.getContent());
System.out.println("Formatted Content: " + message.getFormattedContent());
// message.getChannel().pin(message);
// command.client.getDispatcher().dispatch(new MessagePinEvent(message));
// message.delete();
return "> you sent Erin some data :P";
}else {
return "> Nothing interesting happens.";
}
} catch (NumberFormatException e) {
String channels = "Channel Settings: \n";
for (ChannelSettingObject c : command.guildConfig.getChannelSettings()) {
channels += c.getType() + ": " + Utility.listFormatter(c.mentionChannelIDs(), true) + "\n";
}
return channels;
}
return channels;
}

@Override
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/Commands/General/UserInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Main.Utility;
import Objects.UserTypeObject;
import Objects.XEmbedBuilder;
import POGOs.CustomCommands;
import sx.blah.discord.handle.obj.IRole;
import sx.blah.discord.handle.obj.IUser;
import sx.blah.discord.handle.obj.Permissions;
Expand All @@ -22,7 +23,7 @@ public class UserInfo implements Command {
@Override
public String execute(String args, CommandObject command) {
IUser user = command.author;
if (command.message.getMentions().size() > 0){
if (command.message.getMentions().size() > 0) {
user = command.message.getMentions().get(0);
}
for (UserTypeObject u : command.guildUsers.getUsers()) {
Expand All @@ -48,15 +49,16 @@ public String execute(String args, CommandObject command) {


//sets sidebar colour
builder.withColor(Utility.getUsersColour(user,command.guild));
builder.withColor(Utility.getUsersColour(user, command.guild));

//collect role names;
roleNames.addAll(roles.stream().filter(role -> !role.isEveryoneRole()).map(IRole::getName).collect(Collectors.toList()));

//builds desc
builder.withDesc("Account Created: " + Utility.formatTimeDifference(difference) +
"\nGender: " + u.getGender() +
"\nRoles : " + Utility.listFormatter(roleNames, true) +
builder.withDesc("**Account Created: **" + Utility.formatTimeDifference(difference) +
"\n**Gender: **" + u.getGender() +
"\n**Custom Commands: **" + command.customCommands.getUserCommandCount(user, command.guild, command.guildConfig) +
"\n**Roles: **" + Utility.listFormatter(roleNames, true) +
"\n\n*" + u.getQuote() + "*");

// TODO: 27/02/2017 when xp system is implemented put xp and rank on the user card.
Expand All @@ -69,16 +71,16 @@ public String execute(String args, CommandObject command) {
return null;
}
}
if (user.isBot()){
if (user.isBot()) {
command.guildUsers.addUser(user.getStringID());
return execute(args,command);
return execute(args, command);
}
return "> Unfortunately that user doesn't seem to have a user info right now.";
}

@Override
public String[] names() {
return new String[]{"UserInfo","Me"};
return new String[]{"UserInfo", "Me"};
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Commands/Help/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String execute(String args, CommandObject command) {
String title = "ERROR";
String suffix = Utility.getCommandInfo(new Info(), command);
for (String s : types) {
if (args.equalsIgnoreCase(s)) {
if (args.equalsIgnoreCase(s) || args.equalsIgnoreCase(command.guildConfig.getPrefixCommand() + s)) {
title = "> Here are all of the " + s + " Commands I have available.";
isFound = true;
if (s.equalsIgnoreCase(TYPE_DM)) {
Expand Down
Loading

0 comments on commit 228fe9a

Please sign in to comment.