-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.7.1 Info Channels now with more customisation.
+ added special messages to the Role command when you enter your arguments wrong. + added more checks to the Pixel system * Fixed a bug in which a user profile wouldn't get created until your first gain of pixels. * Reverted a change of name for the slashCommands command. * updated help and info commands to only show information (such as channels and commands) relevant to the user. + editInfoFiles command, this command allows you to modify all of the files needed to use the Updateinfo command properly * fixed a bug with updateinfo where it wouldn't error properly if the ID of the user was incorrect * fixed a bug that would cause using the admin edits for ccs to have weird behaviour. + added RandomStatuses to the Config.Json File. you can now set statuses that will update every 5 mins. this means that it is now fully customisable and not hardcoded. * Further work has been done on the XP system, decay base code has been added. - unused toggle setting "LoginMessage" was removed.
- Loading branch information
1 parent
5c0697f
commit 960b395
Showing
38 changed files
with
6,316 additions
and
672 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
...thub_austinv11_Discord4j_shaded_2_8_1.xml → ...thub_austinv11_Discord4j_shaded_2_8_3.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package Commands.Admin; | ||
|
||
import Commands.CommandObject; | ||
import Commands.Help.Info; | ||
import Interfaces.Command; | ||
import Main.Constants; | ||
import Main.Utility; | ||
import Objects.SplitFirstObject; | ||
import sx.blah.discord.handle.obj.Permissions; | ||
|
||
/** | ||
* Created by Vaerys on 26/06/2017. | ||
*/ | ||
public class EditInfoFiles implements Command { | ||
@Override | ||
public String execute(String args, CommandObject command) { | ||
SplitFirstObject object = new SplitFirstObject(args); | ||
switch (object.getFirstWord().toLowerCase()) { | ||
case "uploadimage": | ||
return InfoEditModes.uploadFile(command.message); | ||
case "removeimage": | ||
return InfoEditModes.removeFile(object.getRest(), command.message); | ||
case "listimages": | ||
return InfoEditModes.listFiles(command.message); | ||
case "listfiles": | ||
return InfoEditModes.listFiles(command.message); | ||
case "uploadinfo": | ||
return InfoEditModes.uploadInfo(command.message); | ||
case "getinfofile": { | ||
return InfoEditModes.getInfoFile(command.message); | ||
} | ||
default: | ||
return "Invalid Edit Mode.\n" + Utility.getCommandInfo(this, command); | ||
} | ||
} | ||
|
||
@Override | ||
public String[] names() { | ||
return new String[]{"EditInfoFiles", "UpdateInfoFiles"}; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Allows for editing of the updateInfo command.\n" + | ||
"**Modes:**\n" + | ||
"- uploadImage: **Requires image file.**\n" + | ||
"- removeImage: **Requires file name.**\n" + | ||
"- listFiles/listImages\n" + | ||
"- uploadInfo: **Requires \"" + Constants.FILE_INFO + "\" file.**\n" + | ||
"- getInfoFile"; | ||
} | ||
|
||
@Override | ||
public String usage() { | ||
return "[EditMode] (ImageFile/ImageName/Info.txt)"; | ||
} | ||
|
||
@Override | ||
public String type() { | ||
return TYPE_ADMIN; | ||
} | ||
|
||
@Override | ||
public String channel() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Permissions[] perms() { | ||
return new UpdateInfo().perms(); | ||
} | ||
|
||
@Override | ||
public boolean requiresArgs() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean doAdminLogging() { | ||
return true; | ||
} | ||
|
||
@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]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package Commands.Admin; | ||
|
||
import Main.Constants; | ||
import Main.Globals; | ||
import Main.Utility; | ||
import Objects.XEmbedBuilder; | ||
import sx.blah.discord.handle.obj.IMessage; | ||
|
||
import java.awt.*; | ||
import java.io.*; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.nio.file.CopyOption; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by Vaerys on 26/06/2017. | ||
*/ | ||
public class InfoEditModes { | ||
|
||
public static String uploadFile(IMessage message) { | ||
if (message.getAttachments() == null || message.getAttachments().size() == 0) { | ||
return "> No file to upload found."; | ||
} else { | ||
try { | ||
IMessage.Attachment attachment = message.getAttachments().get(0); | ||
File file = new File(Utility.getGuildImageDir(message.getGuild().getStringID()) + attachment.getFilename()); | ||
File imagDir = new File(Utility.getGuildImageDir(message.getGuild().getStringID())); | ||
File[] imageList = imagDir.listFiles(); | ||
|
||
if (!Utility.isImageLink(attachment.getFilename())) { | ||
return "> Cannot upload File. File type is invalid."; | ||
} | ||
|
||
//grab file | ||
final HttpURLConnection connection = (HttpURLConnection) new URL(attachment.getUrl()).openConnection(); | ||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) " + "AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31"); | ||
InputStream stream = connection.getInputStream(); | ||
|
||
//save or update file | ||
if (file.exists()) { | ||
file.delete(); | ||
Files.copy(stream, Paths.get(file.getPath())); | ||
return "> File **" + attachment.getFilename() + "** updated"; | ||
} else { | ||
if (imageList.length >= 25) { | ||
return "> Max images already reached, you will need to remove an old image to upload a new one."; | ||
} else { | ||
Files.copy(stream, Paths.get(file.getPath())); | ||
return "> File **" + attachment.getFilename() + "** uploaded"; | ||
} | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return "> An error occurred trying to upload your file."; | ||
} | ||
} | ||
} | ||
|
||
public static String removeFile(String rest, IMessage message) { | ||
File imagDir = new File(Utility.getGuildImageDir(message.getGuild().getStringID())); | ||
File[] imageList = imagDir.listFiles(); | ||
for (File f : imageList) { | ||
if (f.getName().equalsIgnoreCase(rest)) { | ||
f.delete(); | ||
return "> File Removed."; | ||
} | ||
} | ||
return "> File Not Found."; | ||
} | ||
|
||
public static String listFiles(IMessage message) { | ||
//send Embed | ||
XEmbedBuilder builder = new XEmbedBuilder(); | ||
builder.withTitle("> Here are the files available to you:"); | ||
File imagDir = new File(Utility.getGuildImageDir(message.getGuild().getStringID())); | ||
File[] imageList = imagDir.listFiles(); | ||
ArrayList<String> fileNames = new ArrayList<>(); | ||
for (File f : imageList) { | ||
fileNames.add(f.getName()); | ||
} | ||
builder.withColor(Utility.getUsersColour(Globals.getClient().getOurUser(), message.getGuild())); | ||
builder.withDesc("```\n" + Utility.listFormatter(fileNames, true) + "```"); | ||
Utility.sendEmbedMessage("", builder, message.getChannel()); | ||
return null; | ||
} | ||
|
||
public static String uploadInfo(IMessage message) { | ||
if (message.getAttachments() == null || message.getAttachments().size() == 0) { | ||
return "> No file to upload found."; | ||
} else { | ||
try { | ||
IMessage.Attachment attachment = message.getAttachments().get(0); | ||
File file = new File(Utility.getFilePath(message.getGuild().getStringID(), Constants.FILE_INFO)); | ||
|
||
if (!attachment.getFilename().equals(Constants.FILE_INFO)) { | ||
return "> Cannot upload file, File name must be \"" + Constants.FILE_INFO + "\""; | ||
} | ||
|
||
//grab file | ||
final HttpURLConnection connection = (HttpURLConnection) new URL(attachment.getUrl()).openConnection(); | ||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) " + "AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31"); | ||
InputStream stream = connection.getInputStream(); | ||
|
||
//save or update file | ||
if (file.exists()) { | ||
file.delete(); | ||
Files.copy(stream, Paths.get(file.getPath())); | ||
return "> Updated **" + Constants.FILE_INFO + "** file."; | ||
} else { | ||
Files.copy(stream, Paths.get(file.getPath())); | ||
return "> New **" + Constants.FILE_INFO + "** file uploaded."; | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return "> An error occurred trying to upload your file."; | ||
} | ||
} | ||
} | ||
|
||
public static String getInfoFile(IMessage message) { | ||
String filePath = Utility.getFilePath(message.getGuild().getStringID(), Constants.FILE_INFO); | ||
File file = new File(filePath); | ||
if (file.exists()) { | ||
Utility.sendFile("> Here is your **"+Constants.FILE_INFO+ "** file.", file, message.getChannel()); | ||
} else { | ||
return "> Cannot send file, **" + Constants.FILE_INFO + "** file does not exist yet."; | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.