This repository has been archived by the owner on Oct 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added botstats command, updated waframe alerts
- Loading branch information
zekroTJA
committed
Jul 5, 2017
1 parent
03e2f63
commit 4b0e399
Showing
6 changed files
with
157 additions
and
3 deletions.
There are no files selected for viewing
Binary file renamed
BIN
+22.9 MB
...ts/DiscordBot_jar/DiscordBot_1.31.0.1.jar → ...ts/DiscordBot_jar/DiscordBot_1.32.0.0.jar
Binary file not shown.
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,136 @@ | ||
package commands.etc; | ||
|
||
import com.moandjiezana.toml.TomlWriter; | ||
import commands.Command; | ||
import core.Main; | ||
import net.dv8tion.jda.core.EmbedBuilder; | ||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; | ||
import utils.STATICS; | ||
|
||
import java.awt.*; | ||
import java.io.*; | ||
import java.text.ParseException; | ||
|
||
/** | ||
* Created by zekro on 05.07.2017 / 20:53 | ||
* DiscordBot.commands.etc | ||
* dev.zekro.de - github.zekro.de | ||
* © zekro 2017 | ||
*/ | ||
|
||
|
||
public class BotStats implements Command { | ||
|
||
static File f = new File("botstatics.donotdelete"); | ||
|
||
public static long messagesProcessed = 0; | ||
public static long commandsExecuted = 0; | ||
|
||
private int membersDeserving = 0; | ||
|
||
public static void save() { | ||
|
||
if (!f.exists()) | ||
try { | ||
f.createNewFile(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
try { | ||
|
||
BufferedWriter bw = new BufferedWriter(new FileWriter(f)); | ||
bw.write(messagesProcessed + "\n" + commandsExecuted); | ||
bw.close(); | ||
|
||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
|
||
public static long[] stats() { | ||
|
||
if (!f.exists()) | ||
return new long[] {0, 0}; | ||
|
||
try { | ||
|
||
BufferedReader br = new BufferedReader(new FileReader(f)); | ||
return new long[] {Long.parseLong(br.readLine()), Long.parseLong(br.readLine())}; | ||
|
||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
return new long[] {0, 0}; | ||
} | ||
|
||
public static void load() { | ||
messagesProcessed = stats()[0]; | ||
commandsExecuted = stats()[1]; | ||
} | ||
|
||
private void countUpMembers() { | ||
membersDeserving++; | ||
} | ||
|
||
|
||
@Override | ||
public boolean called(String[] args, MessageReceivedEvent event) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void action(String[] args, MessageReceivedEvent event) throws ParseException, IOException { | ||
|
||
int commandsSize = Main.commands.size(); | ||
int serversRunning = event.getJDA().getGuilds().size(); | ||
|
||
event.getJDA().getGuilds().forEach(g -> g.getMembers().forEach(m -> countUpMembers())); | ||
|
||
event.getTextChannel().sendMessage( | ||
new EmbedBuilder() | ||
.setColor(Color.cyan) | ||
.setDescription( | ||
"**zekroBot STATS**\n\n" + | ||
"```\n" + | ||
"Registered commands: " + commandsSize + "\n" + | ||
"Running on servers: " + serversRunning + "\n" + | ||
"Deserving members: " + membersDeserving + "\n" + | ||
"Messages processed: " + messagesProcessed + "\n" + | ||
"Commands executed: " + commandsExecuted + "\n" + | ||
"```" | ||
).build() | ||
).queue(); | ||
|
||
membersDeserving = 0; | ||
|
||
} | ||
|
||
@Override | ||
public void executed(boolean success, MessageReceivedEvent event) { | ||
|
||
} | ||
|
||
@Override | ||
public String help() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String commandType() { | ||
return STATICS.CMDTYPE.etc; | ||
} | ||
|
||
@Override | ||
public int permission() { | ||
return 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
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