Git Product home page Git Product logo

blackoutburst / wally Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 4.0 40.93 MB

A Discord bot created for the game Hole in the Wall on Hypixel, contains multiple commands, custom user profile

Home Page: https://blackoutburst.com/wally.html

License: Do What The F*ck You Want To Public License

Kotlin 99.41% Java 0.59%
hypixel bot minecraft hypixel-api hypixel-stats-bot discord-bot java discord

wally's Introduction

splash

Language Release Size GitHub Workflow Status (branch) License

Wally

Wally is a discord bot that allow you to check your Hypixel Hole in the Wall stats, he contains much more features such as a score tracker, customizable user profile, leaderboards and much more!

Prerequsites

  • Kotlin 1.7.0 - Kotlin is necessary to run the bot since it's made with Kotlin
  • Java 8+ - Java is necessary to run the bot
  • A config file - see the config.json file and modify it to your needs
  • A Hypixel key - In order to get the data from Hypixel you need a key
  • A Discord bot - To send and receive messages via discord you need a bot and a token for that bot
  • A .env file To put confidential values such as API key or discord token

Building

Open a command line and go into the directory and run

gradlew buildDependents

Running

Locate the generated jar file should be inside repo/build/libs and run

java -jar Wally-x.x.x-all.jar

Contributing

See Contributing.md

wally's People

Contributors

blackoutburst avatar eatmyvenom avatar fubycutie avatar ld280905 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

wally's Issues

Manage club role

Require #62
Set user club roles upon linking them / inside the Hypixel stats tracker

Merge every readValue function

Take every rreadValue function form every file (Tracker.java, Stats.java, ...),

make a single readFile function inside core/Utils.java (Make it static and replace all duplicate function with the Utils.readFile())

Add user command display preferences

Allow linked user to select between Text/Embed/Canvas for certain commands such as stats commands

Create a new enum type in WallyUser DisplayPreference with the value TEXT, EMBED, CANVAS
Name the command setdisplaypreference

Search commands does not support player title and custom background

Describe the bug
When displaying player stats using !search their title and background does not display

To Reproduce
Steps to reproduce the behavior:

  1. use !search on any player with a custom title and/or background

Expected behavior
It should display everything like we used !stats on the player

Screenshots
Output
stats
Expected
stats

Wally mention displaying pb does not update player files

Describe the bug
Whe you @Wally in #personnal-best the player file does not get updated like the Tracker does

To Reproduce
Steps to reproduce the behavior:

  1. Make a new PB
  2. Ping Wally multiple time it will display multiple times your pb

Expected behavior
After displaying a pb on mention you need to update the player files to avoid displaying it multiple times

Gradle build script

Is your feature request related to a problem? Please describe.
Currently only IDEs can build and run the code for wally. This presents a challenge for non-ide users such as myself.

Describe the solution you'd like
A build.gradle so that there is universal support for whatever platform there is, this also allows for automatic dependency downloading via maven.

Describe alternatives you've considered
I could make a shell script by hand that does what I would like however this is a bit much for a shell script.

Create the stats command

Re implement the stats command using the Hypixel API

Below the message it should have a SelectMenu if the user is linked and have multiples accounts (like done with the skin command) to allow the user to switch between his account quickly using the select menu should not call the API again but instead use local data

The SelectMenu should also have one extra option call "Combined" or "Total" and once selected it will display the total stats for all the user accounts

If the API is down use local data if available if not then send an error message

Create the leaderboard manager

Create a leaderboard manager class using a singleton patern, it must contain everything needed to create quick leaderboard

Create multiple static list for each leaderboard and sort them before Wally login speed > ram is neccesary here

Fix code duplication

