Modules!
This commit is contained in:
parent
716c6c139b
commit
41c1d28bcc
8
.idea/inspectionProfiles/Project_Default.xml
Normal file
8
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.net.URLClassLoader,newInstance" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
@ -7,9 +7,4 @@
|
|||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
<component name="SwUserDefinedSpecifications">
|
|
||||||
<option name="specTypeByUrl">
|
|
||||||
<map />
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
</project>
|
26
build.gradle
26
build.gradle
@ -1,13 +1,14 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'application'
|
id 'application'
|
||||||
|
id 'maven-publish'
|
||||||
id 'com.github.johnrengelman.shadow' version '5.2.0'
|
id 'com.github.johnrengelman.shadow' version '5.2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
mainClassName = 'net.nevet5gi.buzzbot.Bot'
|
mainClassName = 'net.nevet5gi.buzzbot.Bot'
|
||||||
|
|
||||||
group 'net.nevet5gi'
|
group 'net.nevet5gi'
|
||||||
version '0.4.1'
|
version '0.5.0'
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
@ -36,4 +37,25 @@ dependencies {
|
|||||||
//implementation 'com.github.Kaktushose:jda-commands:v.2.2.0'
|
//implementation 'com.github.Kaktushose:jda-commands:v.2.2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
publishing {
|
||||||
|
publications{
|
||||||
|
publish(MavenPublication) {
|
||||||
|
artifact("nexus/BuzzBot-$version" + ".jar") {
|
||||||
|
extension 'jar'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name 'nexus'
|
||||||
|
url "https://repo.nevets.tech/repository/maven-releases/"
|
||||||
|
credentials {
|
||||||
|
username System.getenv('nexusUser')
|
||||||
|
password System.getenv('nexusPass')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,32 +3,56 @@ package net.nevet5gi.buzzbot;
|
|||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
import net.dv8tion.jda.api.entities.Activity;
|
import net.dv8tion.jda.api.entities.Activity;
|
||||||
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||||
import net.nevet5gi.buzzbot.commands.utils.CommandManager;
|
import net.nevet5gi.buzzbot.commands.utils.CommandManager;
|
||||||
|
import net.nevet5gi.buzzbot.modules.BuzzyModule;
|
||||||
|
import net.nevet5gi.buzzbot.modules.ModuleLoader;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class Bot {
|
public class Bot {
|
||||||
|
//TODO Make shutdown sequence
|
||||||
public static JDA jda;
|
public static JDA jda;
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Bot.class);
|
||||||
|
public static final ArrayList<ListenerAdapter> PLUGINS = new ArrayList<>();
|
||||||
|
private static ArrayList<BuzzyModule> modules;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
|
try {
|
||||||
|
modules = ModuleLoader.loadModules();
|
||||||
|
} catch (IOException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||||
|
System.out.println("Have fun with this stack trace ;)");
|
||||||
|
e.printStackTrace();
|
||||||
|
modules = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
jda = JDABuilder.createDefault(Config.getConfig().getString("bot.token"))
|
JDABuilder builder = JDABuilder.createDefault(Config.getConfig().getString("bot.token"))
|
||||||
.disableCache(EnumSet.of(
|
.disableCache(EnumSet.of(
|
||||||
CacheFlag.CLIENT_STATUS,
|
CacheFlag.CLIENT_STATUS,
|
||||||
CacheFlag.ACTIVITY,
|
CacheFlag.ACTIVITY,
|
||||||
CacheFlag.EMOTE
|
CacheFlag.EMOTE
|
||||||
))
|
))
|
||||||
.enableCache(CacheFlag.VOICE_STATE)
|
.enableCache(CacheFlag.VOICE_STATE);
|
||||||
.addEventListeners(new Listener())
|
|
||||||
.build();
|
for (ListenerAdapter listener : PLUGINS) {
|
||||||
|
builder.addEventListeners(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
jda = builder.build();
|
||||||
|
|
||||||
CommandManager.registerSlashCommands();
|
CommandManager.registerSlashCommands();
|
||||||
|
for (BuzzyModule module : modules) {
|
||||||
|
module.onEnable(jda);
|
||||||
|
}
|
||||||
getActivity();
|
getActivity();
|
||||||
LOGGER.info("BuzzBot finished loading!");
|
LOGGER.info("BuzzBot finished loading!");
|
||||||
} catch (LoginException e) {
|
} catch (LoginException e) {
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package net.nevet5gi.buzzbot;
|
|
||||||
|
|
||||||
public class Group {
|
|
||||||
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ package net.nevet5gi.buzzbot;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
import net.dv8tion.jda.api.events.ReadyEvent;
|
import net.dv8tion.jda.api.events.ReadyEvent;
|
||||||
|
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageUpdateEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageUpdateEvent;
|
||||||
@ -9,6 +10,7 @@ import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
|||||||
import net.nevet5gi.buzzbot.commands.utils.CommandManager;
|
import net.nevet5gi.buzzbot.commands.utils.CommandManager;
|
||||||
import net.nevet5gi.buzzbot.database.SqlDB;
|
import net.nevet5gi.buzzbot.database.SqlDB;
|
||||||
import net.nevet5gi.buzzbot.functions.ProfanityFilter;
|
import net.nevet5gi.buzzbot.functions.ProfanityFilter;
|
||||||
|
import net.nevet5gi.buzzbot.objects.GuildData;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -29,6 +31,19 @@ public class Listener extends ListenerAdapter {
|
|||||||
LOGGER.info("BuzzBot is ready: " + event.getJDA().getSelfUser().getAsTag());
|
LOGGER.info("BuzzBot is ready: " + event.getJDA().getSelfUser().getAsTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuildJoin(@Nonnull GuildJoinEvent event) {
|
||||||
|
GuildData guild = new GuildData();
|
||||||
|
guild.setName(event.getGuild().getName());
|
||||||
|
guild.setId(event.getGuild().getIdLong());
|
||||||
|
guild.setGroup("master");
|
||||||
|
guild.setProfanityLevel(0);
|
||||||
|
|
||||||
|
SqlDB sql = new SqlDB();
|
||||||
|
sql.addGuild(guild);
|
||||||
|
sql.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMessageReceived(@Nonnull GuildMessageReceivedEvent event) {
|
public void onGuildMessageReceived(@Nonnull GuildMessageReceivedEvent event) {
|
||||||
User user = event.getAuthor();
|
User user = event.getAuthor();
|
||||||
@ -41,17 +56,16 @@ public class Listener extends ListenerAdapter {
|
|||||||
if (profanityFilter.containsProfanity(raw, "strong")) {
|
if (profanityFilter.containsProfanity(raw, "strong")) {
|
||||||
SqlDB sql = new SqlDB();
|
SqlDB sql = new SqlDB();
|
||||||
int profanityLevel = sql.getGuildData(event.getGuild().getIdLong()).getProfanityLevel();
|
int profanityLevel = sql.getGuildData(event.getGuild().getIdLong()).getProfanityLevel();
|
||||||
|
sql.close();
|
||||||
|
|
||||||
switch (profanityLevel) {
|
switch (profanityLevel) {
|
||||||
case 1:
|
case 1 -> {
|
||||||
if (profanityFilter.containsProfanity(raw, "mild")) profanityFilter.handle(event);
|
if (profanityFilter.containsProfanity(raw, "mild")) profanityFilter.handle(event);
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> {
|
||||||
if (profanityFilter.containsProfanity(raw, "moderate")) profanityFilter.handle(event);
|
if (profanityFilter.containsProfanity(raw, "moderate")) profanityFilter.handle(event);
|
||||||
break;
|
}
|
||||||
case 3:
|
case 3 -> profanityFilter.handle(event);
|
||||||
profanityFilter.handle(event);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +81,7 @@ public class Listener extends ListenerAdapter {
|
|||||||
if (profanityFilter.containsProfanity(raw, "strong")) {
|
if (profanityFilter.containsProfanity(raw, "strong")) {
|
||||||
SqlDB sql = new SqlDB();
|
SqlDB sql = new SqlDB();
|
||||||
int profanityLevel = sql.getGuildData(event.getGuild().getIdLong()).getProfanityLevel();
|
int profanityLevel = sql.getGuildData(event.getGuild().getIdLong()).getProfanityLevel();
|
||||||
|
sql.close();
|
||||||
|
|
||||||
switch (profanityLevel) {
|
switch (profanityLevel) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -4,6 +4,7 @@ import net.dv8tion.jda.api.JDA;
|
|||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||||
import net.nevet5gi.buzzbot.database.SqlDB;
|
import net.nevet5gi.buzzbot.database.SqlDB;
|
||||||
|
import net.nevet5gi.buzzbot.modules.ModuleLoader;
|
||||||
import net.nevet5gi.buzzbot.objects.BanData;
|
import net.nevet5gi.buzzbot.objects.BanData;
|
||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
@ -18,10 +19,26 @@ public class Test {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
initJda();
|
//initJda();
|
||||||
|
|
||||||
jda.retrieveUserById(712116155388526693L).queue(user -> { System.out.println(Integer.parseInt(user.getDiscriminator())); });
|
ModuleLoader.getModules();
|
||||||
|
|
||||||
|
// String role = "helper_id";
|
||||||
|
// String roleId = "234098234";
|
||||||
|
// String guildId = "34958735345345345";
|
||||||
|
//
|
||||||
|
// String sql = "UPDATE guild_settings SET " + role + " = " + roleId + " WHERE guild_id = " + guildId;
|
||||||
|
//
|
||||||
|
// System.out.println(sql);
|
||||||
|
|
||||||
|
//GuildData guild = new GuildData();
|
||||||
|
//guild.setName("Certified Tater");
|
||||||
|
//guild.setId(948704397569958038L);
|
||||||
|
//guild.setGroup("developer");
|
||||||
|
//guild.setProfanityLevel(0);
|
||||||
|
|
||||||
|
//SqlDB sql = new SqlDB();
|
||||||
|
//sql.addGuild(guild);
|
||||||
|
|
||||||
//sqlTest();
|
//sqlTest();
|
||||||
}
|
}
|
||||||
@ -45,14 +62,15 @@ public class Test {
|
|||||||
|
|
||||||
private static void sqlTest() {
|
private static void sqlTest() {
|
||||||
SqlDB db = new SqlDB();
|
SqlDB db = new SqlDB();
|
||||||
BanData ban = new BanData(972924565361695745L, "nevetS", Date.valueOf(LocalDate.now()), Time.valueOf(LocalTime.now()), true, 0, "Reason", "test3", 865368792980914186L, "DevHQ", 824071914673668138L);
|
BanData ban = new BanData(972924565361695745L, "nevetS", Date.valueOf(LocalDate.now()), Time.valueOf(LocalTime.now()), "reason", true, 0, "test3", 865368792980914186L, "DevHQ", 824071914673668138L);
|
||||||
db.insertBan(ban, "masterbanlist");
|
db.insertBan(ban, "masterbanlist");
|
||||||
|
db.close();
|
||||||
|
|
||||||
SqlDB db2 = new SqlDB();
|
SqlDB db2 = new SqlDB();
|
||||||
BanData qban = db2.queryBan(972924565361695745L, "masterbanlist");
|
BanData qban = db2.queryBan(972924565361695745L, "masterbanlist");
|
||||||
|
db2.close();
|
||||||
|
|
||||||
System.out.println(qban.getUserName());
|
System.out.println(qban.getUserName());
|
||||||
System.out.println(qban.getDate());
|
System.out.println(qban.getDate());
|
||||||
System.out.println(qban.getBanReason());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,12 +61,12 @@ public class BanCmd implements ICommand {
|
|||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ban.setBanReason(sb.toString().trim());
|
ban.setReason(sb.toString().trim());
|
||||||
|
|
||||||
if (ban.getBanLength() == 0) {
|
if (ban.getBanLength() == 0) {
|
||||||
ctx.getChannel().sendMessage("<@" + ctx.getMessage().getAuthor().getId() + "> permanently banned <@" + ban.getUserId() + ">. Reason: " + ban.getBanReason()).queue();
|
ctx.getChannel().sendMessage("<@" + ctx.getMessage().getAuthor().getId() + "> permanently banned <@" + ban.getUserId() + ">. Reason: " + ban.getReason()).queue();
|
||||||
} else {
|
} else {
|
||||||
ctx.getChannel().sendMessage("<@" + ctx.getMessage().getAuthor().getId() + "> banned <@" + ban.getUserId() + "> for " + ban.getBanLength() + " hours. Reason: " + ban.getBanReason()).queue();
|
ctx.getChannel().sendMessage("<@" + ctx.getMessage().getAuthor().getId() + "> banned <@" + ban.getUserId() + "> for " + ban.getBanLength() + " hours. Reason: " + ban.getReason()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bot.jda.retrieveUserById(ban.getUserId()).queue(user -> { ban.setUserName(user.getName()); });
|
Bot.jda.retrieveUserById(ban.getUserId()).queue(user -> { ban.setUserName(user.getName()); });
|
||||||
@ -75,8 +75,9 @@ public class BanCmd implements ICommand {
|
|||||||
ban.setServerId(ctx.getGuild().getIdLong());
|
ban.setServerId(ctx.getGuild().getIdLong());
|
||||||
ban.setServerName(ctx.getGuild().getName());
|
ban.setServerName(ctx.getGuild().getName());
|
||||||
|
|
||||||
//SqlDB db = new SqlDB();
|
SqlDB sql = new SqlDB();
|
||||||
//db.insertBan(ban, "master_ban_record");
|
sql.insertBan(ban, "master_ban_record");
|
||||||
|
sql.close();
|
||||||
|
|
||||||
//ctx.getEvent().getGuild().ban(cmdf, 1 , "").submit();
|
//ctx.getEvent().getGuild().ban(cmdf, 1 , "").submit();
|
||||||
//ctx.getMessage().reply("yes ban");
|
//ctx.getMessage().reply("yes ban");
|
||||||
|
@ -62,7 +62,7 @@ public class BeeCmd implements ICommand, ISlashCommand {
|
|||||||
try { getHttpConnection(); } catch (IOException | InterruptedException e) { e.printStackTrace(); }
|
try { getHttpConnection(); } catch (IOException | InterruptedException e) { e.printStackTrace(); }
|
||||||
EmbedBuilder eb = new EmbedBuilder();
|
EmbedBuilder eb = new EmbedBuilder();
|
||||||
eb.setImage(url.replace("\"",""));
|
eb.setImage(url.replace("\"",""));
|
||||||
ctx.getSlashEvent().getHook().sendMessageEmbeds(eb.build()).queue();
|
ctx.getHook().sendMessageEmbeds(eb.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,13 +2,16 @@ package net.nevet5gi.buzzbot.commands;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.Command;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.nevet5gi.buzzbot.Config;
|
import net.nevet5gi.buzzbot.Config;
|
||||||
import net.nevet5gi.buzzbot.commands.utils.*;
|
import net.nevet5gi.buzzbot.commands.utils.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HelpCmd implements ICommand, ISlashCommand {
|
public class HelpCmd implements ICommand, ISlashCommand {
|
||||||
@ -106,9 +109,21 @@ public class HelpCmd implements ICommand, ISlashCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull CommandData getCommandData() {
|
public @NotNull CommandData getCommandData() {
|
||||||
|
List<Command.Choice> choices = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ICommand cmd : manager.getCommands()) {
|
||||||
|
choices.add(new Command.Choice(cmd.getName(), cmd.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ISlashCommand cmd : manager.getSlashCommands()) {
|
||||||
|
choices.add(new Command.Choice(cmd.getName(), cmd.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionData option = new OptionData(OptionType.STRING, "command", "Gives info on specified command", false);
|
||||||
|
option.addChoices(choices);
|
||||||
|
|
||||||
return new CommandData(this.getName(), this.getDescription())
|
return new CommandData(this.getName(), this.getDescription())
|
||||||
.addOption(OptionType.STRING, "command", "Gives info on this command", false);
|
.addOptions(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ public class PingCmd implements ICommand, ISlashCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void handleSlash(CommandContext ctx) {
|
public void handleSlash(CommandContext ctx) {
|
||||||
JDA jda = Bot.jda;
|
JDA jda = Bot.jda;
|
||||||
jda.getRestPing().queue(ping -> ctx.getSlashEvent().getHook().sendMessageFormat("Rest API Ping: %sms\nWebSocket Ping: %sms", ping, jda.getGatewayPing()).queue());
|
jda.getRestPing().queue(ping -> ctx.getHook().sendMessageFormat("Rest API Ping: %sms\nWebSocket Ping: %sms", ping, jda.getGatewayPing()).queue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
60
src/main/java/net/nevet5gi/buzzbot/commands/SetRoleCmd.java
Normal file
60
src/main/java/net/nevet5gi/buzzbot/commands/SetRoleCmd.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package net.nevet5gi.buzzbot.commands;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
|
import net.nevet5gi.buzzbot.commands.utils.CommandContext;
|
||||||
|
import net.nevet5gi.buzzbot.commands.utils.ISlashCommand;
|
||||||
|
import net.nevet5gi.buzzbot.database.SqlDB;
|
||||||
|
import net.nevet5gi.buzzbot.objects.ModRoles;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SetRoleCmd implements ISlashCommand {
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "setrole";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPermissionLevel() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return "Sets the role id for the moderation roles";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleSlash(CommandContext ctx) {
|
||||||
|
SqlDB sql = new SqlDB();
|
||||||
|
sql.updateGuildRole(ctx.getGuild().getIdLong(), ctx.getSlashEvent().getOption("role").getAsString(), ctx.getSlashEvent().getOption("guild_role").getAsRole().getIdLong());
|
||||||
|
sql.close();
|
||||||
|
ctx.getHook().sendMessage("Assigned role <@&" + ctx.getSlashEvent().getOption("guild_role").getAsRole().getId() + "> to " + ctx.getSlashEvent().getOption("role").getAsString()).queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.getHelp();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandData getCommandData() {
|
||||||
|
List<OptionData> options = new ArrayList<>();
|
||||||
|
|
||||||
|
OptionData role = new OptionData(OptionType.STRING, "role", "Role assigned to moderation roles", true);
|
||||||
|
role.addChoice("helper", ModRoles.HELPER.getRole());
|
||||||
|
role.addChoice("moderator", ModRoles.MODERATOR.getRole());
|
||||||
|
role.addChoice("administrator", ModRoles.ADMINISTRATOR.getRole());
|
||||||
|
role.addChoice("owner", ModRoles.OWNER.getRole());
|
||||||
|
options.add(role);
|
||||||
|
|
||||||
|
OptionData guildRole = new OptionData(OptionType.ROLE, "guild_role", "Mentioned role to assign", true);
|
||||||
|
options.add(guildRole);
|
||||||
|
|
||||||
|
return new CommandData(this.getName(), this.getDescription())
|
||||||
|
.addOptions(options);
|
||||||
|
}
|
||||||
|
}
|
@ -18,22 +18,23 @@ public class TestCmd implements ICommand, ISlashCommand {
|
|||||||
long number = ctx.getSlashEvent().getOption("number").getAsLong();
|
long number = ctx.getSlashEvent().getOption("number").getAsLong();
|
||||||
IMentionable member = ctx.getSlashEvent().getOption("mention").getAsMentionable();
|
IMentionable member = ctx.getSlashEvent().getOption("mention").getAsMentionable();
|
||||||
boolean testBoolean = ctx.getSlashEvent().getOption("boolean").getAsBoolean();
|
boolean testBoolean = ctx.getSlashEvent().getOption("boolean").getAsBoolean();
|
||||||
|
String commandString = ctx.getSlashEvent().getCommandString();
|
||||||
|
|
||||||
String content = "number: " + number + ", mention: " + member.getAsMention() + ", boolean: " + testBoolean;
|
String content = "number: " + number + ", mention: " + member.getAsMention() + ", boolean: " + testBoolean + ", command string: " + commandString;
|
||||||
|
|
||||||
ctx.getSlashEvent().getHook().sendMessage(content).queue();
|
ctx.getHook().sendMessage(content).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Checks the piung between bot and API";
|
return "Checks the ping between bot and API";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandData getCommandData() {
|
public CommandData getCommandData() {
|
||||||
return new CommandData(this.getName(), this.getDescription())
|
return new CommandData(this.getName(), this.getDescription())
|
||||||
.addOption(OptionType.INTEGER, "number", "test number", true)
|
.addOption(OptionType.INTEGER, "number", "test number", true)
|
||||||
.addOption(OptionType.MENTIONABLE, "mention", "mentioned member or role", true)
|
.addOption(OptionType.USER, "mention", "mentioned member or role", true)
|
||||||
.addOption(OptionType.BOOLEAN, "boolean", "test boolean", true);
|
.addOption(OptionType.BOOLEAN, "boolean", "test boolean", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,10 @@ package net.nevet5gi.buzzbot.commands;
|
|||||||
|
|
||||||
import net.nevet5gi.buzzbot.commands.utils.CommandContext;
|
import net.nevet5gi.buzzbot.commands.utils.CommandContext;
|
||||||
import net.nevet5gi.buzzbot.commands.utils.ICommand;
|
import net.nevet5gi.buzzbot.commands.utils.ICommand;
|
||||||
|
import net.nevet5gi.buzzbot.database.SqlDB;
|
||||||
|
import net.nevet5gi.buzzbot.util.GuildUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class UnbanCmd implements ICommand {
|
public class UnbanCmd implements ICommand {
|
||||||
@Override
|
@Override
|
||||||
@ -9,7 +13,20 @@ public class UnbanCmd implements ICommand {
|
|||||||
// Somehow keep track of bans
|
// Somehow keep track of bans
|
||||||
// Make sure a user can only be unbanned from the guild they were banned from
|
// Make sure a user can only be unbanned from the guild they were banned from
|
||||||
|
|
||||||
ctx.getMessage().reply("This command doesn't work yet").queue();
|
List<String> args = ctx.getArgs();
|
||||||
|
|
||||||
|
long userId;
|
||||||
|
if (args.get(0).contains("<@")) {
|
||||||
|
userId = Long.parseLong(args.get(0).replace("<","").replace("@","").replace("&","").replace(">",""));
|
||||||
|
} else {
|
||||||
|
userId = Long.parseLong(args.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
SqlDB sql = new SqlDB();
|
||||||
|
sql.queryBan(userId, GuildUtils.getTable(ctx.getGuild()));
|
||||||
|
sql.close();
|
||||||
|
|
||||||
|
ctx.getGuild().getIdLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,19 +1,51 @@
|
|||||||
package net.nevet5gi.buzzbot.commands;
|
package net.nevet5gi.buzzbot.commands;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.nevet5gi.buzzbot.Bot;
|
||||||
import net.nevet5gi.buzzbot.commands.utils.CommandContext;
|
import net.nevet5gi.buzzbot.commands.utils.CommandContext;
|
||||||
import net.nevet5gi.buzzbot.commands.utils.ICommand;
|
import net.nevet5gi.buzzbot.commands.utils.ICommand;
|
||||||
import net.nevet5gi.buzzbot.commands.utils.ISlashCommand;
|
import net.nevet5gi.buzzbot.database.SqlDB;
|
||||||
|
import net.nevet5gi.buzzbot.objects.WarnData;
|
||||||
|
|
||||||
public class WarnCmd implements ICommand, ISlashCommand {
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WarnCmd implements ICommand {
|
||||||
@Override
|
@Override
|
||||||
public void handle(CommandContext ctx) {
|
public void handle(CommandContext ctx) {
|
||||||
ctx.getMessage().reply("This command has not been implemented yet").queue();
|
List<String> args = ctx.getArgs();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (args.size() < 2) {
|
||||||
public void handleSlash(CommandContext ctx) {
|
ctx.getChannel().sendMessage("Not enough arguments, please try again").queue();
|
||||||
ctx.getSlashEvent().getHook().sendMessage("This command has not been implemented yet").queue();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WarnData warn = new WarnData();
|
||||||
|
|
||||||
|
if (args.get(0).contains("<@")) {
|
||||||
|
warn.setUserId(Long.parseLong(args.get(0).replace("<","").replace("@","").replace("&","").replace(">","")));
|
||||||
|
} else {
|
||||||
|
warn.setUserId(Long.parseLong(args.get(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (args.size() >= 1) {
|
||||||
|
for (int i = 1; i < args.size(); i++) {
|
||||||
|
sb.append(args.get(i));
|
||||||
|
sb.append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
warn.setReason(sb.toString().trim());
|
||||||
|
|
||||||
|
ctx.getChannel().sendMessage("<@" + ctx.getMessage().getAuthor().getId() + "> warned <@" + warn.getUserId() + "> for reason: " + warn.getReason()).queue();
|
||||||
|
|
||||||
|
Bot.jda.retrieveUserById(warn.getUserId()).queue(user -> { warn.setUserName(user.getName()); });
|
||||||
|
warn.setModId(ctx.getMessage().getAuthor().getIdLong());
|
||||||
|
warn.setModName(ctx.getMessage().getAuthor().getName());
|
||||||
|
warn.setServerId(ctx.getGuild().getIdLong());
|
||||||
|
warn.setServerName(ctx.getGuild().getName());
|
||||||
|
|
||||||
|
SqlDB sql = new SqlDB();
|
||||||
|
sql.insertWarn(warn, "master_warn_record");
|
||||||
|
sql.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,16 +58,6 @@ public class WarnCmd implements ICommand, ISlashCommand {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return "Warns specified user";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandData getCommandData() {
|
|
||||||
return new CommandData(this.getName(), this.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelp() {
|
public String getHelp() {
|
||||||
return "Warns the specified user";
|
return "Warns the specified user";
|
||||||
|
@ -25,6 +25,7 @@ public class CommandContext implements ICommandContext {
|
|||||||
return this.event;
|
return this.event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SlashCommandEvent getSlashEvent() {
|
public SlashCommandEvent getSlashEvent() {
|
||||||
return this.slashEvent;
|
return this.slashEvent;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.nevet5gi.buzzbot.commands.utils;
|
package net.nevet5gi.buzzbot.commands.utils;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
@ -8,6 +9,8 @@ import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
|||||||
import net.nevet5gi.buzzbot.Bot;
|
import net.nevet5gi.buzzbot.Bot;
|
||||||
import net.nevet5gi.buzzbot.Config;
|
import net.nevet5gi.buzzbot.Config;
|
||||||
import net.nevet5gi.buzzbot.commands.*;
|
import net.nevet5gi.buzzbot.commands.*;
|
||||||
|
import net.nevet5gi.buzzbot.database.SqlDB;
|
||||||
|
import net.nevet5gi.buzzbot.objects.GuildData;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -29,6 +32,7 @@ public class CommandManager {
|
|||||||
addCommand(new HelpCmd(this));
|
addCommand(new HelpCmd(this));
|
||||||
addCommand(new MuteCmd());
|
addCommand(new MuteCmd());
|
||||||
addCommand(new PingCmd());
|
addCommand(new PingCmd());
|
||||||
|
addCommand(new SetRoleCmd());
|
||||||
addCommand(new TestCmd());
|
addCommand(new TestCmd());
|
||||||
addCommand(new UnbanCmd());
|
addCommand(new UnbanCmd());
|
||||||
addCommand(new UnmuteCmd());
|
addCommand(new UnmuteCmd());
|
||||||
@ -66,6 +70,10 @@ public class CommandManager {
|
|||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ISlashCommand> getSlashCommands() {
|
||||||
|
return slashList;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ICommand getCommand(String search) {
|
public ICommand getCommand(String search) {
|
||||||
String searchLower = search.toLowerCase();
|
String searchLower = search.toLowerCase();
|
||||||
@ -79,10 +87,8 @@ public class CommandManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(Member member, ICmdGeneric cmd) {
|
public boolean hasPermission(Member member, ICmdGeneric cmd, GuildData guild) {
|
||||||
//TODO Make this get roles from db
|
|
||||||
List<Role> roles = member.getRoles();
|
List<Role> roles = member.getRoles();
|
||||||
|
|
||||||
int permLevel = 0;
|
int permLevel = 0;
|
||||||
|
|
||||||
for (Role role : roles) {
|
for (Role role : roles) {
|
||||||
@ -99,6 +105,12 @@ public class CommandManager {
|
|||||||
case "owner":
|
case "owner":
|
||||||
if (permLevel < 4) permLevel = 4;
|
if (permLevel < 4) permLevel = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (role.getIdLong() == guild.getHelperId() && permLevel < 1) permLevel = 1;
|
||||||
|
if (role.getIdLong() == guild.getModeratorId() && permLevel < 2) permLevel = 2;
|
||||||
|
if (role.getIdLong() == guild.getAdministratorId() && permLevel < 3) permLevel = 3;
|
||||||
|
if (role.getIdLong() == guild.getOwnerId() && permLevel < 4) permLevel = 4;
|
||||||
|
if (member.isOwner() && permLevel < 4) permLevel = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return permLevel >= cmd.getPermissionLevel();
|
return permLevel >= cmd.getPermissionLevel();
|
||||||
@ -125,7 +137,11 @@ public class CommandManager {
|
|||||||
String invoke = split[0].toLowerCase();
|
String invoke = split[0].toLowerCase();
|
||||||
ICommand cmd = getCommand(invoke);
|
ICommand cmd = getCommand(invoke);
|
||||||
|
|
||||||
if (!hasPermission(event.getMember(), cmd)) {
|
SqlDB sql = new SqlDB();
|
||||||
|
GuildData guild = sql.getGuildData(event.getGuild().getIdLong());
|
||||||
|
sql.close();
|
||||||
|
|
||||||
|
if (!hasPermission(event.getMember(), cmd, guild)) {
|
||||||
event.getMessage().reply("You do not have permission to use this command.").queue();
|
event.getMessage().reply("You do not have permission to use this command.").queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -144,13 +160,18 @@ public class CommandManager {
|
|||||||
String invoke = event.getName();
|
String invoke = event.getName();
|
||||||
ISlashCommand cmd = getSlashCommand(invoke);
|
ISlashCommand cmd = getSlashCommand(invoke);
|
||||||
|
|
||||||
if (!hasPermission(event.getMember(), cmd)) {
|
|
||||||
event.getHook().sendMessage("You do not have permission to use this command.").queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmd != null) {
|
if (cmd != null) {
|
||||||
event.deferReply().queue();
|
event.deferReply().queue();
|
||||||
|
|
||||||
|
SqlDB sql = new SqlDB();
|
||||||
|
GuildData guild = sql.getGuildData(event.getGuild().getIdLong());
|
||||||
|
sql.close();
|
||||||
|
|
||||||
|
if (!hasPermission(event.getMember(), cmd, guild)) {
|
||||||
|
event.getHook().sendMessage("You do not have permission to use this command.").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
|
|
||||||
CommandContext ctx = new CommandContext(event, args);
|
CommandContext ctx = new CommandContext(event, args);
|
||||||
|
@ -2,7 +2,9 @@ package net.nevet5gi.buzzbot.commands.utils;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.entities.*;
|
import net.dv8tion.jda.api.entities.*;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||||
import net.dv8tion.jda.api.sharding.ShardManager;
|
import net.dv8tion.jda.api.sharding.ShardManager;
|
||||||
|
|
||||||
public interface ICommandContext {
|
public interface ICommandContext {
|
||||||
@ -13,7 +15,12 @@ public interface ICommandContext {
|
|||||||
* @return the {@link net.dv8tion.jda.api.entities.Guild} for this command/event
|
* @return the {@link net.dv8tion.jda.api.entities.Guild} for this command/event
|
||||||
*/
|
*/
|
||||||
default Guild getGuild() {
|
default Guild getGuild() {
|
||||||
return this.getEvent().getGuild();
|
if (this.getEvent() == null) {
|
||||||
|
return this.getSlashEvent().getGuild();
|
||||||
|
} else if (this.getSlashEvent() == null) {
|
||||||
|
return this.getEvent().getGuild();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,13 +30,25 @@ public interface ICommandContext {
|
|||||||
*/
|
*/
|
||||||
GuildMessageReceivedEvent getEvent();
|
GuildMessageReceivedEvent getEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link net.dv8tion.jda.api.events.interaction.SlashCommandEvent interaction event} that was received for this instance
|
||||||
|
*
|
||||||
|
* @returns the {@link net.dv8tion.jda.api.events.interaction.SlashCommandEvent interaction event} that was received for this instance
|
||||||
|
*/
|
||||||
|
SlashCommandEvent getSlashEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link net.dv8tion.jda.api.entities.TextChannel channel} that the message for this event was send in
|
* Returns the {@link net.dv8tion.jda.api.entities.TextChannel channel} that the message for this event was send in
|
||||||
*
|
*
|
||||||
* @return the {@link net.dv8tion.jda.api.entities.TextChannel channel} that the message for this event was send in
|
* @return the {@link net.dv8tion.jda.api.entities.TextChannel channel} that the message for this event was send in
|
||||||
*/
|
*/
|
||||||
default TextChannel getChannel() {
|
default TextChannel getChannel() {
|
||||||
return this.getEvent().getChannel();
|
if (this.getEvent() == null) {
|
||||||
|
return this.getSlashEvent().getTextChannel();
|
||||||
|
} else if (this.getSlashEvent() == null) {
|
||||||
|
return this.getEvent().getChannel();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +57,19 @@ public interface ICommandContext {
|
|||||||
* @return the {@link net.dv8tion.jda.api.entities.Message message} that triggered this event
|
* @return the {@link net.dv8tion.jda.api.entities.Message message} that triggered this event
|
||||||
*/
|
*/
|
||||||
default Message getMessage() {
|
default Message getMessage() {
|
||||||
return this.getEvent().getMessage();
|
if (this.getEvent() == null) {
|
||||||
|
return null;
|
||||||
|
} else if (this.getSlashEvent() == null) {
|
||||||
|
return this.getEvent().getMessage();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
default String getCommandString() {
|
||||||
|
if (this.getEvent() == null) {
|
||||||
|
return this.getSlashEvent().getCommandString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +78,12 @@ public interface ICommandContext {
|
|||||||
* @return the {@link net.dv8tion.jda.api.entities.User author} of the message as user
|
* @return the {@link net.dv8tion.jda.api.entities.User author} of the message as user
|
||||||
*/
|
*/
|
||||||
default User getAuthor() {
|
default User getAuthor() {
|
||||||
return this.getEvent().getAuthor();
|
if (this.getEvent() == null) {
|
||||||
|
return this.getSlashEvent().getUser();
|
||||||
|
} else if (this.getSlashEvent() == null) {
|
||||||
|
return this.getEvent().getAuthor();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the {@link net.dv8tion.jda.api.entities.Member author} of the message as member
|
* Returns the {@link net.dv8tion.jda.api.entities.Member author} of the message as member
|
||||||
@ -55,7 +91,21 @@ public interface ICommandContext {
|
|||||||
* @return the {@link net.dv8tion.jda.api.entities.Member author} of the message as member
|
* @return the {@link net.dv8tion.jda.api.entities.Member author} of the message as member
|
||||||
*/
|
*/
|
||||||
default Member getMember() {
|
default Member getMember() {
|
||||||
return this.getEvent().getMember();
|
if (this.getEvent() == null) {
|
||||||
|
return this.getSlashEvent().getMember();
|
||||||
|
} else if (this.getSlashEvent() == null) {
|
||||||
|
return this.getEvent().getMember();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link net.dv8tion.jda.api.interactions.InteractionHook interaction hook} of the slash command
|
||||||
|
*
|
||||||
|
* @return the {@link net.dv8tion.jda.api.interactions.InteractionHook interaction hook} of the slash command
|
||||||
|
*/
|
||||||
|
default InteractionHook getHook() {
|
||||||
|
return this.getSlashEvent().getHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +114,12 @@ public interface ICommandContext {
|
|||||||
* @return the current {@link net.dv8tion.jda.api.JDA jda} instance
|
* @return the current {@link net.dv8tion.jda.api.JDA jda} instance
|
||||||
*/
|
*/
|
||||||
default JDA getJDA() {
|
default JDA getJDA() {
|
||||||
return this.getEvent().getJDA();
|
if (this.getEvent() == null) {
|
||||||
|
return this.getSlashEvent().getJDA();
|
||||||
|
} else if (this.getSlashEvent() == null) {
|
||||||
|
return this.getEvent().getJDA();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.nevet5gi.buzzbot.database;
|
package net.nevet5gi.buzzbot.database;
|
||||||
|
|
||||||
import net.nevet5gi.buzzbot.Config;
|
import net.nevet5gi.buzzbot.Config;
|
||||||
import net.nevet5gi.buzzbot.objects.BanData;
|
import net.nevet5gi.buzzbot.objects.*;
|
||||||
import net.nevet5gi.buzzbot.objects.GuildData;
|
|
||||||
import net.nevet5gi.buzzbot.objects.MuteData;
|
|
||||||
import net.nevet5gi.buzzbot.objects.WarnData;
|
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SqlDB {
|
public class SqlDB {
|
||||||
private Connection connect;
|
private Connection connect;
|
||||||
@ -25,12 +23,13 @@ public class SqlDB {
|
|||||||
|
|
||||||
public void insertBan(BanData ban, String table) {
|
public void insertBan(BanData ban, String table) {
|
||||||
try {
|
try {
|
||||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + ban.getUserId() + ", '" + ban.getUserName() + "', '" + ban.getDate() + "', '" + ban.getTime() + "', " + ban.getBanType() + ", " + ban.getBanLength() + ", '" + ban.getBanReason() + "', '" + ban.getModName() + "', " + ban.getModId() + ", '" + ban.getServerName() + "', " + ban.getServerId() + ", 1)");
|
statement.executeUpdate("INSERT INTO master_ban_record VALUES (default, " + ban.getUserId() + ", '" + ban.getUserName() + "', '" + ban.getDate() + "', '" + ban.getTime() + "', " + ban.getBanType() + ", " + ban.getBanLength() + ", '" + ban.getReason() + "', '" + ban.getModName() + "', " + ban.getModId() + ", '" + ban.getServerName() + "', " + ban.getServerId() + ", 1)");
|
||||||
|
if (!table.equalsIgnoreCase("master_ban_record")) {
|
||||||
|
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + ban.getUserId() + ", '" + ban.getUserName() + "', '" + ban.getDate() + "', '" + ban.getTime() + "', " + ban.getBanType() + ", " + ban.getBanLength() + ", '" + ban.getReason() + "', '" + ban.getModName() + "', " + ban.getModId() + ", '" + ban.getServerName() + "', " + ban.getServerId() + ", 1)");
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertUnban(long userId, String table) {
|
public void insertUnban(long userId, String table) {
|
||||||
@ -39,22 +38,24 @@ public class SqlDB {
|
|||||||
|
|
||||||
public void insertMute(MuteData mute, String table) {
|
public void insertMute(MuteData mute, String table) {
|
||||||
try {
|
try {
|
||||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + mute.getUserId() + ", '" + mute.getUserName() + "', '" + mute.getDate() + "', '" + mute.getTime() + "', " + mute.getMuteLength() + ", '" + mute.getMuteReason() + "', '" + mute.getModName() + "', " + mute.getModId() + ", '" + mute.getServerName() + "', " + mute.getServerId() + ")");
|
statement.executeUpdate("INSERT INTO master_mute_record VALUES (default, " + mute.getUserId() + ", '" + mute.getUserName() + "', '" + mute.getDate() + "', '" + mute.getTime() + "', " + mute.getMuteLength() + ", '" + mute.getReason() + "', '" + mute.getModName() + "', " + mute.getModId() + ", '" + mute.getServerName() + "', " + mute.getServerId() + ")");
|
||||||
|
if (!table.equalsIgnoreCase("master_mute_record")) {
|
||||||
|
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + mute.getUserId() + ", '" + mute.getUserName() + "', '" + mute.getDate() + "', '" + mute.getTime() + "', " + mute.getMuteLength() + ", '" + mute.getReason() + "', '" + mute.getModName() + "', " + mute.getModId() + ", '" + mute.getServerName() + "', " + mute.getServerId() + ")");
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertWarn(WarnData warn, String table) {
|
public void insertWarn(WarnData warn, String table) {
|
||||||
try {
|
try {
|
||||||
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + warn.getUserId() + ", '" + warn.getUserName() + "', '" + warn.getDate() + "', '" + warn.getTime() + "', " + warn.getBanType() + ", " + warn.getBanLength() + ", '" + warn.getBanReason() + "', '" + warn.getModName() + "', " + warn.getModId() + ", '" + warn.getServerName() + "', " + warn.getServerId() + ")");
|
statement.executeUpdate("INSERT INTO master_warn_record VALUES (default, " + warn.getUserId() + ", '" + warn.getUserName() + "', '" + warn.getDate() + "', '" + warn.getTime() + "', '" + warn.getReason() + "', '" + warn.getModName() + "', " + warn.getModId() + ", '" + warn.getServerName() + "', " + warn.getServerId() + ")");
|
||||||
|
if (!table.equalsIgnoreCase("master_warn_record")){
|
||||||
|
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + warn.getUserId() + ", '" + warn.getUserName() + "', '" + warn.getDate() + "', '" + warn.getTime() + "', '" + warn.getReason() + "', '" + warn.getModName() + "', " + warn.getModId() + ", '" + warn.getServerName() + "', " + warn.getServerId() + ")");
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BanData queryBan(long userId, String table) {
|
public BanData queryBan(long userId, String table) {
|
||||||
@ -68,9 +69,9 @@ public class SqlDB {
|
|||||||
ban.setUserName(resultSet.getString("user_name"));
|
ban.setUserName(resultSet.getString("user_name"));
|
||||||
ban.setDate(resultSet.getDate("ban_date"));
|
ban.setDate(resultSet.getDate("ban_date"));
|
||||||
ban.setTime(resultSet.getTime("ban_time"));
|
ban.setTime(resultSet.getTime("ban_time"));
|
||||||
|
ban.setReason(resultSet.getString("ban_reason"));
|
||||||
ban.setBanType(resultSet.getBoolean("ban_type"));
|
ban.setBanType(resultSet.getBoolean("ban_type"));
|
||||||
ban.setBanLength(resultSet.getInt("ban_length"));
|
ban.setBanLength(resultSet.getInt("ban_length"));
|
||||||
ban.setBanReason(resultSet.getString("ban_reason"));
|
|
||||||
ban.setModName(resultSet.getString("mod_name"));
|
ban.setModName(resultSet.getString("mod_name"));
|
||||||
ban.setModId(resultSet.getLong("mod_id"));
|
ban.setModId(resultSet.getLong("mod_id"));
|
||||||
ban.setServerName(resultSet.getString("server_name"));
|
ban.setServerName(resultSet.getString("server_name"));
|
||||||
@ -80,8 +81,6 @@ public class SqlDB {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
return ban;
|
return ban;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,8 +98,6 @@ public class SqlDB {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
return mute;
|
return mute;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,19 +114,15 @@ public class SqlDB {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
return warn;
|
return warn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGuild(GuildData guild) {
|
public void addGuild(GuildData guild) {
|
||||||
try {
|
try {
|
||||||
statement.executeUpdate("INSERT INTO guild_settings VALUES ('" + guild.getName() + "', " + guild.getId() + ", '" + guild.getGroup() + "', " + guild.getProfanityLevel() + ")");
|
statement.executeUpdate("INSERT INTO guild_settings VALUES ('" + guild.getName() + "', " + guild.getId() + ", '" + guild.getGroup() + "', " + guild.getProfanityLevel() + ", 0, 0, 0, 0)");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuildData getGuildData(long guildId) {
|
public GuildData getGuildData(long guildId) {
|
||||||
@ -143,16 +136,47 @@ public class SqlDB {
|
|||||||
guild.setId(resultSet.getLong("guild_id"));
|
guild.setId(resultSet.getLong("guild_id"));
|
||||||
guild.setGroup(resultSet.getString("guild_group"));
|
guild.setGroup(resultSet.getString("guild_group"));
|
||||||
guild.setProfanityLevel(resultSet.getInt("profanity_level"));
|
guild.setProfanityLevel(resultSet.getInt("profanity_level"));
|
||||||
|
guild.setHelperId(resultSet.getLong("helper_id"));
|
||||||
|
guild.setModeratorId(resultSet.getLong("moderator_id"));
|
||||||
|
guild.setAdministratorId(resultSet.getLong("administrator_id"));
|
||||||
|
guild.setOwnerId(resultSet.getLong("owner_id"));
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
return guild;
|
return guild;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void close() {
|
public void updateGuildRole(long guildId, String role, long roleId) {
|
||||||
|
String sql = "UPDATE guild_settings SET " + role + " = " + roleId + " WHERE guild_id = " + guildId;
|
||||||
|
try {
|
||||||
|
statement.executeUpdate(sql);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGroup(Group group) {
|
||||||
|
//TODO Make this function
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Group> getGroups() {
|
||||||
|
String sql = "";
|
||||||
|
ArrayList<Group> groups = new ArrayList<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
resultSet = statement.executeQuery(sql);
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
try {
|
try {
|
||||||
if (resultSet != null) {
|
if (resultSet != null) {
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
|
@ -25,12 +25,12 @@ public class ProfanityFilter {
|
|||||||
|
|
||||||
public void handle(GuildMessageReceivedEvent event) {
|
public void handle(GuildMessageReceivedEvent event) {
|
||||||
event.getMessage().delete().queue();
|
event.getMessage().delete().queue();
|
||||||
event.getChannel().sendMessage("No swearing please :)").queue();
|
event.getChannel().sendMessage("Hey <@" + event.getAuthor().getId() + ">, no swearing!").queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleEdit(GuildMessageUpdateEvent event) {
|
public void handleEdit(GuildMessageUpdateEvent event) {
|
||||||
event.getMessage().delete().queue();
|
event.getMessage().delete().queue();
|
||||||
event.getChannel().sendMessage("Nice try ;)").queue();
|
event.getChannel().sendMessage("Hey <@" + event.getAuthor().getId() + ">, no swearing!").queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildDictionaries() {
|
public void buildDictionaries() {
|
||||||
|
12
src/main/java/net/nevet5gi/buzzbot/modules/BuzzyModule.java
Normal file
12
src/main/java/net/nevet5gi/buzzbot/modules/BuzzyModule.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package net.nevet5gi.buzzbot.modules;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
|
||||||
|
public interface BuzzyModule {
|
||||||
|
|
||||||
|
default void onPreEnable() {}
|
||||||
|
|
||||||
|
void onEnable(JDA jda);
|
||||||
|
|
||||||
|
void onDisable();
|
||||||
|
}
|
71
src/main/java/net/nevet5gi/buzzbot/modules/ModuleLoader.java
Normal file
71
src/main/java/net/nevet5gi/buzzbot/modules/ModuleLoader.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package net.nevet5gi.buzzbot.modules;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.jar.Attributes;
|
||||||
|
import java.util.jar.JarInputStream;
|
||||||
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
|
public class ModuleLoader {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ModuleLoader.class);
|
||||||
|
|
||||||
|
public static ArrayList<Path> getModules() {
|
||||||
|
File modulesPath = new File("./modules/");
|
||||||
|
if (!modulesPath.exists()) {
|
||||||
|
modulesPath.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<Path> modules = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Files.walk(Paths.get("./modules/"))
|
||||||
|
.filter(Files::isRegularFile)
|
||||||
|
.forEach(modules::add);
|
||||||
|
|
||||||
|
for (Path path : modules) {
|
||||||
|
System.out.println("Module path: " + path.toString());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Unable to get module list");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<BuzzyModule> loadModules() throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
|
||||||
|
ArrayList<Path> modulePaths = getModules();
|
||||||
|
|
||||||
|
ArrayList<BuzzyModule> modules = new ArrayList<>();
|
||||||
|
for (Path module : modulePaths) {
|
||||||
|
JarInputStream jarStream = new JarInputStream(new FileInputStream(String.valueOf(module)));
|
||||||
|
Manifest mf = jarStream.getManifest();
|
||||||
|
Attributes attributes = mf.getMainAttributes();
|
||||||
|
String mainClassString = attributes.getValue("Main-Class");
|
||||||
|
if (mainClassString == null) {
|
||||||
|
LOGGER.error("Unable to get Main Class from module " + module.toString());
|
||||||
|
}
|
||||||
|
String[] packages = mainClassString.split("\\.");
|
||||||
|
String className = packages[packages.length - 1];
|
||||||
|
|
||||||
|
File file = module.toFile();
|
||||||
|
URL[] urls = {file.toURI().toURL()};
|
||||||
|
|
||||||
|
URLClassLoader urlClassLoader = URLClassLoader.newInstance(urls);
|
||||||
|
|
||||||
|
Class<? extends BuzzyModule> mainClass = (Class<? extends BuzzyModule>) Class.forName(className, true, urlClassLoader);
|
||||||
|
BuzzyModule newModule = mainClass.getDeclaredConstructor().newInstance();
|
||||||
|
newModule.onPreEnable();
|
||||||
|
modules.add(newModule);
|
||||||
|
}
|
||||||
|
return modules;
|
||||||
|
}
|
||||||
|
}
|
@ -3,18 +3,15 @@ package net.nevet5gi.buzzbot.objects;
|
|||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.sql.Time;
|
import java.sql.Time;
|
||||||
|
|
||||||
public class BanData extends UserData {
|
public class BanData extends DisciplineData {
|
||||||
private boolean banType;
|
private boolean banType;
|
||||||
private int banLength;
|
private int banLength;
|
||||||
private String banReason;
|
|
||||||
|
|
||||||
public BanData() {}
|
public BanData() {}
|
||||||
|
|
||||||
public BanData(long userId, String userName, Date date, Time time, boolean banType, int banLength, String banReason, String modName, long modId, String serverName, long serverId) {
|
public BanData(long userId, String userName, Date date, Time time, String reason, boolean banType, int banLength, String modName, long modId, String serverName, long serverId) {
|
||||||
super(userId, userName, date, time, modName, modId, serverName, serverId);
|
super(userId, userName, date, time, reason, modName, modId, serverName, serverId);
|
||||||
this.banType = banType;
|
this.banType = banType;
|
||||||
this.banLength = banLength;
|
this.banLength = banLength;
|
||||||
this.banReason = banReason;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBanType(boolean banType) {
|
public void setBanType(boolean banType) {
|
||||||
@ -32,12 +29,4 @@ public class BanData extends UserData {
|
|||||||
public int getBanLength() {
|
public int getBanLength() {
|
||||||
return banLength;
|
return banLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBanReason(String banReason) {
|
|
||||||
this.banReason = banReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBanReason() {
|
|
||||||
return banReason;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,23 +5,25 @@ import java.sql.Time;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
|
||||||
public class UserData {
|
public class DisciplineData {
|
||||||
private long userId;
|
private long userId;
|
||||||
private String userName;
|
private String userName;
|
||||||
private Date date = Date.valueOf(LocalDate.now());
|
private Date date = Date.valueOf(LocalDate.now());
|
||||||
private Time time = Time.valueOf(LocalTime.now());
|
private Time time = Time.valueOf(LocalTime.now());
|
||||||
|
private String reason;
|
||||||
private String modName;
|
private String modName;
|
||||||
private long modId;
|
private long modId;
|
||||||
private String serverName;
|
private String serverName;
|
||||||
private long serverId;
|
private long serverId;
|
||||||
|
|
||||||
public UserData() {}
|
public DisciplineData() {}
|
||||||
|
|
||||||
public UserData(long userId, String userName, Date date, Time time, String modName, long modId, String serverName, long serverId) {
|
public DisciplineData(long userId, String userName, Date date, Time time, String reason, String modName, long modId, String serverName, long serverId) {
|
||||||
this.setUserId(userId);
|
this.setUserId(userId);
|
||||||
this.setUserName(userName);
|
this.setUserName(userName);
|
||||||
this.setDate(date);
|
this.setDate(date);
|
||||||
this.setTime(time);
|
this.setTime(time);
|
||||||
|
this.setReason(reason);
|
||||||
this.setModName(modName);
|
this.setModName(modName);
|
||||||
this.setModId(modId);
|
this.setModId(modId);
|
||||||
this.setServerName(serverName);
|
this.setServerName(serverName);
|
||||||
@ -60,6 +62,14 @@ public class UserData {
|
|||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setReason(String reason) {
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
public void setModName(String modName) {
|
public void setModName(String modName) {
|
||||||
this.modName = modName;
|
this.modName = modName;
|
||||||
}
|
}
|
37
src/main/java/net/nevet5gi/buzzbot/objects/Group.java
Normal file
37
src/main/java/net/nevet5gi/buzzbot/objects/Group.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package net.nevet5gi.buzzbot.objects;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Group {
|
||||||
|
private String name;
|
||||||
|
private String tablePrefix;
|
||||||
|
private List<String> members;
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTablePrefix(String tablePrefix) {
|
||||||
|
this.tablePrefix = tablePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTablePrefix() {
|
||||||
|
return tablePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMembers(List<String> members) {
|
||||||
|
this.members = members;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMember(String member) {
|
||||||
|
this.members.add(member);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getMembers() {
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,10 @@ public class GuildData {
|
|||||||
private long id;
|
private long id;
|
||||||
private String group;
|
private String group;
|
||||||
private int profanityLevel;
|
private int profanityLevel;
|
||||||
|
private long helperId;
|
||||||
|
private long moderatorId;
|
||||||
|
private long administratorId;
|
||||||
|
private long ownerId;
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -37,4 +41,36 @@ public class GuildData {
|
|||||||
public int getProfanityLevel() {
|
public int getProfanityLevel() {
|
||||||
return profanityLevel;
|
return profanityLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHelperId(long helperId) {
|
||||||
|
this.helperId = helperId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getHelperId() {
|
||||||
|
return helperId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModeratorId(long moderatorId) {
|
||||||
|
this.moderatorId = moderatorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getModeratorId() {
|
||||||
|
return moderatorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdministratorId(long administratorId) {
|
||||||
|
this.administratorId = administratorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAdministratorId() {
|
||||||
|
return administratorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwnerId(long ownerId) {
|
||||||
|
this.ownerId = ownerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getOwnerId() {
|
||||||
|
return ownerId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
17
src/main/java/net/nevet5gi/buzzbot/objects/ModRoles.java
Normal file
17
src/main/java/net/nevet5gi/buzzbot/objects/ModRoles.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package net.nevet5gi.buzzbot.objects;
|
||||||
|
|
||||||
|
public enum ModRoles {
|
||||||
|
HELPER("helper_id"),
|
||||||
|
MODERATOR("moderator_id"),
|
||||||
|
ADMINISTRATOR("administrator_id"),
|
||||||
|
OWNER("owner_id");
|
||||||
|
|
||||||
|
private final String role;
|
||||||
|
|
||||||
|
ModRoles(String role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
public String getRole() {
|
||||||
|
return this.role;
|
||||||
|
}
|
||||||
|
}
|
@ -3,16 +3,14 @@ package net.nevet5gi.buzzbot.objects;
|
|||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.sql.Time;
|
import java.sql.Time;
|
||||||
|
|
||||||
public class MuteData extends UserData {
|
public class MuteData extends DisciplineData {
|
||||||
private int muteLength;
|
private int muteLength;
|
||||||
private String muteReason;
|
|
||||||
|
|
||||||
public MuteData() {}
|
public MuteData() {}
|
||||||
|
|
||||||
public MuteData(long userId, String userName, Date date, Time time, int muteLength, String muteReason, String modName, long modId, String serverName, long serverId) {
|
public MuteData(long userId, String userName, Date date, Time time, String reason, int muteLength, String modName, long modId, String serverName, long serverId) {
|
||||||
super(userId, userName, date, time, modName, modId, serverName, serverId);
|
super(userId, userName, date, time, reason, modName, modId, serverName, serverId);
|
||||||
this.muteLength = muteLength;
|
this.muteLength = muteLength;
|
||||||
this.muteReason = muteReason;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMuteLength(int muteLength) {
|
public void setMuteLength(int muteLength) {
|
||||||
@ -22,12 +20,4 @@ public class MuteData extends UserData {
|
|||||||
public int getMuteLength() {
|
public int getMuteLength() {
|
||||||
return muteLength;
|
return muteLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMuteReason(String muteReason) {
|
|
||||||
this.muteReason = muteReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMuteReason() {
|
|
||||||
return muteReason;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,41 +3,11 @@ package net.nevet5gi.buzzbot.objects;
|
|||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.sql.Time;
|
import java.sql.Time;
|
||||||
|
|
||||||
public class WarnData extends UserData {
|
public class WarnData extends DisciplineData {
|
||||||
private boolean banType;
|
|
||||||
private int banLength;
|
|
||||||
private String banReason;
|
|
||||||
|
|
||||||
public WarnData() {}
|
public WarnData() {}
|
||||||
|
|
||||||
public WarnData(long userId, String userName, Date date, Time time, boolean banType, int banLength, String banReason, String modName, long modId, String serverName, long serverId) {
|
public WarnData(long userId, String userName, Date date, Time time, String reason, String modName, long modId, String serverName, long serverId) {
|
||||||
super(userId, userName, date, time, modName, modId, serverName, serverId);
|
super(userId, userName, date, time, reason, modName, modId, serverName, serverId);
|
||||||
this.banType = banType;
|
|
||||||
this.banLength = banLength;
|
|
||||||
this.banReason = banReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBanType(boolean banType) {
|
|
||||||
this.banType = banType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getBanType() {
|
|
||||||
return banType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBanLength(int banLength) {
|
|
||||||
this.banLength = banLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBanLength() {
|
|
||||||
return banLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBanReason(String banReason) {
|
|
||||||
this.banReason = banReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBanReason() {
|
|
||||||
return banReason;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
src/main/java/net/nevet5gi/buzzbot/util/GuildUtils.java
Normal file
19
src/main/java/net/nevet5gi/buzzbot/util/GuildUtils.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package net.nevet5gi.buzzbot.util;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.nevet5gi.buzzbot.database.SqlDB;
|
||||||
|
|
||||||
|
public class GuildUtils {
|
||||||
|
|
||||||
|
public static void loadGroups() {
|
||||||
|
SqlDB sql = new SqlDB();
|
||||||
|
|
||||||
|
sql.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getTable(Guild guild) {
|
||||||
|
guild.getIdLong();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,14 +1,12 @@
|
|||||||
package net.nevet5gi.buzzbot.util;
|
package net.nevet5gi.buzzbot.util;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import net.nevet5gi.buzzbot.objects.DisciplineData;
|
||||||
import net.nevet5gi.buzzbot.objects.UserData;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class JsonUtils <T extends UserData> {
|
public class JsonUtils <T extends DisciplineData> {
|
||||||
T object;
|
T object;
|
||||||
|
|
||||||
// public void createJson(T object) {
|
// public void createJson(T object) {
|
||||||
|
Loading…
Reference in New Issue
Block a user