Compare commits
No commits in common. "d8a43381d259ca8bc7da63562eb1086d9a509a30" and "f82a8988f9da5424cbda3ce7059e67d81d8ba66f" have entirely different histories.
d8a43381d2
...
f82a8988f9
@ -30,7 +30,6 @@ public class Bot {
|
|||||||
.build();
|
.build();
|
||||||
CommandManager.registerSlashCommands();
|
CommandManager.registerSlashCommands();
|
||||||
getActivity();
|
getActivity();
|
||||||
LOGGER.info("BuzzBot finished loading!");
|
|
||||||
} catch (LoginException e) {
|
} catch (LoginException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,16 @@ public class Test {
|
|||||||
private static JDA jda;
|
private static JDA jda;
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
initJda();
|
|
||||||
|
|
||||||
jda.retrieveUserById(712116155388526693L).queue(user -> { System.out.println(Integer.parseInt(user.getDiscriminator())); });
|
SqlDB sql = new SqlDB();
|
||||||
|
GuildData guild = new GuildData();
|
||||||
|
|
||||||
|
guild.setName("DevHQ");
|
||||||
|
guild.setId(824071914673668138L);
|
||||||
|
guild.setGroup("developer");
|
||||||
|
guild.setProfanityLevel(3);
|
||||||
|
|
||||||
|
sql.addGuild(guild);
|
||||||
|
|
||||||
//sqlTest();
|
//sqlTest();
|
||||||
}
|
}
|
||||||
@ -45,7 +51,7 @@ 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", 3866, Date.valueOf(LocalDate.now()), Time.valueOf(LocalTime.now()), true, 0, "Reason", "test3", 865368792980914186L, "DevHQ", 824071914673668138L);
|
||||||
db.insertBan(ban, "masterbanlist");
|
db.insertBan(ban, "masterbanlist");
|
||||||
|
|
||||||
SqlDB db2 = new SqlDB();
|
SqlDB db2 = new SqlDB();
|
||||||
|
@ -3,7 +3,6 @@ package net.nevet5gi.buzzbot.commands;
|
|||||||
import net.nevet5gi.buzzbot.Bot;
|
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.database.SqlDB;
|
|
||||||
import net.nevet5gi.buzzbot.objects.BanData;
|
import net.nevet5gi.buzzbot.objects.BanData;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -70,13 +69,12 @@ public class BanCmd implements ICommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bot.jda.retrieveUserById(ban.getUserId()).queue(user -> { ban.setUserName(user.getName()); });
|
Bot.jda.retrieveUserById(ban.getUserId()).queue(user -> { ban.setUserName(user.getName()); });
|
||||||
|
Bot.jda.retrieveUserById(ban.getUserId()).queue(user -> { ban.setUserDiscriminator(Integer.parseInt(user.getDiscriminator())); });
|
||||||
ban.setModId(ctx.getMessage().getAuthor().getIdLong());
|
ban.setModId(ctx.getMessage().getAuthor().getIdLong());
|
||||||
ban.setModName(ctx.getMessage().getAuthor().getName());
|
ban.setModName(ctx.getMessage().getAuthor().getName());
|
||||||
ban.setServerId(ctx.getGuild().getIdLong());
|
ban.setServerId(ctx.getGuild().getIdLong());
|
||||||
ban.setServerName(ctx.getGuild().getName());
|
ban.setServerName(ctx.getGuild().getName());
|
||||||
|
|
||||||
SqlDB db = new SqlDB();
|
|
||||||
db.insertBan(ban, "master_ban_list");
|
|
||||||
|
|
||||||
//ctx.getEvent().getGuild().ban(cmdf, 1 , "").submit();
|
//ctx.getEvent().getGuild().ban(cmdf, 1 , "").submit();
|
||||||
//ctx.getMessage().reply("yes ban");
|
//ctx.getMessage().reply("yes ban");
|
||||||
|
@ -23,7 +23,7 @@ public class PandaCmd implements ICommand {
|
|||||||
EmbedBuilder eb = new EmbedBuilder();
|
EmbedBuilder eb = new EmbedBuilder();
|
||||||
ctx.getChannel().sendTyping().queue();
|
ctx.getChannel().sendTyping().queue();
|
||||||
eb.setImage(url.replace("\"",""));
|
eb.setImage(url.replace("\"",""));
|
||||||
ctx.getChannel().sendMessageEmbeds(eb.build()).queue();
|
ctx.getChannel().sendMessage(eb.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.nevet5gi.buzzbot.commands.utils;
|
package net.nevet5gi.buzzbot.commands.utils;
|
||||||
|
|
||||||
import me.duncte123.botcommons.commands.ICommandContext;
|
import me.duncte123.botcommons.commands.ICommandContext;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
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;
|
||||||
|
|
||||||
@ -21,6 +22,11 @@ public class CommandContext implements ICommandContext {
|
|||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Guild getGuild() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuildMessageReceivedEvent getEvent() {
|
public GuildMessageReceivedEvent getEvent() {
|
||||||
return this.event;
|
return this.event;
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
package net.nevet5gi.buzzbot.commands.utils;public class ICommandContext {
|
|
||||||
}
|
|
@ -9,6 +9,8 @@ import net.nevet5gi.buzzbot.objects.WarnData;
|
|||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
|
||||||
public class SqlDB {
|
public class SqlDB {
|
||||||
|
//TODO Make this a two way class for reading and writing from db
|
||||||
|
|
||||||
private Connection connect;
|
private Connection connect;
|
||||||
private Statement statement;
|
private Statement statement;
|
||||||
private ResultSet resultSet;
|
private ResultSet resultSet;
|
||||||
@ -25,7 +27,7 @@ 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() + ")");
|
statement.executeUpdate("INSERT INTO " + table + " VALUES (default, " + ban.getUserId() + ", '" + ban.getUserName() + "', '" + ban.getUserDiscriminator() + "', '" + ban.getDate() + "', '" + ban.getTime() + "', " + ban.getBanType() + ", " + ban.getBanLength() + ", '" + ban.getBanReason() + "', '" + ban.getModName() + "', " + ban.getModId() + ", '" + ban.getServerName() + "', " + ban.getServerId() + ")");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -35,7 +37,7 @@ 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 " + table + " VALUES (default, " + mute.getUserId() + ", '" + mute.getUserName() + "', '" + mute.getUserDiscriminator() + "', '" + mute.getDate() + "', '" + mute.getTime() + "', " + mute.getMuteLength() + ", '" + mute.getMuteReason() + "', '" + mute.getModName() + "', " + mute.getModId() + ", '" + mute.getServerName() + "', " + mute.getServerId() + ")");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -43,7 +45,7 @@ public class SqlDB {
|
|||||||
|
|
||||||
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 " + table + " VALUES (default, " + warn.getUserId() + ", '" + warn.getUserName() + "', '" + warn.getUserDiscriminator() + "', '" + warn.getDate() + "', '" + warn.getTime() + "', " + warn.getBanType() + ", " + warn.getBanLength() + ", '" + warn.getBanReason() + "', '" + warn.getModName() + "', " + warn.getModId() + ", '" + warn.getServerName() + "', " + warn.getServerId() + ")");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -58,17 +60,18 @@ public class SqlDB {
|
|||||||
resultSet = statement.executeQuery("SELECT * FROM " + table + " WHERE userId=" + userId);
|
resultSet = statement.executeQuery("SELECT * FROM " + table + " WHERE userId=" + userId);
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
ban.setUserId(resultSet.getLong("user_id"));
|
ban.setUserId(resultSet.getLong("userid"));
|
||||||
ban.setUserName(resultSet.getString("user_name"));
|
ban.setUserName(resultSet.getString("username"));
|
||||||
ban.setDate(resultSet.getDate("ban_date"));
|
ban.setUserDiscriminator(resultSet.getInt("userdiscriminator"));
|
||||||
ban.setTime(resultSet.getTime("ban_time"));
|
ban.setDate(resultSet.getDate("bandate"));
|
||||||
ban.setBanType(resultSet.getBoolean("ban_type"));
|
ban.setTime(resultSet.getTime("bantime"));
|
||||||
ban.setBanLength(resultSet.getInt("ban_length"));
|
ban.setBanType(resultSet.getBoolean("bantype"));
|
||||||
ban.setBanReason(resultSet.getString("ban_reason"));
|
ban.setBanLength(resultSet.getInt("banlength"));
|
||||||
ban.setModName(resultSet.getString("mod_name"));
|
ban.setBanReason(resultSet.getString("banreason"));
|
||||||
ban.setModId(resultSet.getLong("mod_id"));
|
ban.setModName(resultSet.getString("modname"));
|
||||||
ban.setServerName(resultSet.getString("server_name"));
|
ban.setModId(resultSet.getLong("modid"));
|
||||||
ban.setServerId(resultSet.getLong("server_id"));
|
ban.setServerName(resultSet.getString("servername"));
|
||||||
|
ban.setServerId(resultSet.getLong("serverid"));
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -86,8 +89,9 @@ public class SqlDB {
|
|||||||
resultSet = statement.executeQuery("SELECT * FROM " + table + "WHERE userId=" + userId);
|
resultSet = statement.executeQuery("SELECT * FROM " + table + "WHERE userId=" + userId);
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
mute.setUserId(resultSet.getLong("user_id"));
|
mute.setUserId(resultSet.getLong("userid"));
|
||||||
mute.setUserName(resultSet.getString("user_name"));
|
mute.setUserName(resultSet.getString("username"));
|
||||||
|
mute.setUserDiscriminator(resultSet.getInt("userdiscriminator"));
|
||||||
//mute.setDate(resultSet.);
|
//mute.setDate(resultSet.);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -104,8 +108,9 @@ public class SqlDB {
|
|||||||
resultSet = statement.executeQuery("SELECT * FROM " + table + "WHERE userId=" + userId);
|
resultSet = statement.executeQuery("SELECT * FROM " + table + "WHERE userId=" + userId);
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
warn.setUserId(resultSet.getLong("user_id"));
|
warn.setUserId(resultSet.getLong("userid"));
|
||||||
warn.setUserName(resultSet.getString("user_name"));
|
warn.setUserName(resultSet.getString("username"));
|
||||||
|
warn.setUserDiscriminator(resultSet.getInt("userdiscriminator"));
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -116,7 +121,7 @@ public class SqlDB {
|
|||||||
|
|
||||||
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() + ")");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ public class BanData extends UserData {
|
|||||||
|
|
||||||
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, int userDiscriminator, Date date, Time time, boolean banType, int banLength, String banReason, String modName, long modId, String serverName, long serverId) {
|
||||||
super(userId, userName, date, time, modName, modId, serverName, serverId);
|
super(userId, userName, userDiscriminator, date, time, modName, modId, serverName, serverId);
|
||||||
this.banType = banType;
|
this.banType = banType;
|
||||||
this.banLength = banLength;
|
this.banLength = banLength;
|
||||||
this.banReason = banReason;
|
this.banReason = banReason;
|
||||||
|
@ -9,8 +9,8 @@ public class MuteData extends UserData {
|
|||||||
|
|
||||||
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, int userDiscriminator, Date date, Time time, int muteLength, String muteReason, String modName, long modId, String serverName, long serverId) {
|
||||||
super(userId, userName, date, time, modName, modId, serverName, serverId);
|
super(userId, userName, userDiscriminator, date, time, modName, modId, serverName, serverId);
|
||||||
this.muteLength = muteLength;
|
this.muteLength = muteLength;
|
||||||
this.muteReason = muteReason;
|
this.muteReason = muteReason;
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,10 @@ import java.time.LocalDate;
|
|||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
|
||||||
public class UserData {
|
public class UserData {
|
||||||
|
private String name = "users";
|
||||||
private long userId;
|
private long userId;
|
||||||
private String userName;
|
private String userName;
|
||||||
|
private int userDiscriminator;
|
||||||
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 modName;
|
private String modName;
|
||||||
@ -17,9 +19,10 @@ public class UserData {
|
|||||||
|
|
||||||
public UserData() {}
|
public UserData() {}
|
||||||
|
|
||||||
public UserData(long userId, String userName, Date date, Time time, String modName, long modId, String serverName, long serverId) {
|
public UserData(long userId, String userName, int userDiscriminator, Date date, Time time, String modName, long modId, String serverName, long serverId) {
|
||||||
this.setUserId(userId);
|
this.setUserId(userId);
|
||||||
this.setUserName(userName);
|
this.setUserName(userName);
|
||||||
|
this.setUserDiscriminator(userDiscriminator);
|
||||||
this.setDate(date);
|
this.setDate(date);
|
||||||
this.setTime(time);
|
this.setTime(time);
|
||||||
this.setModName(modName);
|
this.setModName(modName);
|
||||||
@ -28,6 +31,10 @@ public class UserData {
|
|||||||
this.setServerId(serverId);
|
this.setServerId(serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUserId(long userId) {
|
public void setUserId(long userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
@ -44,6 +51,14 @@ public class UserData {
|
|||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUserDiscriminator(int userDiscriminator) {
|
||||||
|
this.userDiscriminator = userDiscriminator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserDiscriminator() {
|
||||||
|
return userDiscriminator;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDate(Date date) {
|
public void setDate(Date date) {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ public class WarnData extends UserData {
|
|||||||
|
|
||||||
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, int userDiscriminator, Date date, Time time, boolean banType, int banLength, String banReason, String modName, long modId, String serverName, long serverId) {
|
||||||
super(userId, userName, date, time, modName, modId, serverName, serverId);
|
super(userId, userName, userDiscriminator, date, time, modName, modId, serverName, serverId);
|
||||||
this.banType = banType;
|
this.banType = banType;
|
||||||
this.banLength = banLength;
|
this.banLength = banLength;
|
||||||
this.banReason = banReason;
|
this.banReason = banReason;
|
||||||
|
@ -11,20 +11,20 @@ import java.util.ArrayList;
|
|||||||
public class JsonUtils <T extends UserData> {
|
public class JsonUtils <T extends UserData> {
|
||||||
T object;
|
T object;
|
||||||
|
|
||||||
// public void createJson(T object) {
|
public void createJson(T object) {
|
||||||
// try {
|
try {
|
||||||
// Writer writer = new FileWriter("./" + object.getName() + ".json");
|
Writer writer = new FileWriter("./" + object.getName() + ".json");
|
||||||
//
|
|
||||||
// GsonBuilder builder = new GsonBuilder();
|
GsonBuilder builder = new GsonBuilder();
|
||||||
// builder.setPrettyPrinting();
|
builder.setPrettyPrinting();
|
||||||
// Gson gson = builder.create();
|
Gson gson = builder.create();
|
||||||
// String jsonString = gson.toJson(object);
|
String jsonString = gson.toJson(object);
|
||||||
// writer.write(jsonString);
|
writer.write(jsonString);
|
||||||
// writer.close();
|
writer.close();
|
||||||
// } catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
public T loadJson(String jsonFileName) {
|
public T loadJson(String jsonFileName) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user