Fix this huge mess present in both link and add alt

        final String discordID = CommandUtils.getDiscordIDFromTwoArgs(guild, args);
        if (discordID == null) {
            message.reply(ConfigManager.getInstance().loadValue("replies", "not an user")).queue();
            return;
        }

        final String playerName = CommandUtils.getNonDiscordIDArgFromTwoArgs(guild, args);
        if (playerName == null) {
            message.reply(ConfigManager.getInstance().loadValue("replies", "could not get name")).queue();
            return;
        }

        final String playerUUID = Mojang.getPlayerUUID(playerName);
        if (playerUUID == null) {
            message.reply(ConfigManager.getInstance().loadValue("replies", "not in mojang").replace("%name%", playerName)).queue();
            return;
        }

        final String hypixelData = Hypixel.getPlayerStats(playerUUID);
        if (hypixelData == null) {
            message.reply(ConfigManager.getInstance().loadValue("replies", "not in hypixel").replace("%name%", playerName)).queue();
            return;
        }

        String practiceData = PracticeServer.getPlayerStats(playerUUID);
        if (practiceData == null) {
            channel.sendMessage(ConfigManager.getInstance().loadValue("replies", "could not load practice data").replace("%name%", playerName)).queue();
            practiceData = "";
        }

        final UserOption wallyProfile = new UserOption(PermissionLevel.MEMBER, playerUUID, guild.getId());

        if (!DatabaseManager.getInstance().createUserData(discordID, playerUUID, hypixelData, practiceData, wallyProfile)) {
            MessageUtils.sendLogButtonReply(commandSender, message, ConfigManager.getInstance().loadValue("replies", "link error"));
            return;
        }

Create a generic Canvas system

Like the previous Wally some commands will use a canvas format to display information therefor we need some basic canvas utility system for furture canvas

Add the leaderboard command

Require #48

Unlike previous Wally version the leaderboard command should only take 1 args, the page index (if no args proivded default is page 1 aka top 10)

After the message add a SelectMenu to switch between different leaderboard type (for both Hypixel and Practice server data)

Whois command

Display many player informations (only available in Embed format)
Information such as global Hypixel information, combined HitW stats for both Hypixel and Practice, alts acount and much more

Big background image cause error when creating a canvas with them

Describe the bug
Adding a huge background create a crash when trying to create a canvas with it

To Reproduce
Steps to reproduce the behavior:

  1. Use !setbackground to set a big image
  2. Use !stats or any commands generating canvas and it should crash

Expected behavior
This should work normally and display the image instead of a black image
We can either compress the image when saving it or just limit the file size when using !setbackground

Error message

