mirror of
https://github.com/Koala3353/rpg-discord-bot.git
synced 2024-11-23 20:43:40 +00:00
initial files
This commit is contained in:
parent
0bea4364c5
commit
96bb15fc48
12 changed files with 178 additions and 0 deletions
17
src/main/java/github/io/koala3353/Config.java
Normal file
17
src/main/java/github/io/koala3353/Config.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package github.io.koala3353;
|
||||
|
||||
import io.github.cdimascio.dotenv.Dotenv;
|
||||
|
||||
public class Config {
|
||||
// Simple Config getter (.env file)
|
||||
private static final Dotenv dotenv = Dotenv.load();
|
||||
|
||||
public static String get(String key) {
|
||||
return dotenv.get(key.toUpperCase());
|
||||
}
|
||||
public static long getLong(String key) {
|
||||
String config = dotenv.get(key.toUpperCase());
|
||||
if (config == null) return 0L;
|
||||
return Long.parseLong(config);
|
||||
}
|
||||
}
|
19
src/main/java/github/io/koala3353/Main.java
Normal file
19
src/main/java/github/io/koala3353/Main.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package github.io.koala3353;
|
||||
|
||||
import github.io.koala3353.bot.Bot;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Main {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
LOGGER.info("Starting program....");
|
||||
try {
|
||||
new Bot();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LOGGER.info("Program started successfully!");
|
||||
}
|
||||
}
|
57
src/main/java/github/io/koala3353/bot/Bot.java
Normal file
57
src/main/java/github/io/koala3353/bot/Bot.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package github.io.koala3353.bot;
|
||||
|
||||
import com.jagrosh.jdautilities.command.CommandClient;
|
||||
import com.jagrosh.jdautilities.command.CommandClientBuilder;
|
||||
import com.jagrosh.jdautilities.command.SlashCommand;
|
||||
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
|
||||
import github.io.koala3353.Config;
|
||||
import github.io.koala3353.bot.commands.AboutCommand;
|
||||
import github.io.koala3353.bot.commands.TradeCommand;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.OnlineStatus;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
import net.dv8tion.jda.api.utils.ChunkingFilter;
|
||||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Bot {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class);
|
||||
|
||||
public Bot() throws InterruptedException {
|
||||
// Initialize the waiter and client
|
||||
CommandClientBuilder client = new CommandClientBuilder();
|
||||
// Set the client settings
|
||||
client.setOwnerId(Config.get("owner_id"));
|
||||
client.setStatus(OnlineStatus.ONLINE);
|
||||
client.setActivity(Activity.listening("for loopholes"));
|
||||
addCommands(client);
|
||||
EventWaiter eventWaiter = new EventWaiter();
|
||||
// Finalize the command client
|
||||
CommandClient commandClient = client.build();
|
||||
|
||||
JDABuilder.createDefault(Config.get("token"),
|
||||
GatewayIntent.GUILD_MEMBERS,
|
||||
GatewayIntent.GUILD_MESSAGES,
|
||||
GatewayIntent.GUILD_MESSAGE_REACTIONS,
|
||||
GatewayIntent.DIRECT_MESSAGES,
|
||||
GatewayIntent.MESSAGE_CONTENT,
|
||||
GatewayIntent.GUILD_PRESENCES,
|
||||
GatewayIntent.GUILD_EMOJIS_AND_STICKERS,
|
||||
GatewayIntent.SCHEDULED_EVENTS,
|
||||
GatewayIntent.GUILD_VOICE_STATES)
|
||||
.addEventListeners(eventWaiter, commandClient)
|
||||
.setChunkingFilter(ChunkingFilter.ALL) // enable member chunking for all guilds
|
||||
.setMemberCachePolicy(MemberCachePolicy.ALL)
|
||||
.build().awaitReady();
|
||||
}
|
||||
private static void addCommands(CommandClientBuilder clientBuilder) {
|
||||
// Initialize the commands of the bot
|
||||
clientBuilder.addSlashCommands(new TradeCommand(), new AboutCommand());
|
||||
LOGGER.info("Added the slash commands");
|
||||
clientBuilder.addContextMenus();
|
||||
LOGGER.info("Added the context menus");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package github.io.koala3353.bot.commands;
|
||||
|
||||
import com.jagrosh.jdautilities.command.SlashCommand;
|
||||
import com.jagrosh.jdautilities.command.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class AboutCommand extends SlashCommand {
|
||||
public AboutCommand() {
|
||||
this.name = "about";
|
||||
this.help = "Get information about the bot";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(SlashCommandEvent event) {
|
||||
EmbedBuilder aboutEmbed = new EmbedBuilder();
|
||||
aboutEmbed.setTitle("About the bot");
|
||||
aboutEmbed.setDescription("This bot is a simple bot created by Koala3353");
|
||||
aboutEmbed.setColor(Color.decode("#2A2E75"));
|
||||
|
||||
event.reply("This bot is a simple bot created by Koala3353").queue();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package github.io.koala3353.bot.commands;
|
||||
|
||||
public class HelpCommand {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package github.io.koala3353.bot.commands;
|
||||
|
||||
public class ProfileCommand {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package github.io.koala3353.bot.commands;
|
||||
|
||||
public class ShopCommand {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package github.io.koala3353.bot.commands;
|
||||
|
||||
public class StartAdventureCommand {
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package github.io.koala3353.bot.commands;
|
||||
|
||||
import com.jagrosh.jdautilities.command.SlashCommand;
|
||||
import com.jagrosh.jdautilities.command.SlashCommandEvent;
|
||||
|
||||
public class TradeCommand extends SlashCommand {
|
||||
public TradeCommand() {
|
||||
this.name = "trade";
|
||||
this.help = "Trade with another player";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(SlashCommandEvent event) {
|
||||
event.reply("Trade command is not implemented yet!").queue();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package github.io.koala3353.bot.commands;
|
||||
|
||||
public class ViewInventoryCommand {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package github.io.koala3353.bot.events;
|
||||
|
||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
public class ButtonEvent extends ListenerAdapter {
|
||||
@Override
|
||||
public void onButtonInteraction(ButtonInteractionEvent event) {
|
||||
//code
|
||||
}
|
||||
}
|
14
src/main/resources/logback.xml
Normal file
14
src/main/resources/logback.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false">
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} %boldCyan(%-34.-34thread) %red(%10.10X{jda.shard}) %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
Loading…
Reference in a new issue