mirror of
https://github.com/opelly27/Sokobot.git
synced 2026-05-20 14:37:38 +00:00
Preparations for public host
This commit adds a lot of new features, optimizations and bugfixes to prepare the bot to be hosted publicly. Updates include a prefix changing command, fixes with box generation to prevent softlocks in later levels, and making edits to game messages instead of sending a new message after each update. Smaller optimizations were made as well, such as removing games from the HashMap when a user quits to save memory.
This commit is contained in:
+18
-2
@@ -2,22 +2,38 @@ import net.dv8tion.jda.api.AccountType;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.OnlineStatus;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Bot {
|
||||
static String prefix = "!";
|
||||
static HashMap<Guild, String> prefixes = new HashMap<Guild, String>();
|
||||
|
||||
public static void main(String[] args) throws LoginException, IOException {
|
||||
JDABuilder builder = new JDABuilder(AccountType.BOT);
|
||||
String token = new String(Files.readAllBytes(Paths.get("token.txt")));
|
||||
builder.setToken(token);
|
||||
builder.setStatus(OnlineStatus.ONLINE);
|
||||
builder.setActivity(Activity.playing("!play to play Sokoban!"));
|
||||
builder.setActivity(Activity.playing("@Sokobot for info!"));
|
||||
builder.addEventListeners(new Commands());
|
||||
builder.build();
|
||||
}
|
||||
|
||||
static void setPrefix(Guild guild, String prefix)
|
||||
{
|
||||
prefixes.put(guild, prefix);
|
||||
}
|
||||
|
||||
static String getPrefix(Guild guild)
|
||||
{
|
||||
if (!prefixes.containsKey(guild))
|
||||
{
|
||||
return "!";
|
||||
}
|
||||
return prefixes.get(guild);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user