javax.imageio.IIOException: Error reading PNG image data
        at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1345)
        at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1614)
        at javax.imageio.ImageIO.read(ImageIO.java:1448)
        at javax.imageio.ImageIO.read(ImageIO.java:1308)
        at utils.Canvas.drawCustomBackground(Canvas.java:130)
        at commands.CommandStats.execute(CommandStats.java:44)
        at core.CommandExecutable.run(CommandExecutable.java:32)
        at commands.CommandManager.<init>(CommandManager.java:14)
        at event.MessageReceived.run(MessageReceived.java:35)
        at core.Bot.onMessageReceived(Bot.java:66)
        at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:428)
        at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96)
        at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:82)
        at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:69)
        at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:152)
        at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:122)
        at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
        at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:954)
        at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:841)
        at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:819)
        at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:992)
        at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
        at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
        at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
        at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
        at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
        at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
        at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
        at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
        at java.io.DataInputStream.readFully(DataInputStream.java:195)
        at com.sun.imageio.plugins.png.PNGImageReader.decodePass(PNGImageReader.java:1119)
        at com.sun.imageio.plugins.png.PNGImageReader.decodeImage(PNGImageReader.java:1223)
        at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1338)```

Implement the stats tracker

Re implement the stat tracker in a different thread checking user stats using the Hypixel API and display in a specific channel (see the config file) a new embed message if the user beat is personal score

Create the stats Canvas

Require #53

Create the stats canvas for the command stat, customisation will come later, create a generic one for now

Re adding the !profile commands

The profile commands used to show player Hypixel level and AP but the plancke.io generator was really unstable and was not working on some linux device for some reason. So for this reason the commands got disabled

The goal is to bring back this commands without using the plancke.io generator and maybe add more Player information such as karma.

The command should follow the standard like !stats and !compare, meaning a canvas 600x400 suporting user custom background/title and so on

help command

Create a help command with a main help menu displaying the sub menu in embed messages like

  • help Hypixel
  • help practice
  • help misc
  • help staff
  • help admin

Help staff and admin only display if the user does have the required permission

Manage gender role

Require #62
The gender role are affiliated to a specific message, this message ID can be found in the config files for this one it's better to replicated the old code or at least extract the correct reaction from it

!convert F display wrong F value

image

This is only a visual problem since conversion is correct, this show the F value after conversion instead of the original input.

Just need to change the return message to display original F value instead of the converted one

Using !unlink IGN on a non linked player cause error

Describe the bug
Trying to unlink a non linked player with his IGN create an error
It does work using discord ID only IGN is broken

To Reproduce
Steps to reproduce the behavior:

  1. use !unlink IGN on a non linked player

Expected behavior
It should show the normal output message Impossible to find corresponding user like it does by using !unlink discordID

Error Message

java.lang.NullPointerException
        at utils.Utils.unlinkMember(Utils.java:295)
        at commands.CommandUnlink.execute(CommandUnlink.java:23)
        at core.CommandExecutable.run(CommandExecutable.java:26)
        at commands.CommandManager.<init>(CommandManager.java:23)
        at event.MessageReceived.run(MessageReceived.java:35)
        at core.Bot.onMessageReceived(Bot.java:66)
        at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:428)
        at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96)
        at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:82)
        at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:69)
        at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:152)
        at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:122)
        at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
        at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:954)
        at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:841)
        at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:819)
        at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:992)
        at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
        at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
        at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
        at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
        at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
        at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
        at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

Send typing events as it handles requests.

Is your feature request related to a problem? Please describe.
sometimes when I send a request, it takes a small while and I am not sure if I misentered a command.

Describe the solution you'd like
If it shows that it's typing as it handles requests this will provide visual feedback.

Describe alternatives you've considered
waiting or rereading my commands each time, therefore this isn't needed but would be nice

Line.java should be an enum

Line.java file make the same role as an enum but it's not an enum. Replace everything and every use of it with an enum to make the code better

Add the suggest command

Re implement the suggest command but with reaction below it like the command poll do, this way it's better to know what people really want first

Create the leaderboard canvas

Must be done after this one #50 and #49
Create the leaderboard canvas and the assets that goes with it then apply this new canvas to the leaderboard command

!link crash Tracker thread

Describe the bug
Linking new user crash the tracker thread due to missing file ?

To Reproduce
Steps to reproduce the behavior:

  1. link someone using !link

Expected behavior
Should not crash the tracker

Error Message

java.nio.file.NoSuchFileException: linked player/5e5ae6cb30fc43b5bccc3a565f14da19/data.json
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
        at java.nio.file.Files.newByteChannel(Files.java:361)
        at java.nio.file.Files.newByteChannel(Files.java:407)
        at java.nio.file.Files.readAllBytes(Files.java:3152)
        at utils.GeneralUtils.readJsonToString(GeneralUtils.java:221)
        at core.Tracker.checkUsers(Tracker.java:44)
        at core.Tracker.access$0(Tracker.java:31)
        at core.Tracker$1.run(Tracker.java:19)
        at java.lang.Thread.run(Thread.java:748)
Exception in thread "Tracker" java.lang.NullPointerException
        at java.io.StringReader.<init>(StringReader.java:50)
        at org.json.JSONTokener.<init>(JSONTokener.java:94)
        at org.json.JSONObject.<init>(JSONObject.java:406)
        at utils.Stats.getDiscordId(Stats.java:17)
        at core.Tracker.checkUsers(Tracker.java:45)
        at core.Tracker.access$0(Tracker.java:31)
        at core.Tracker$1.run(Tracker.java:19)
        at java.lang.Thread.run(Thread.java:748)

User not inside leaderboard display rank 10 000 on every stats

Describe the bug
When using !stats on a player not inside the leaderboard it display rank 10 000 for all their stats

To Reproduce
Steps to reproduce the behavior:

  1. use !stats on someone not inside the leaderboard

Expected behavior
This should not display ranks after the stats like it used to be

Screenshots
stats

!link commands argument order can cause incorrect user link

Describe the bug
When using the !link commands most of the time we use !link discordID IGN
but if we use !link IGN discordID it save the IGN as a discordID inside the player data file and create a broken link the you have to remove and re do correctly

To Reproduce
Steps to reproduce the behavior:

  1. link a player using his IGN first then his discord ID

Expected behavior
Argument order should not be an issue and both !link discordID IGN and !link IGN discordID should work the same way

Screenshots
Capture
This should be his discordID not his IGN

Reworking the help message formating

For now the !help message formatting use a regular code integration on discord with the yaml syntaxe, while this actually does the job for now it would be better to have a cleaner version of this message since code syntaxe does not work on mobile device making the help message looking really bad.

It would be cool to actually make something cleaner and working properly on mobile device.

Main solution would be using embeded message or creating a canvas as long as it look better it's fine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.