Merge pull request #345 from BigBotNetwork/greg-dev

Release v1.0.0
This commit is contained in:
Skidder 2020-01-24 17:49:09 +01:00 committed by GitHub
commit 6060f53e00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
95 changed files with 2961 additions and 1583 deletions

View file

@ -69,7 +69,7 @@ further defined and clarified by project maintainers.
### Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team on [Discord](https://discordapp.com/invite/Vf4zCYn). All
reported by contacting the project team on [Discord](https://discordapp.com/invite/58My2dM). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.

View file

@ -27,7 +27,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.1.0_99</version>
<version>4.1.1_101</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
@ -52,7 +52,7 @@
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.101</version>
<version>1.103</version>
</dependency>
<dependency>
<groupId>com.sedmelluq</groupId>

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder;
import com.bbn.hadder.audio.AudioManager;
@ -103,7 +119,8 @@ public class Hadder {
new BlacklistCommand(),
new PauseCommand(),
new LoopCommand(),
new BassCommand()), config, helpCommand);
new BassCommand(),
new EchoCommand()), config, helpCommand);
builder.addEventListeners(
new MentionListener(rethink),

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder;
import com.bbn.hadder.core.Config;
@ -5,12 +21,11 @@ import com.rethinkdb.RethinkDB;
import com.rethinkdb.gen.exc.ReqlOpFailedError;
import com.rethinkdb.net.Connection;
import org.json.JSONArray;
import org.json.JSONObject;
import java.lang.reflect.Field;
import java.util.NoSuchElementException;
/*
* @author Skidder / GregTCLTK
*/
public class Rethink {
private RethinkDB r = RethinkDB.r;
@ -62,28 +77,13 @@ public class Rethink {
else return null;
}
public void update(String table, String where, String what, String value) {
try {
r.table(table).get(where).update(r.hashMap(what, value)).run(conn);
} catch (ClassCastException e) {
e.printStackTrace();
}
public Object getByID(String table, String wherevalue, String column) {
return r.table(table).get(wherevalue).getField(column).run(conn);
}
public void update(String table, String where, String what, int value) {
try {
r.table(table).get(where).update(r.hashMap(what, value)).run(conn);
} catch (ClassCastException e) {
e.printStackTrace();
}
}
public void update(String table, String where, String what, boolean value) {
try {
r.table(table).get(where).update(r.hashMap(what, value)).run(conn);
} catch (ClassCastException e) {
e.printStackTrace();
}
public JSONObject getObjectByID(String table, String id) {
String response = r.table(table).get(id).toJson().run(conn);
return new JSONObject(response);
}
public void insert(String table, Object object) {
@ -107,7 +107,7 @@ public class Rethink {
try {
r.tableCreate("server").run(conn);
} catch (ReqlOpFailedError e) {
System.out.println(e.getMessage());
System.out.println(e.getMessage());
}
try {
r.tableCreate("user").run(conn);
@ -121,22 +121,6 @@ public class Rethink {
}
}
public void setUserPrefix(String prefix, String user_id) {
this.update("user", user_id, "prefix", prefix);
}
public String getUserPrefix(String id) {
return (String) this.get("user", "id", id, "prefix");
}
public void setGuildPrefix(String prefix, String guild_id) {
this.update("server", guild_id, "prefix", prefix);
}
public String getGuildPrefix(String id) {
return (String) this.get("server", "id", id, "prefix");
}
public void insertGuild(String id) {
this.insert("server", r
.hashMap("id", id)
@ -157,87 +141,54 @@ public class Rethink {
.with("blacklisted", "none"));
}
public void setBlackListed(String id, String commands) {
this.update("user", id, "blacklisted", commands);
}
public String getBlackListed(String id) {
return (String) this.get("user", "id", id, "blacklisted");
}
public void setNeededStars(String stars, String guild_id) {
this.update("server", guild_id, "neededstars", stars);
}
public String getNeededStars(String guild_id) {
return (String) this.get("server", "id", guild_id, "neededstars");
}
public void setStarboardChannel(String guild_id, String channel_id) {
this.update("server", guild_id, "starboard", channel_id);
}
public String getStarboardChannel(String guild_id) {
return (String) this.get("server", "id", guild_id, "starboard");
}
// TODO
public boolean hasStarboardChannel(String guild_id) {
return !this.get("server", "id", guild_id, "starboard").equals("");
return !this.getByID("server", guild_id, "starboard").equals("");
}
// TODO
public void insertStarboardMessage(String message_id, String guild_id, String starboard_message_id) {
this.insert("stars", r.hashMap("id", message_id).with("guild", guild_id).with("starboardmsg", starboard_message_id));
}
// TODO
public String getStarboardMessage(String message_id) {
return (String) this.get("stars", "id", message_id, "starboardmsg");
return (String) this.getByID("stars", message_id, "starboardmsg");
}
// TODO
public void removeStarboardMessage(String message_id) {
this.remove("stars", "id", message_id);
}
// TODO
public boolean hasStarboardMessage(String message_id) {
return this.get("stars", "id", message_id, "guild") != null;
return this.getByID("stars", message_id, "guild") != null;
}
public void updateRules(String guild_id, String message_id, String role_id, String accept_emote, String decline_emote) {
this.update("server", guild_id, "message_id", message_id);
this.update("server", guild_id, "role_id", role_id);
this.update("server", guild_id, "accept_emote", accept_emote);
this.update("server", guild_id, "decline_emote", decline_emote);
public void pushServer(RethinkServer server) {
JSONObject object = new JSONObject();
for (Field field : server.getClass().getDeclaredFields()) {
if (!field.getName().equals("rethink")) {
try {
object.put(field.getName(), field.get(server));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
r.table("server").get(server.getId()).update(object).run(conn);
}
public String getRulesMID(String guild_id) {
return (String) this.get("server", "id", guild_id, "message_id");
}
public String getRulesRID(String guild_id) {
return (String) this.get("server", "id", guild_id, "role_id");
}
public String getRulesAEmote(String guild_id) {
return (String) this.get("server", "id", guild_id, "accept_emote");
}
public String getRulesDEmote(String guild_id) {
return (String) this.get("server", "id", guild_id, "decline_emote");
}
public void setInviteDetection(String guild_id, boolean b) {
this.update("server", guild_id, "invite_detect", b);
}
public Boolean getInviteDetection(String guild_id) {
return (Boolean) this.get("server", "id", guild_id, "invite_detect");
}
public void setLanguage(String user_id, String language) {
this.update("user", user_id, "language", language);
}
public String getLanguage(String user_id) {
return (String) this.get("user", "id", user_id, "language");
public void pushUser(RethinkUser user) {
JSONObject object = new JSONObject();
for (Field field : user.getClass().getDeclaredFields()) {
if (!field.getName().equals("rethink")) {
try {
object.put(field.getName(), field.get(user));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
r.table("user").get(user.getId()).update(object).run(conn);
}
}

View file

@ -0,0 +1,129 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder;
import org.json.JSONObject;
import java.lang.reflect.Field;
public class RethinkServer {
private Rethink rethink;
private String accept_emote = "";
private String decline_emote = "";
private String id;
private boolean invite_detect = false;
private String message_id = "";
private String neededstars = "3";
private String prefix = "h.";
private String role_id = "";
private String starboard = "";
public RethinkServer(JSONObject object, Rethink rethink) {
for (Field field : this.getClass().getDeclaredFields()) {
if (!field.getName().equals("rethink")) {
try {
if (object.has(field.getName()))
field.set(this, object.get(field.getName()));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
this.rethink = rethink;
}
public String getAcceptEmote() {
return accept_emote;
}
public void setAcceptEmote(String accept_emote) {
this.accept_emote = accept_emote;
}
public String getDeclineEmote() {
return decline_emote;
}
public void setDeclineEmote(String decline_emote) {
this.decline_emote = decline_emote;
}
public String getId() {
return id;
}
public boolean isInviteDetect() {
return invite_detect;
}
public void setInviteDetect(boolean invite_detect) {
this.invite_detect = invite_detect;
}
public String getMessageID() {
return message_id;
}
public void setMessageID(String message_id) {
this.message_id = message_id;
}
public String getNeededStars() {
return neededstars;
}
public void setNeededStars(String neededstars) {
this.neededstars = neededstars;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getRoleID() {
return role_id;
}
public void setRoleID(String role_id) {
this.role_id = role_id;
}
public String getStarboard() {
return starboard;
}
public void setStarboard(String starboard) {
this.starboard = starboard;
}
public void updateRules(String message_id, String role_id, String accept_emote, String decline_emote) {
this.setMessageID(message_id);
this.setRoleID(role_id);
this.setAcceptEmote(accept_emote);
this.setDeclineEmote(decline_emote);
}
public void push() {
rethink.pushServer(this);
}
}

View file

@ -0,0 +1,89 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder;
import org.json.JSONObject;
import java.lang.reflect.Field;
public class RethinkUser {
private Rethink rethink;
private String id;
private String prefix = "h.";
private String language = "en";
private String blacklisted = "none";
public RethinkUser(JSONObject object, Rethink rethink) {
for (Field field : this.getClass().getDeclaredFields()) {
if (!field.getName().equals("rethink")) {
try {
if (object.has(field.getName()))
field.set(this, object.getString(field.getName()));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
this.rethink = rethink;
}
public RethinkUser(String id) {
this.id = id;
}
public Rethink getRethink() {
return rethink;
}
public void setRethink(Rethink rethink) {
this.rethink = rethink;
}
public String getId() {
return id;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getBlacklisted() {
return blacklisted;
}
public void setBlacklisted(String blacklisted) {
this.blacklisted = blacklisted;
}
public void push() {
rethink.pushUser(this);
}
}

View file

@ -1,12 +1,24 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.audio;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import net.dv8tion.jda.api.entities.Member;
/**
* @author Skidder / GregTCLTK
*/
public class AudioInfo {
private final AudioTrack track;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.audio;
import com.bbn.hadder.commands.CommandEvent;
@ -19,10 +35,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author Skidder / GregTCLTK
*/
public class AudioManager {
public Map<String, Map.Entry<AudioPlayer, TrackManager>> players = new HashMap<>();

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.audio;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
@ -7,10 +23,6 @@ import net.dv8tion.jda.api.audio.AudioSendHandler;
import javax.annotation.Nullable;
import java.nio.ByteBuffer;
/**
* @author Skidder / GregTCLTK
*/
public class AudioPlayerSendHandler implements AudioSendHandler {
private final AudioPlayer audioPlayer;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.audio;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
@ -11,15 +27,12 @@ import net.dv8tion.jda.api.entities.VoiceChannel;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
/**
* @author Skidder / GregTCLTK
*/
public class TrackManager extends AudioEventAdapter {
private final AudioPlayer player;
private final AudioManager manager;
private final Queue<AudioInfo> queue;
private AudioTrack lastTrack;
private boolean loop = false;
public TrackManager(AudioPlayer player, AudioManager manager) {
@ -51,8 +64,9 @@ public class TrackManager extends AudioEventAdapter {
@Override
public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
Guild g = queue.poll().getAuthor().getGuild();
this.lastTrack = track;
if (loop) {
player.playTrack(track.makeClone());
player.playTrack(lastTrack.makeClone());
} else if (queue.isEmpty()) {
manager.players.remove(g.getId());
manager.getPlayer(g).destroy();

View file

@ -1,11 +1,23 @@
package com.bbn.hadder.commands;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands;
public interface Command {
void executed(String[] args, CommandEvent event);
void executed(String[] args, CommandEvent e);
String[] labels();

View file

@ -1,6 +1,24 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer;
import com.bbn.hadder.RethinkUser;
import com.bbn.hadder.audio.AudioManager;
import com.bbn.hadder.commands.general.HelpCommand;
import com.bbn.hadder.core.CommandHandler;
@ -22,8 +40,13 @@ public class CommandEvent extends MessageReceivedEvent {
private MessageEditor messageEditor;
private EventWaiter eventWaiter;
private AudioManager audioManager;
private RethinkUser rethinkUser;
private RethinkServer rethinkServer;
public CommandEvent(@Nonnull JDA api, long responseNumber, @Nonnull Message message, Rethink rethink, Config config, CommandHandler commandHandler, HelpCommand helpCommand, MessageEditor messageEditor, EventWaiter eventWaiter, AudioManager audioManager) {
public CommandEvent(@Nonnull JDA api, long responseNumber, @Nonnull Message message, Rethink rethink, Config config,
CommandHandler commandHandler, HelpCommand helpCommand, MessageEditor messageEditor,
EventWaiter eventWaiter, AudioManager audioManager, RethinkUser rethinkUser,
RethinkServer rethinkServer) {
super(api, responseNumber, message);
this.rethink = rethink;
this.config = config;
@ -32,17 +55,8 @@ public class CommandEvent extends MessageReceivedEvent {
this.messageEditor = messageEditor;
this.eventWaiter = eventWaiter;
this.audioManager = audioManager;
}
public CommandEvent(MessageReceivedEvent event, Rethink rethink, Config config, CommandHandler commandHandler, HelpCommand helpCommand, MessageEditor messageEditor, EventWaiter eventWaiter, AudioManager audioManager) {
super(event.getJDA(), event.getResponseNumber(), event.getMessage());
this.rethink = rethink;
this.config = config;
this.commandHandler = commandHandler;
this.helpCommand = helpCommand;
this.messageEditor = messageEditor;
this.eventWaiter = eventWaiter;
this.audioManager = audioManager;
this.rethinkUser = rethinkUser;
this.rethinkServer = rethinkServer;
}
public Rethink getRethink() {
@ -72,4 +86,12 @@ public class CommandEvent extends MessageReceivedEvent {
public AudioManager getAudioManager() {
return audioManager;
}
public RethinkServer getRethinkServer() {
return rethinkServer;
}
public RethinkUser getRethinkUser() {
return rethinkUser;
}
}

View file

@ -1,56 +1,101 @@
package com.bbn.hadder.commands.fun;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.fun;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONException;
import org.json.JSONObject;
public class AvatarCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length == 0) {
Member member = event.getMember();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
User u = e.getAuthor();
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.fun.avatar.success.title",
member.getUser().getAsTag(),
u.getAsTag(),
"",
"")
.setImage(member.getUser().getAvatarUrl())
.setFooter(member.getUser().getAsTag())
.setImage(u.getAvatarUrl())
.setFooter(u.getAsTag())
.build()).queue();
} else if (event.getMessage().getMentionedMembers().size() == 1) {
Member member = event.getMessage().getMentionedMembers().get(0);
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
} else if (e.getMessage().getMentionedUsers().size() == 1) {
User u = e.getMessage().getMentionedUsers().get(0);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.fun.avatar.success.title",
member.getUser().getAsTag(),
u.getAsTag(),
"",
"")
.setImage(member.getUser().getAvatarUrl())
.setFooter(member.getUser().getAsTag())
.build()).queue();
} else if (args[0].length() == 18){
Member member = event.getGuild().getMemberById(args[0]);
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.fun.avatar.success.title",
member.getUser().getAsTag(),
"",
"")
.setImage(member.getUser().getAvatarUrl())
.setFooter(member.getUser().getAsTag())
.setImage(u.getAvatarUrl())
.setFooter(u.getAsTag())
.build()).queue();
} else if (args[0].length() == 18) {
try {
User u = e.getJDA().getUserById(args[0]);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.fun.avatar.success.title",
u.getAsTag(),
"",
"")
.setImage(u.getAvatarUrl())
.setFooter(u.getAsTag())
.build()).queue();
} catch (NullPointerException ignore) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url("https://canary.discordapp.com/api/v6/users/" + args[0]).addHeader("Authorization", "Bot " + e.getConfig().getBotToken()).build();
try {
Response response = client.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
String url = "https://cdn.discordapp.com/avatars/" + args[0] + "/" + json.getString("avatar") + ".png";
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.fun.avatar.success.title",
json.getString("username") + "#" + json.getString("discriminator"),
"",
"")
.setImage(url)
.setFooter(json.getString("username") + "#" + json.getString("discriminator"))
.build()).queue();
} catch (JSONException ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.fun.avatar.error.title",
"commands.fun.avatar.error.description"
).build()).queue();
} catch (Exception ex) {
ex.printStackTrace();
}
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.fun;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.fun;
import club.minnced.discord.webhook.WebhookClient;
import club.minnced.discord.webhook.WebhookClientBuilder;
import com.bbn.hadder.commands.Command;
@ -24,13 +36,13 @@ import java.util.concurrent.TimeUnit;
public class ClydeCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
if (event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_WEBHOOKS)) {
TextChannel channel = event.getMessage().getTextChannel();
String content = event.getMessage().getContentRaw().replace(event.getRethink().getGuildPrefix(event.getGuild().getId()), "").replace(event.getRethink().getUserPrefix(event.getAuthor().getId()), "").replace("clyde", "");
if (e.getGuild().getSelfMember().hasPermission(Permission.MANAGE_WEBHOOKS)) {
TextChannel channel = e.getMessage().getTextChannel();
String content = e.getMessage().getContentRaw().replace(e.getRethinkServer().getPrefix(), "").replace(e.getRethinkUser().getPrefix(), "").replace("clyde", "");
Webhook webhook = channel.createWebhook(event.getConfig().getClydeName()).complete();
Webhook webhook = channel.createWebhook(e.getConfig().getClydeName()).complete();
try {
InputStream s = new URL("https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png").openStream();
webhook.getManager().setAvatar(Icon.from(s)).queue();
@ -40,24 +52,24 @@ public class ClydeCommand implements Command {
WebhookClient client = builder.build();
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
client.send(content);
} catch (Exception e) {
e.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
webhook.delete().queue();
event.getMessage().delete().queue();
e.getMessage().delete().queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else event.getHelpCommand().sendHelp(this, event);
} else e.getHelpCommand().sendHelp(this, e);
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.fun;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.fun;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
@ -18,7 +30,7 @@ import java.util.Random;
public class GifCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
StringBuilder query = new StringBuilder();
for (String arg : args) {
@ -27,7 +39,7 @@ public class GifCommand implements Command {
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url("http://api.giphy.com/v1/gifs/search?q=" + query + "&api_key=" + event.getConfig().getGiphyToken()).build();
Request request = new Request.Builder().url("http://api.giphy.com/v1/gifs/search?q=" + query + "&api_key=" + e.getConfig().getGiphyToken()).build();
try {
Random rand = new Random();
Response response = client.newCall(request).execute();
@ -35,15 +47,15 @@ public class GifCommand implements Command {
JSONArray array = json.getJSONArray("data");
int gifIndex = rand.nextInt(array.length());
String url = array.getJSONObject(gifIndex).get("url").toString();
event.getTextChannel().sendMessage(url).queue();
} catch (Exception e) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(url).queue();
} catch (Exception ignore) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"error",
"commands.fun.gif.error.description").build()).queue();
}
} else event.getHelpCommand().sendHelp(this, event);
} else e.getHelpCommand().sendHelp(this, e);
}
@Override

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.fun;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.fun;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
@ -18,7 +30,7 @@ import java.io.IOException;
public class MemeCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url("https://meme-api.herokuapp.com/gimme").build();
@ -27,16 +39,15 @@ public class MemeCommand implements Command {
Response response = client.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
String url = json.getString("url");
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.fun.meme.success.title", "")
.setImage(url)
.setAuthor("Subreddit: " + json.getString("subreddit"))
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
} catch (IOException ignore) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"error",
"commands.fun.meme.api.error")

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.general;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.general;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
@ -11,13 +23,13 @@ import com.bbn.hadder.utils.MessageEditor;
public class AboutCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.general.about.success.title",
"commands.general.about.success.description")
.addField(event.getMessageEditor().getTerm("commands.general.about.success.field.one.title"), event.getMessageEditor().getTerm("commands.general.about.success.field.one.description", "(https://donatebot.io/checkout/448554629282922527?buyer=" + event.getAuthor().getId() + "). :smiley:", ""), true)
.addField(e.getMessageEditor().getTerm("commands.general.about.success.field.one.title"), e.getMessageEditor().getTerm("commands.general.about.success.field.one.description", "(https://donatebot.io/checkout/448554629282922527?buyer=" + e.getAuthor().getId() + "). :smiley:", ""), true)
.setThumbnail("https://bigbotnetwork.com/images/Hadder.png")
.build()).queue();
}

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.general;
import com.bbn.hadder.commands.Command;
@ -5,37 +21,33 @@ import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.EventWaiter;
import com.bbn.hadder.utils.MessageEditor;
/*
* @author Skidder / GregTCLTK
*/
public class EqualsCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
event.getChannel().sendMessage(
event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
e.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.general.equals.string.first.request", "")
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(msgevent -> {
String firstString = msgevent.getMessage().getContentRaw();
event.getChannel().sendMessage(
event.getMessageEditor().getMessage(
new EventWaiter().newOnMessageEventWaiter(msge -> {
String firstString = msge.getMessage().getContentRaw();
e.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.general.equals.string.second.request",
"").build()).queue();
new EventWaiter().newOnMessageEventWaiter(msgevent2 -> {
String secondString = msgevent2.getMessage().getContentRaw();
event.getChannel().sendMessage(
event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle((firstString.equals(secondString)) ? event.getMessageEditor().getTerm( "commands.general.equals.string.equals.true") : event.getMessageEditor().getTerm( "commands.general.equals.string.equals.false"))
.addField(event.getMessageEditor().getTerm( "commands.general.equals.string.first"), firstString, false)
.addField(event.getMessageEditor().getTerm( "commands.general.equals.string.second"), secondString, false)
.addField(event.getMessageEditor().getTerm( "commands.general.equals.string.result"), String.valueOf(firstString.equals(secondString)), false)
new EventWaiter().newOnMessageEventWaiter(msge2 -> {
String secondString = msge2.getMessage().getContentRaw();
e.getChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle((firstString.equals(secondString)) ? e.getMessageEditor().getTerm( "commands.general.equals.string.equals.true") : e.getMessageEditor().getTerm( "commands.general.equals.string.equals.false"))
.addField(e.getMessageEditor().getTerm( "commands.general.equals.string.first"), firstString, false)
.addField(e.getMessageEditor().getTerm( "commands.general.equals.string.second"), secondString, false)
.addField(e.getMessageEditor().getTerm( "commands.general.equals.string.result"), String.valueOf(firstString.equals(secondString)), false)
.build()).queue();
}, event.getJDA(), event.getAuthor());
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
}, e.getJDA(), e.getAuthor());
}
@Override

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.general;
import com.bbn.hadder.commands.Command;
@ -13,11 +29,11 @@ import java.util.Map;
public class HelpCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_EMBED_LINKS)) {
public void executed(String[] args, CommandEvent e) {
if (e.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_EMBED_LINKS)) {
if (args.length == 0) {
HashMap<String, ArrayList<Command>> hashMap = new HashMap<>();
for (Command cmd : event.getCommandHandler().getCommandList()) {
for (Command cmd : e.getCommandHandler().getCommandList()) {
if (!hashMap.containsKey(cmd.getClass().getPackageName())) {
ArrayList<Command> cmdlist = new ArrayList<>();
cmdlist.add(cmd);
@ -28,8 +44,8 @@ public class HelpCommand implements Command {
}
EmbedBuilder eb = new EmbedBuilder();
for (Map.Entry<String, ArrayList<Command>> entry : hashMap.entrySet()) {
if (!entry.getKey().endsWith("owner") || (entry.getKey().endsWith("owner") && (event.getAuthor().getId().equals("477141528981012511") ||
event.getAuthor().getId().equals("261083609148948488")))) {
if (!entry.getKey().endsWith("owner") || (entry.getKey().endsWith("owner") && (e.getAuthor().getId().equals("477141528981012511") ||
e.getAuthor().getId().equals("261083609148948488")))) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < entry.getValue().size(); i++) {
Command cmd = entry.getValue().get(i);
@ -40,35 +56,35 @@ public class HelpCommand implements Command {
eb.addField(ps[ps.length - 1], sb.toString(), false);
}
}
event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO);
event.getChannel().sendMessage(eb.build()).queue();
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO);
e.getChannel().sendMessage(eb.build()).queue();
} else {
for (Command cmd : event.getCommandHandler().getCommandList()) {
for (Command cmd : e.getCommandHandler().getCommandList()) {
for (String label : cmd.labels()) {
if (label.equalsIgnoreCase(args[0])) {
sendHelp(cmd, event);
sendHelp(cmd, e);
}
}
}
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getTerm("commands.general.help.error.description")).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getTerm("commands.general.help.error.description")).queue();
}
}
public void sendHelp(Command cmd, CommandEvent event) {
public void sendHelp(Command cmd, CommandEvent e) {
if (!cmd.getClass().getPackageName().endsWith("owner") || (cmd.getClass().getPackageName().endsWith("owner") &&
(event.getAuthor().getId().equals("477141528981012511") || event.getAuthor().getId().equals("261083609148948488")))) {
(e.getAuthor().getId().equals("477141528981012511") || e.getAuthor().getId().equals("261083609148948488")))) {
String name = cmd.labels()[0];
StringBuilder b = new StringBuilder();
b.append(event.getMessageEditor().getTerm("commands.general.help.description")).append(" ").append(event.getMessageEditor().getTerm(cmd.description())).append("\n");
b.append(e.getMessageEditor().getTerm("commands.general.help.description")).append(" ").append(e.getMessageEditor().getTerm(cmd.description())).append("\n");
if (cmd.usage() != null) {
b.append(event.getMessageEditor().getTerm("commands.general.help.usage")).append(" ").append(event.getRethink().getGuildPrefix(event.getGuild().getId())).append(name).append(" ").append(cmd.usage()).append("\n");
b.append(e.getMessageEditor().getTerm("commands.general.help.usage")).append(" ").append(e.getRethinkServer().getPrefix()).append(name).append(" ").append(cmd.usage()).append("\n");
}
if (cmd.example() != null) {
b.append(event.getMessageEditor().getTerm("commands.general.help.example")).append(" ").append(event.getRethink().getGuildPrefix(event.getGuild().getId())).append(name).append(" ").append(cmd.example());
b.append(e.getMessageEditor().getTerm("commands.general.help.example")).append(" ").append(e.getRethinkServer().getPrefix()).append(name).append(" ").append(cmd.example());
}
event.getChannel().sendMessage(event.getMessageEditor().getMessage(
e.getChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO)
.setTitle(cmd.labels()[0])
.setDescription(b.toString())

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.general;
import com.bbn.hadder.Hadder;
@ -5,16 +21,12 @@ import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
/*
* @author Skidder / GregTCLTK
*/
public class InviteCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.general.invite.success.title",
"",

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.general;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.general;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
@ -11,8 +23,8 @@ import com.bbn.hadder.utils.MessageEditor;
public class PingCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
event.getJDA().getRestPing().queue(ping -> event.getTextChannel().sendMessage(event.getMessageEditor()
public void executed(String[] args, CommandEvent e) {
e.getJDA().getRestPing().queue(ping -> e.getTextChannel().sendMessage(e.getMessageEditor()
.getMessage(MessageEditor.MessageType.INFO)
.setTitle("Ping")
.setDescription(String.valueOf(ping))

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.misc;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.misc;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.EventWaiter;
@ -17,39 +29,39 @@ import java.io.IOException;
public class FeedbackCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.misc.feedback.title.request.title",
"commands.misc.feedback.title.request.description")
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event1 -> {
String title = event1.getMessage().getContentDisplay();
event1.getChannel().sendMessage(event.getMessageEditor().getMessage(
new EventWaiter().newOnMessageEventWaiter(e1 -> {
String title = e1.getMessage().getContentDisplay();
e1.getChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.misc.feedback.description.request.title",
"commands.misc.feedback.description.request.description")
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event2 -> {
String description = event2.getMessage().getContentDisplay();
new EventWaiter().newOnMessageEventWaiter(e2 -> {
String description = e2.getMessage().getContentDisplay();
try {
GitHub connection = GitHub.connectUsingOAuth(event.getConfig().getGitHubToken());
GitHub connection = GitHub.connectUsingOAuth(e.getConfig().getGitHubToken());
GHRepository Hadder = connection.getOrganization("BigBotNetwork").getRepository("Hadder");
GHIssue issue = Hadder.createIssue(title).body("<strong>Feedback by " + event.getAuthor().getAsTag() + "</strong><br>" + description).label("feedback").create();
GHIssue issue = Hadder.createIssue(title).body("<strong>Feedback by " + e.getAuthor().getAsTag() + "</strong><br>" + description).label("feedback").create();
issue.addLabels("feedback");
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.misc.feedback.success.title",
"")
.setDescription(issue.getHtmlUrl().toString())
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}, event.getJDA(), event.getAuthor());
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
}, e.getJDA(), e.getAuthor());
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.misc;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.misc;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
@ -18,11 +30,11 @@ import java.io.IOException;
public class GitHubCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
if (args[0].equals("link")) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.misc.github.link.title",
"")
@ -51,39 +63,39 @@ public class GitHubCommand implements Command {
if (!json.getString("blog").equals("")) website = json.getString("blog");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.misc.github.success.title", nickname + " (" + args[0] + ")", ""), "https://github.com/" + args[0] + "", "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png")
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.misc.github.success.title", nickname + " (" + args[0] + ")", ""), "https://github.com/" + args[0] + "", "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png")
.setThumbnail(json.getString("avatar_url"))
.addField(event.getMessageEditor().getTerm("commands.misc.github.success.bio"), bio, false)
.addField(event.getMessageEditor().getTerm("commands.misc.github.success.location"), location, true)
.addField(event.getMessageEditor().getTerm("commands.misc.github.success.website"), website, true)
.addField(event.getMessageEditor().getTerm("commands.misc.github.success.repositories"), String.valueOf(json.getInt("public_repos")), true)
.addField(event.getMessageEditor().getTerm("commands.misc.github.success.gists"), String.valueOf(json.getInt("public_gists")), true)
.addField(event.getMessageEditor().getTerm("commands.misc.github.success.followers"), String.valueOf(json.getInt("followers")), true)
.addField(event.getMessageEditor().getTerm("commands.misc.github.success.following"), String.valueOf(json.getInt("following")), true)
.addField(e.getMessageEditor().getTerm("commands.misc.github.success.bio"), bio, false)
.addField(e.getMessageEditor().getTerm("commands.misc.github.success.location"), location, true)
.addField(e.getMessageEditor().getTerm("commands.misc.github.success.website"), website, true)
.addField(e.getMessageEditor().getTerm("commands.misc.github.success.repositories"), String.valueOf(json.getInt("public_repos")), true)
.addField(e.getMessageEditor().getTerm("commands.misc.github.success.gists"), String.valueOf(json.getInt("public_gists")), true)
.addField(e.getMessageEditor().getTerm("commands.misc.github.success.followers"), String.valueOf(json.getInt("followers")), true)
.addField(e.getMessageEditor().getTerm("commands.misc.github.success.following"), String.valueOf(json.getInt("following")), true)
.build()).queue();
} catch (IOException | NullPointerException e) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
} catch (IOException | NullPointerException ex) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.misc.github.api.error.title",
"commands.misc.github.api.error.description")
.build()
).queue();
} catch (JSONException e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
} catch (JSONException ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.misc.github.user.error.title",
"commands.misc.github.user.error.description").build()).queue();
}
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
/*
TODO: THIS
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.misc.github.connect.title",
"",

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.misc;
import com.bbn.hadder.commands.Command;
@ -14,52 +30,52 @@ import java.util.List;
public class ScreenShareCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length>0) {
if (args[0].matches("[0-9]*") && args.length==1 && args[0].length() == 18) {
if (event.getGuild().getVoiceChannelById(args[0]) != null) {
event.getChannel().sendMessage(event.getMessageEditor().getMessage(
if (e.getGuild().getVoiceChannelById(args[0]) != null) {
e.getChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.misc.screenshare.success.title", "")
.setDescription("http://discordapp.com/channels/" + event.getGuild().getId() + "/" + args[0] + "/").build()).queue();
.setDescription("http://discordapp.com/channels/" + e.getGuild().getId() + "/" + args[0] + "/").build()).queue();
} else {
event.getChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.screenshare.id.error.title", "commands.misc.screenshare.id.error.description").build()).queue();
event.getHelpCommand().sendHelp(this, event);
e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.screenshare.id.error.title", "commands.misc.screenshare.id.error.description").build()).queue();
e.getHelpCommand().sendHelp(this, e);
}
} else {
List<VoiceChannel> vcs = event.getGuild().getVoiceChannelsByName(String.join(" ", args), true);
List<VoiceChannel> vcs = e.getGuild().getVoiceChannelsByName(String.join(" ", args), true);
if (vcs.size() > 1) {
EmbedBuilder eb = event.getMessageEditor().getMessage(MessageType.WARNING, "commands.misc.screenshare.channel.error.title", "commands.misc.screenshare.channel.error.description");
EmbedBuilder eb = e.getMessageEditor().getMessage(MessageType.WARNING, "commands.misc.screenshare.channel.error.title", "commands.misc.screenshare.channel.error.description");
for (int i = 0; i < vcs.size(); i++) {
VoiceChannel voiceChannel = vcs.get(i);
eb.addField(i + ": " + voiceChannel.getName(), voiceChannel.getId(), false);
}
event.getChannel().sendMessage(eb.build()).queue();
new EventWaiter().newOnMessageEventWaiter(msgevent -> {
e.getChannel().sendMessage(eb.build()).queue();
new EventWaiter().newOnMessageEventWaiter(msge -> {
try {
int i = Integer.parseInt(msgevent.getMessage().getContentRaw());
int i = Integer.parseInt(msge.getMessage().getContentRaw());
if (vcs.size() > i) {
event.getChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.misc.screenshare.success.title", "")
.setDescription("http://discordapp.com/channels/" + event.getGuild().getId() + "/" + vcs.get(i).getId() + "/").build()).queue();
e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.misc.screenshare.success.title", "")
.setDescription("http://discordapp.com/channels/" + e.getGuild().getId() + "/" + vcs.get(i).getId() + "/").build()).queue();
} else {
event.getChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.screenshare.number.error.title", "").build()).queue();
event.getHelpCommand().sendHelp(this, event);
e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.screenshare.number.error.title", "").build()).queue();
e.getHelpCommand().sendHelp(this, e);
}
} catch (NumberFormatException e) {
event.getChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.screenshare.id.error.title", "commands.misc.screenshare.number.error.description").build()).queue();
event.getHelpCommand().sendHelp(this, event);
} catch (NumberFormatException ex) {
e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.screenshare.id.error.title", "commands.misc.screenshare.number.error.description").build()).queue();
e.getHelpCommand().sendHelp(this, e);
}
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
} else if (vcs.size()==0) {
event.getChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.screenshare.channel.existing.error", "commands.misc.screenshare.channel.existing.description").build()).queue();
event.getHelpCommand().sendHelp(this, event);
e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.misc.screenshare.channel.existing.error", "commands.misc.screenshare.channel.existing.description").build()).queue();
e.getHelpCommand().sendHelp(this, e);
} else {
event.getChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.misc.screenshare.success.title", "")
.setDescription("http://discordapp.com/channels/" + event.getGuild().getId() + "/" + vcs.get(0).getId() + "/").build()).queue();
e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.misc.screenshare.success.title", "")
.setDescription("http://discordapp.com/channels/" + e.getGuild().getId() + "/" + vcs.get(0).getId() + "/").build()).queue();
}
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.moderation;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -15,68 +27,68 @@ import net.dv8tion.jda.api.entities.Member;
public class BanCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getMessage().getMentionedMembers().size() == 1) {
Member victim = event.getMessage().getMentionedMembers().get(0);
if (!event.getAuthor().getId().equals(victim.getId())) {
if (!event.getJDA().getSelfUser().getId().equals(victim.getId())) {
if (event.getGuild().getSelfMember().canInteract(victim)) {
event.getGuild().ban(victim, 0, "Banned by " + event.getAuthor().getAsTag()).queue();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
if (e.getMessage().getMentionedMembers().size() == 1) {
Member victim = e.getMessage().getMentionedMembers().get(0);
if (!e.getAuthor().getId().equals(victim.getId())) {
if (!e.getJDA().getSelfUser().getId().equals(victim.getId())) {
if (e.getGuild().getSelfMember().canInteract(victim)) {
e.getGuild().ban(victim, 0, "Banned by " + e.getAuthor().getAsTag()).queue();
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.ban.success.title",
"",
"commands.moderation.ban.success.description",
victim.getUser().getName() + ".").build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.ban.error.title",
"commands.moderation.ban.myself.error.description").build()).queue();
}
} else {
event.getTextChannel().sendMessage
(event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage
(e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.ban.error.title",
"commands.moderation.ban.yourself.error.description").build()).queue();
}
} else if (event.getMessage().getMentionedMembers().size() == 0) {
event.getHelpCommand().sendHelp(this, event);
} else if (event.getMessage().getMentionedMembers().size() > 1) {
for (int i = 0; i < event.getMessage().getMentionedMembers().size(); i++) {
Member member = event.getMessage().getMentionedMembers().get(i);
if (!event.getAuthor().getId().equals(member.getId())) {
if (!event.getJDA().getSelfUser().getId().equals(member.getId())) {
if (event.getGuild().getSelfMember().canInteract(member)) {
event.getGuild().ban(member, 0).reason("Mass Ban by " + event.getAuthor().getAsTag()).queue();
} else if (e.getMessage().getMentionedMembers().size() == 0) {
e.getHelpCommand().sendHelp(this, e);
} else if (e.getMessage().getMentionedMembers().size() > 1) {
for (int i = 0; i < e.getMessage().getMentionedMembers().size(); i++) {
Member member = e.getMessage().getMentionedMembers().get(i);
if (!e.getAuthor().getId().equals(member.getId())) {
if (!e.getJDA().getSelfUser().getId().equals(member.getId())) {
if (e.getGuild().getSelfMember().canInteract(member)) {
e.getGuild().ban(member, 0).reason("Mass Ban by " + e.getAuthor().getAsTag()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.ban.error.title",
"commands.moderation.ban.myself.error.description").build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.ban.error.title",
"commands.moderation.ban.yourself.error.description").build()).queue();
}
}
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.moderation.ban.success.title",
"",
"commands.moderation.ban.massban.success.description",
String.valueOf(event.getMessage().getMentionedMembers().size())).build()).queue();
String.valueOf(e.getMessage().getMentionedMembers().size())).build()).queue();
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.moderation;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -20,15 +32,15 @@ import java.util.concurrent.TimeUnit;
public class ClearCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
if (event.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_MANAGE)) {
if (e.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_MANAGE)) {
if (args[0].equals("all")) {
List<Message> msg = event.getTextChannel().getIterableHistory().complete();
List<Message> msg = e.getTextChannel().getIterableHistory().complete();
for (Message message : msg) {
message.delete().queue();
}
Message message = event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
Message message = e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.clear.all.success.title",
"",
@ -37,51 +49,51 @@ public class ClearCommand implements Command {
.build()).complete();
try {
TimeUnit.SECONDS.sleep(3);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
message.delete().queue();
} else {
try {
int nbToDelete = Integer.parseInt(args[0]);
if (nbToDelete < 1 || nbToDelete > 99) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.clear.number.error.title", "commands.moderation.clear.number.error.description").build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.clear.number.error.title", "commands.moderation.clear.number.error.description").build()).queue();
} else {
List<Message> history = event.getTextChannel().getHistory().retrievePast(nbToDelete + 1).complete();
List<Message> history = e.getTextChannel().getHistory().retrievePast(nbToDelete + 1).complete();
List<Message> msgToDelete = new ArrayList<>(history);
event.getTextChannel().deleteMessages(msgToDelete).queue();
e.getTextChannel().deleteMessages(msgToDelete).queue();
if (nbToDelete == 1) {
Message msg = event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.moderation.clear.success.title",
Message msg = e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.moderation.clear.success.title",
"commands.moderation.clear.success.description.singular").build()).complete();
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
msg.delete().queue();
} else {
Message msg = event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.moderation.clear.success.title", "",
Message msg = e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.moderation.clear.success.title", "",
"commands.moderation.clear.success.description.plural", String.valueOf(nbToDelete)).build()).complete();
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
msg.delete().queue();
}
}
} catch (NumberFormatException e) {
event.getHelpCommand().sendHelp(this, event);
} catch (IllegalArgumentException e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.clear.message.error.title", "commands.moderation.clear.message.error.description")
} catch (NumberFormatException ex) {
e.getHelpCommand().sendHelp(this, e);
} catch (IllegalArgumentException ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.clear.message.error.title", "commands.moderation.clear.message.error.description")
.build()).queue();
}
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
@ -7,75 +23,71 @@ import com.bbn.hadder.core.Perms;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.entities.TextChannel;
/**
* @author Skidder / GregTCLTK
*/
@Perms(Perm.MANAGE_SERVER)
public class EditRulesCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getRethink().getRulesMID(event.getGuild().getId()).length() == 18) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
public void executed(String[] args, CommandEvent e) {
if (e.getRethinkServer().getMessageID().length() == 18) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.moderation.editrules.message.title",
"commands.moderation.editrules.message.description").build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event1 -> {
String rules = event1.getMessage().getContentRaw();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
e.getEventWaiter().newOnMessageEventWaiter(e1 -> {
String rules = e1.getMessage().getContentRaw();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.moderation.editrules.channel.title",
"commands.moderation.editrules.channel.description").build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event2 -> {
if (event2.getMessage().getMentionedChannels().size() == 1) {
e.getEventWaiter().newOnMessageEventWaiter(e2 -> {
if (e2.getMessage().getMentionedChannels().size() == 1) {
try {
TextChannel channel = event2.getMessage().getMentionedChannels().get(0);
checkChannel(event, rules, channel);
} catch (Exception e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
TextChannel channel = e2.getMessage().getMentionedChannels().get(0);
checkChannel(e, rules, channel);
} catch (Exception ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.editrules.channel.error.title",
"commands.moderation.editrules.channel.error.description")
.build()).queue();
}
} else {
try {
TextChannel channel = event1.getGuild().getTextChannelsByName(event2.getMessage().getContentRaw(), true).get(0);
checkChannel(event, rules, channel);
} catch (Exception e) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
TextChannel channel = e1.getGuild().getTextChannelsByName(e2.getMessage().getContentRaw(), true).get(0);
checkChannel(e, rules, channel);
} catch (Exception ex) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.editrules.channel.error.title",
"commands.moderation.editrules.channel.error.description")
.build()).queue();
}
}
}, event.getJDA(), event.getAuthor());
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
}, e.getJDA(), e.getAuthor());
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.editrules.error.title", "",
"commands.moderation.editrules.error.description", event.getRethink().getGuildPrefix(event.getGuild().getId())).build()).queue();
"commands.moderation.editrules.error.description", e.getRethinkServer().getPrefix()).build()).queue();
}
}
public void checkChannel(CommandEvent event, String rules, TextChannel channel) {
public void checkChannel(CommandEvent e, String rules, TextChannel channel) {
try {
channel.retrieveMessageById(event.getRethink().getRulesMID(event.getGuild().getId())).queue();
setRules(event, rules, channel);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
channel.retrieveMessageById(e.getRethinkServer().getMessageID()).queue();
setRules(e, rules, channel);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.moderation.editrules.success.title",
"commands.moderation.editrules.success.description").build()).queue();
} catch (Exception e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
} catch (Exception ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.editrules.channel.message.error.title",
"commands.moderation.editrules.channel.message.error.description").build()).queue();
}
}
public void setRules(CommandEvent event, String rules, TextChannel channel) {
channel.retrieveMessageById(event.getRethink().getRulesMID(event.getGuild().getId())).complete().editMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
public void setRules(CommandEvent e, String rules, TextChannel channel) {
channel.retrieveMessageById(e.getRethinkServer().getMessageID()).complete().editMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Rules")
.setDescription(rules)
.build()).queue();

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.moderation;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -14,21 +26,22 @@ import com.bbn.hadder.utils.MessageEditor;
public class InviteDetectCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length == 1) {
String opinion = args[0].toLowerCase();
switch (opinion) {
case "on":
if (!event.getRethink().getInviteDetection(event.getGuild().getId())) {
event.getRethink().setInviteDetection(event.getGuild().getId(), true);
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
if (!e.getRethinkServer().isInviteDetect()) {
e.getRethinkServer().setInviteDetect(true);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.invitedetect.activate.success.title",
"commands.moderation.invitedetect.activate.success.description")
.build()).queue();
e.getRethinkServer().push();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.invitedetect.activate.error.title",
"commands.moderation.invitedetect.activate.error.description")
@ -37,15 +50,16 @@ public class InviteDetectCommand implements Command {
break;
case "off":
if (event.getRethink().getInviteDetection(event.getGuild().getId())) {
event.getRethink().setInviteDetection(event.getGuild().getId(), false);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
if (e.getRethinkServer().isInviteDetect()) {
e.getRethinkServer().setInviteDetect(false);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.invitedetect.deactivate.success.title",
"commands.moderation.invitedetect.deactivate.success.description")
.build()).queue();
e.getRethinkServer().push();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.invitedetect.deactivate.error.title",
"commands.moderation.invitedetect.deactivate.error.description")
@ -53,10 +67,10 @@ public class InviteDetectCommand implements Command {
}
break;
default:
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.moderation;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -15,53 +27,53 @@ import net.dv8tion.jda.api.entities.Member;
public class KickCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getMessage().getMentionedMembers().size() == 1) {
Member victim = event.getMessage().getMentionedMembers().get(0);
if (!event.getAuthor().getId().equals(victim.getId())) {
if (!event.getJDA().getSelfUser().getId().equals(victim.getId())) {
if (event.getGuild().getSelfMember().canInteract(victim)) {
event.getGuild().kick(victim, "Kicked by " + event.getAuthor().getAsTag()).queue();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
if (e.getMessage().getMentionedMembers().size() == 1) {
Member victim = e.getMessage().getMentionedMembers().get(0);
if (!e.getAuthor().getId().equals(victim.getId())) {
if (!e.getJDA().getSelfUser().getId().equals(victim.getId())) {
if (e.getGuild().getSelfMember().canInteract(victim)) {
e.getGuild().kick(victim, "Kicked by " + e.getAuthor().getAsTag()).queue();
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.kick.success.title",
"",
"commands.moderation.kick.success.description",
victim.getUser().getName()).build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.kick.error.title",
"commands.moderation.kick.myself.error.description").build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.kick.error.title", "commands.moderation.kick.yourself.error.description").build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.kick.error.title", "commands.moderation.kick.yourself.error.description").build()).queue();
}
} else if (event.getMessage().getMentionedMembers().size() == 0) {
event.getHelpCommand().sendHelp(this, event);
} else if (event.getMessage().getMentionedMembers().size() > 1) {
for (int i = 0; i < event.getMessage().getMentionedMembers().size(); i++) {
Member member = event.getMessage().getMentionedMembers().get(i);
if (!event.getAuthor().getId().equals(member.getId())) {
if (!event.getJDA().getSelfUser().getId().equals(member.getId())) {
if (event.getGuild().getSelfMember().canInteract(member)) {
event.getGuild().kick(member).reason("Mass Kicked by " + event.getAuthor().getAsTag()).queue();
} else if (e.getMessage().getMentionedMembers().size() == 0) {
e.getHelpCommand().sendHelp(this, e);
} else if (e.getMessage().getMentionedMembers().size() > 1) {
for (int i = 0; i < e.getMessage().getMentionedMembers().size(); i++) {
Member member = e.getMessage().getMentionedMembers().get(i);
if (!e.getAuthor().getId().equals(member.getId())) {
if (!e.getJDA().getSelfUser().getId().equals(member.getId())) {
if (e.getGuild().getSelfMember().canInteract(member)) {
e.getGuild().kick(member).reason("Mass Kicked by " + e.getAuthor().getAsTag()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.kick.error.title", "commands.moderation.kick.myself.error.description").build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.kick.error.title", "commands.moderation.kick.myself.error.description").build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.kick.error.title", "commands.moderation.kick.yourself.error.description").build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.moderation.kick.error.title", "commands.moderation.kick.yourself.error.description").build()).queue();
}
}
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.moderation.kick.success.title", "", "commands.moderation.kick.masskick.success.description", String.valueOf(event.getMessage().getMentionedMembers().size())).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.moderation.kick.success.title", "", "commands.moderation.kick.masskick.success.description", String.valueOf(e.getMessage().getMentionedMembers().size())).build()).queue();
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.moderation;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -16,52 +28,52 @@ import net.dv8tion.jda.api.entities.Member;
public class NickCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getGuild().getSelfMember().hasPermission(Permission.NICKNAME_MANAGE)) {
if (event.getMessage().getMentionedMembers().size() == 1) {
if (!event.getMessage().getMentionedMembers().get(0).getId().equals(event.getGuild().getSelfMember().getId())) {
if (event.getGuild().getSelfMember().canInteract(event.getMessage().getMentionedMembers().get(0))) {
public void executed(String[] args, CommandEvent e) {
if (e.getGuild().getSelfMember().hasPermission(Permission.NICKNAME_MANAGE)) {
if (e.getMessage().getMentionedMembers().size() == 1) {
if (!e.getMessage().getMentionedMembers().get(0).getId().equals(e.getGuild().getSelfMember().getId())) {
if (e.getGuild().getSelfMember().canInteract(e.getMessage().getMentionedMembers().get(0))) {
if (args.length > 1) {
if (event.getMessage().getContentRaw().startsWith(event.getRethink().getUserPrefix(event.getMember().getId()))) {
event.getGuild().modifyNickname(event.getMessage().getMentionedMembers().get(0), event.getMessage().getContentRaw().replaceFirst(event.getRethink().getUserPrefix(event.getMember().getId()) + "nick " + args[0], "")).reason("Nicked by " + event.getAuthor().getAsTag()).queue();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
if (e.getMessage().getContentRaw().startsWith(e.getRethinkUser().getPrefix())) {
e.getGuild().modifyNickname(e.getMessage().getMentionedMembers().get(0), e.getMessage().getContentRaw().replaceFirst(e.getRethinkUser().getPrefix() + "nick " + args[0], "")).reason("Nicked by " + e.getAuthor().getAsTag()).queue();
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.nick.success.title",
"",
"commands.moderation.nick.success.description",
event.getMessage().getMentionedMembers().get(0).getUser().getAsTag()
e.getMessage().getMentionedMembers().get(0).getUser().getAsTag()
).build()).queue();
} else if (event.getMessage().getContentRaw().startsWith(event.getRethink().getGuildPrefix(event.getGuild().getId()))) {
event.getGuild().modifyNickname(event.getMessage().getMentionedMembers().get(0), event.getMessage().getContentRaw().replaceFirst(event.getRethink().getGuildPrefix(event.getGuild().getId()) + "nick " + args[0], "")).reason("Nicked by " + event.getAuthor().getAsTag()).queue();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
} else if (e.getMessage().getContentRaw().startsWith(e.getRethinkServer().getPrefix())) {
e.getGuild().modifyNickname(e.getMessage().getMentionedMembers().get(0), e.getMessage().getContentRaw().replaceFirst(e.getRethinkServer().getPrefix() + "nick " + args[0], "")).reason("Nicked by " + e.getAuthor().getAsTag()).queue();
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.nick.success.title",
"",
"commands.moderation.nick.success.description", event.getMessage().getMentionedMembers().get(0).getUser().getAsTag()
"commands.moderation.nick.success.description", e.getMessage().getMentionedMembers().get(0).getUser().getAsTag()
).build()).queue();
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
if (event.getMessage().getContentRaw().startsWith(event.getRethink().getUserPrefix(event.getMember().getId()))) {
event.getGuild().getSelfMember().modifyNickname(event.getMessage().getContentRaw().replaceFirst(event.getRethink().getUserPrefix(event.getMember().getId()) + "nick " + args[0], "")).reason("Nicked by " + event.getAuthor().getAsTag()).queue();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
if (e.getMessage().getContentRaw().startsWith(e.getRethinkUser().getPrefix())) {
e.getGuild().getSelfMember().modifyNickname(e.getMessage().getContentRaw().replaceFirst(e.getRethinkUser().getPrefix() + "nick " + args[0], "")).reason("Nicked by " + e.getAuthor().getAsTag()).queue();
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.nick.success.title",
"",
"commands.moderation.nick.myself.success.description",
"").build()).queue();
} else if (event.getMessage().getContentRaw().startsWith(event.getRethink().getGuildPrefix(event.getGuild().getId()))) {
event.getGuild().getSelfMember().modifyNickname(event.getMessage().getContentRaw().replaceFirst(event.getRethink().getGuildPrefix(event.getGuild().getId()) + "nick " + args[0], "")).reason("Nicked by " + event.getAuthor().getAsTag()).queue();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
} else if (e.getMessage().getContentRaw().startsWith(e.getRethinkServer().getPrefix())) {
e.getGuild().getSelfMember().modifyNickname(e.getMessage().getContentRaw().replaceFirst(e.getRethinkServer().getPrefix() + "nick " + args[0], "")).reason("Nicked by " + e.getAuthor().getAsTag()).queue();
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.nick.success.title",
"",
@ -69,27 +81,27 @@ public class NickCommand implements Command {
).build()).queue();
}
}
} else if (event.getMessage().getMentionedMembers().size() == 0) {
event.getHelpCommand().sendHelp(this, event);
} else if (e.getMessage().getMentionedMembers().size() == 0) {
e.getHelpCommand().sendHelp(this, e);
} else {
for (int i = 0; i < event.getMessage().getMentionedMembers().size(); i++) {
Member member = event.getMessage().getMentionedMembers().get(i);
if (!event.getJDA().getSelfUser().getId().equals(member.getId())) {
event.getGuild().modifyNickname(member, args[args.length - 1]).reason("Mass Nicked by " + event.getAuthor().getAsTag()).queue();
for (int i = 0; i < e.getMessage().getMentionedMembers().size(); i++) {
Member member = e.getMessage().getMentionedMembers().get(i);
if (!e.getJDA().getSelfUser().getId().equals(member.getId())) {
e.getGuild().modifyNickname(member, args[args.length - 1]).reason("Mass Nicked by " + e.getAuthor().getAsTag()).queue();
} else {
event.getGuild().getSelfMember().modifyNickname(args[args.length - 1]).reason("Mass Nicked by " + event.getAuthor().getAsTag()).queue();
e.getGuild().getSelfMember().modifyNickname(args[args.length - 1]).reason("Mass Nicked by " + e.getAuthor().getAsTag()).queue();
}
}
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.nick.success.title",
"",
"commands.moderation.nick.myself.success.description", String.valueOf(event.getMessage().getMentionedMembers().size())
"commands.moderation.nick.myself.success.description", String.valueOf(e.getMessage().getMentionedMembers().size())
).build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
}

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
@ -10,11 +26,12 @@ import com.bbn.hadder.utils.MessageEditor;
public class PrefixCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length == 1) {
if (!args[0].contains("\"")) {
event.getRethink().setGuildPrefix(args[0], event.getGuild().getId());
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getRethinkServer().setPrefix(args[0]);
e.getRethinkServer().push();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.prefix.success.title",
"",
@ -22,14 +39,14 @@ public class PrefixCommand implements Command {
args[0]).build()
).queue();
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.WARNING,
"",
"commands.moderation.prefix.error.description").build()).queue();
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.moderation;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -16,67 +28,67 @@ import net.dv8tion.jda.api.Region;
public class RegionChangeCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length == 1) {
if (event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_SERVER)) {
if (e.getGuild().getSelfMember().hasPermission(Permission.MANAGE_SERVER)) {
switch (args[0].toLowerCase()) {
case "amsterdam":
setRegion(Region.AMSTERDAM, "Amsterdam", event);
setRegion(Region.AMSTERDAM, "Amsterdam", e);
break;
case "frankfurt":
setRegion(Region.FRANKFURT, "Frankfurt", event);
setRegion(Region.FRANKFURT, "Frankfurt", e);
break;
case "eu-west":
setRegion(Region.EU_WEST, "EU West", event);
setRegion(Region.EU_WEST, "EU West", e);
break;
case "eu-central":
setRegion(Region.EU_CENTRAL, "EU Central", event);
setRegion(Region.EU_CENTRAL, "EU Central", e);
break;
case "europe":
setRegion(Region.EUROPE, "EUROPE", event);
setRegion(Region.EUROPE, "EUROPE", e);
break;
case "brazil":
setRegion(Region.BRAZIL, "Brazil", event);
setRegion(Region.BRAZIL, "Brazil", e);
break;
case "hongkong":
setRegion(Region.HONG_KONG, "Hong Kong", event);
setRegion(Region.HONG_KONG, "Hong Kong", e);
break;
case "india":
setRegion(Region.INDIA, "India", event);
setRegion(Region.INDIA, "India", e);
break;
case "japan":
setRegion(Region.JAPAN, "Japan", event);
setRegion(Region.JAPAN, "Japan", e);
break;
case "london":
setRegion(Region.LONDON, "London", event);
setRegion(Region.LONDON, "London", e);
break;
case "russia":
setRegion(Region.RUSSIA, "Russia", event);
setRegion(Region.RUSSIA, "Russia", e);
break;
case "singapore":
setRegion(Region.SINGAPORE, "Singapore", event);
setRegion(Region.SINGAPORE, "Singapore", e);
break;
case "south-africa":
setRegion(Region.SOUTH_AFRICA, "South Africa", event);
setRegion(Region.SOUTH_AFRICA, "South Africa", e);
break;
case "sydney":
setRegion(Region.SYDNEY, "Sydney", event);
setRegion(Region.SYDNEY, "Sydney", e);
break;
case "us-central":
setRegion(Region.US_CENTRAL, "US Central", event);
setRegion(Region.US_CENTRAL, "US Central", e);
break;
case "us-east":
setRegion(Region.US_EAST, "US East", event);
setRegion(Region.US_EAST, "US East", e);
break;
case "us-west":
setRegion(Region.US_WEST, "US West", event);
setRegion(Region.US_WEST, "US West", e);
break;
case "us-south":
setRegion(Region.US_SOUTH, "US South", event);
setRegion(Region.US_SOUTH, "US South", e);
break;
default:
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.regionchange.regions.title",
"")
@ -84,10 +96,12 @@ public class RegionChangeCommand implements Command {
.build()).queue();
break;
}
//TODO: Maybe South Korea. Check the geo restricted discussion
} else
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
} else event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
} else e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.regionchange.regions.title",
"")
@ -95,10 +109,10 @@ public class RegionChangeCommand implements Command {
.build()).queue();
}
public void setRegion (Region region, String region_name, CommandEvent event) {
event.getGuild().getManager().setRegion(region).reason("Region changed by " + event.getAuthor().getAsTag()).queue();
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
public void setRegion (Region region, String region_name, CommandEvent e) {
e.getGuild().getManager().setRegion(region).reason("Region changed by " + e.getAuthor().getAsTag()).queue();
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.regionchange.success.title", "",
"commands.moderation.regionchange.success.description", region_name)

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
@ -13,74 +29,74 @@ import net.dv8tion.jda.api.entities.Role;
public class RoleCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
if (event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) {
if (e.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) {
switch (args[0].toLowerCase()) {
case "add":
if (event.getMessage().getMentionedMembers().size() > 0 && event.getMessage().getMentionedRoles().size() > 0) {
for (Member member : event.getMessage().getMentionedMembers()) {
for (Role role : event.getMessage().getMentionedRoles()) {
if (event.getGuild().getSelfMember().canInteract(member)) {
if (event.getGuild().getSelfMember().canInteract(role)) {
event.getGuild().addRoleToMember(member, role).reason("Role added by " + event.getAuthor().getAsTag()).queue();
if (e.getMessage().getMentionedMembers().size() > 0 && e.getMessage().getMentionedRoles().size() > 0) {
for (Member member : e.getMessage().getMentionedMembers()) {
for (Role role : e.getMessage().getMentionedRoles()) {
if (e.getGuild().getSelfMember().canInteract(member)) {
if (e.getGuild().getSelfMember().canInteract(role)) {
e.getGuild().addRoleToMember(member, role).reason("Role added by " + e.getAuthor().getAsTag()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
}
}
event.getChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.role.add.success.title",
"",
"",
"commands.moderation.role.add.success.description",
String.valueOf(event.getMessage().getMentionedRoles().size()),
String.valueOf(event.getMessage().getMentionedMembers().size()))
String.valueOf(e.getMessage().getMentionedRoles().size()),
String.valueOf(e.getMessage().getMentionedMembers().size()))
.build()).queue();
}
break;
case "remove":
if (event.getMessage().getMentionedMembers().size() > 0 && event.getMessage().getMentionedRoles().size() > 0) {
for (Member member : event.getMessage().getMentionedMembers()) {
for (Role role : event.getMessage().getMentionedRoles()) {
if (event.getGuild().getSelfMember().canInteract(member)) {
if (event.getGuild().getSelfMember().canInteract(role)) {
event.getGuild().removeRoleFromMember(member, role).reason("Role removed by " + event.getAuthor().getAsTag()).queue();
if (e.getMessage().getMentionedMembers().size() > 0 && e.getMessage().getMentionedRoles().size() > 0) {
for (Member member : e.getMessage().getMentionedMembers()) {
for (Role role : e.getMessage().getMentionedRoles()) {
if (e.getGuild().getSelfMember().canInteract(member)) {
if (e.getGuild().getSelfMember().canInteract(role)) {
e.getGuild().removeRoleFromMember(member, role).reason("Role removed by " + e.getAuthor().getAsTag()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
}
}
event.getChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.role.remove.success.title",
"",
"",
"commands.moderation.role.remove.success.description",
String.valueOf(event.getMessage().getMentionedRoles().size()),
String.valueOf(event.getMessage().getMentionedMembers().size()))
String.valueOf(e.getMessage().getMentionedRoles().size()),
String.valueOf(e.getMessage().getMentionedMembers().size()))
.build()).queue();
}
break;
default:
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
break;
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.moderation;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -21,92 +33,94 @@ import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
public class RulesCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
if (e.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.setup.title",
"commands.moderation.rules.setup.description")
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event1 -> {
if (event1.getMessage().getMentionedChannels().size() == 1) {
e.getEventWaiter().newOnMessageEventWaiter(e1 -> {
if (e1.getMessage().getMentionedChannels().size() == 1) {
try {
TextChannel channel = event1.getMessage().getMentionedChannels().get(0);
createRules(event, event1, channel);
} catch (Exception e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
TextChannel channel = e1.getMessage().getMentionedChannels().get(0);
createRules(e, e1, channel);
} catch (Exception ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.rules.channel.error.title",
"commands.moderation.rules.channel.error.description")
.build()).queue();
}
} else {
try {
TextChannel channel = event1.getGuild().getTextChannelsByName(event1.getMessage().getContentRaw(), true).get(0);
createRules(event, event1, channel);
} catch (Exception e) {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
TextChannel channel = e1.getGuild().getTextChannelsByName(e1.getMessage().getContentRaw(), true).get(0);
createRules(e, e1, channel);
} catch (NullPointerException ex) {
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.rules.channel.error.title",
"commands.moderation.rules.channel.error.description")
.build()).queue();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.rules.error.permission.title",
"commands.moderation.rules.error.permission.description")
.build()).queue();
}
}
public void createRules(CommandEvent event, GuildMessageReceivedEvent event1, TextChannel channel) {
if (channel.getGuild().getId().equals(event1.getGuild().getId())) {
if (event.getGuild().getSelfMember().hasPermission(channel, Permission.MESSAGE_WRITE)) {
event1.getChannel().sendMessage(
event.getMessageEditor().getMessage(
public void createRules(CommandEvent e, GuildMessageReceivedEvent e1, TextChannel channel) {
if (channel.getGuild().getId().equals(e1.getGuild().getId())) {
if (e.getGuild().getSelfMember().hasPermission(channel, Permission.MESSAGE_WRITE)) {
e1.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.rules.title",
"",
"commands.moderation.rules.rules.description",
channel.getName())
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event2 -> {
String message = event2.getMessage().getContentRaw();
event2.getChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getEventWaiter().newOnMessageEventWaiter(e2 -> {
String message = e2.getMessage().getContentRaw();
e2.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.role.title",
"commands.moderation.rules.role.description")
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event3 -> {
if (event3.getMessage().getMentionedRoles().size() == 1) {
Role role = event3.getMessage().getMentionedRoles().get(0);
setRole(event, channel, message, event3, role);
} else if (event3.getGuild().getRolesByName(event3.getMessage().getContentRaw(), true).size() > 0) {
Role role = event3.getGuild().getRolesByName(event3.getMessage().getContentRaw(), true).get(0);
setRole(event, channel, message, event3, role);
new EventWaiter().newOnMessageEventWaiter(e3 -> {
if (e3.getMessage().getMentionedRoles().size() == 1) {
Role role = e3.getMessage().getMentionedRoles().get(0);
setRole(e, channel, message, e3, role);
} else if (e3.getGuild().getRolesByName(e3.getMessage().getContentRaw(), true).size() > 0) {
Role role = e3.getGuild().getRolesByName(e3.getMessage().getContentRaw(), true).get(0);
setRole(e, channel, message, e3, role);
} else {
event3.getChannel().sendMessage(
event.getMessageEditor().getMessage(
e3.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.rules.role.error.title",
"commands.moderation.rules.role.error.description")
.build()).queue();
}
}, event.getJDA(), event.getAuthor());
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
}, e.getJDA(), e.getAuthor());
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.rules.error.message.title",
"commands.moderation.rules.error.message.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.rules.guild.error.title",
"commands.moderation.rules.guild.error.description")
@ -114,117 +128,119 @@ public class RulesCommand implements Command {
}
}
public void setRole(CommandEvent event, TextChannel channel, String message, GuildMessageReceivedEvent event3, Role role) {
if (event3.getGuild().getSelfMember().canInteract(role)) {
if (event3.getMember().canInteract(role)) {
event3.getChannel().sendMessage(
event.getMessageEditor().getMessage(
public void setRole(CommandEvent e, TextChannel channel, String message, GuildMessageReceivedEvent e3, Role role) {
if (e3.getGuild().getSelfMember().canInteract(role)) {
if (e3.getMember().canInteract(role)) {
e3.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.accept.title",
"",
"commands.moderation.rules.emote.accept.description", role.getName())
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event4 -> {
if (event4.getMessage().getEmotes().size() == 1) {
Emote aemote = event4.getMessage().getEmotes().get(0);
event4.getChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getEventWaiter().newOnMessageEventWaiter(e4 -> {
if (e4.getMessage().getEmotes().size() == 1) {
Emote aemote = e4.getMessage().getEmotes().get(0);
e4.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.decline.title", "",
"commands.moderation.rules.emote.decline.description", String.valueOf(aemote))
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event5 -> {
Emote demote = event5.getMessage().getEmotes().get(0);
e.getEventWaiter().newOnMessageEventWaiter(e5 -> {
Emote demote = e5.getMessage().getEmotes().get(0);
if (!aemote.equals(demote)) {
Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
Message rules = channel.sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Rules")
.setDescription(message)
.build()).complete();
try {
rules.addReaction(aemote).queue();
rules.addReaction(demote).queue();
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
e5.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.success.title",
"",
"commands.moderation.rules.success.description",
channel.getAsMention())
.build()).queue();
} catch (Exception e) {
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
} catch (Exception ex) {
e5.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"error",
"commands.moderation.rules.emote.error.access.description")
.build()).queue();
e.printStackTrace();
ex.printStackTrace();
}
event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote.toString(), demote.toString());
e.getRethinkServer().updateRules(rules.getId(), role.getId(), aemote.toString(), demote.toString());
e.getRethinkServer().push();
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.rules.emote.error.equal.title",
"commands.moderation.rules.emote.error.equal.description")
.build()).queue();
}
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
} else {
String aemote = event4.getMessage().getContentRaw();
event4.getChannel().sendMessage(
event.getMessageEditor().getMessage(
String aemote = e4.getMessage().getContentRaw();
e4.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.decline.title",
"commands.moderation.rules.emoji.decline.description")
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event5 -> {
String demote = event5.getMessage().getContentRaw();
e.getEventWaiter().newOnMessageEventWaiter(e5 -> {
String demote = e5.getMessage().getContentRaw();
if (!aemote.equals(demote)) {
Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
Message rules = channel.sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Rules")
.setDescription(message)
.build()).complete();
try {
rules.addReaction(aemote).queue();
rules.addReaction(demote).queue();
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
e5.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.success.title",
"",
"commands.moderation.rules.success.description",
channel.getAsMention())
.build()).queue();
} catch (Exception e) {
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
} catch (Exception ex) {
e5.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"error",
"commands.moderation.rules.emoji.error.description")
.build()).queue();
e.printStackTrace();
ex.printStackTrace();
}
event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote, demote);
e.getRethinkServer().updateRules(rules.getId(), role.getId(), aemote, demote);
e.getRethinkServer().push();
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.rules.emote.error.equal.title",
"commands.moderation.rules.emote.error.equal.description")
.build()).queue();
}
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
}
}, event.getJDA(), event.getAuthor());
}, e.getJDA(), e.getAuthor());
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.rules.role.permission.error.title",
"commands.moderation.rules.role.permission.error.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.rules.error.interact.title",
"commands.moderation.rules.error.interact.description")
.build()).queue();

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.moderation;
import com.bbn.hadder.commands.Command;
@ -8,29 +24,31 @@ import net.dv8tion.jda.api.entities.TextChannel;
public class StarboardCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getMessage().getMentionedChannels().size()==1) {
event.getRethink().setStarboardChannel(event.getGuild().getId(), event.getMessage().getMentionedChannels().get(0).getId());
event.getChannel().sendMessage(
event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
if (e.getMessage().getMentionedChannels().size()==1) {
e.getRethinkServer().setStarboard(e.getMessage().getMentionedChannels().get(0).getId());
e.getChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.starboard.success.title","")
.build())
.queue();
} else {
if (args.length>0) {
TextChannel channel = event.getGuild().getTextChannelById(args[0]);
TextChannel channel = e.getGuild().getTextChannelById(args[0]);
if (channel!=null) {
event.getRethink().setStarboardChannel(event.getGuild().getId(), channel.getId());
e.getRethinkServer().setStarboard(channel.getId());
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}
if (args.length==2) {
event.getRethink().setNeededStars(args[1], event.getGuild().getId());
e.getRethinkServer().setNeededStars(args[1]);
}
e.getRethinkServer().push();
}
@Override

View file

@ -1,5 +1,17 @@
/*
@author Hax / Hax6775 / Schlauer_Hax
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
@ -14,29 +26,29 @@ public class BassCommand implements Command {
-0.1f, -0.1f, -0.1f, -0.1f };
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
if (e.getAudioManager().hasPlayer(e.getGuild()) && e.getAudioManager().getPlayer(e.getGuild()).getPlayingTrack() != null) {
if (e.getMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().getChannel().equals(e.getMember().getVoiceState().getChannel())) {
float value = Float.parseFloat(args[0]);
EqualizerFactory equalizer = new EqualizerFactory();
for (int i = 0; i < BASS_BOOST.length; i++) {
equalizer.setGain(i, BASS_BOOST[i] + value);
}
event.getAudioManager().getPlayer(event.getGuild()).setFrameBufferDuration(500);
event.getAudioManager().getPlayer(event.getGuild()).setFilterFactory(equalizer);
e.getAudioManager().getPlayer(e.getGuild()).setFrameBufferDuration(500);
e.getAudioManager().getPlayer(e.getGuild()).setFilterFactory(equalizer);
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.bass.error.connected.title",
"commands.music.bass.error.connected.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}
} else event.getHelpCommand().sendHelp(this, event);
} else e.getHelpCommand().sendHelp(this, e);
}
@Override

View file

@ -0,0 +1,101 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
import com.bbn.hadder.core.Perms;
import net.dv8tion.jda.api.audio.*;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.managers.AudioManager;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.ByteBuffer;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@Perms(Perm.BOT_OWNER)
public class EchoCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
Guild guild = event.getMember().getVoiceState().getChannel().getGuild();
AudioManager audioManager = guild.getAudioManager();
EchoHandler handler = new EchoHandler();
if (!audioManager.isConnected()) {
audioManager.setSendingHandler(handler);
audioManager.setReceivingHandler(handler);
audioManager.openAudioConnection(event.getMember().getVoiceState().getChannel());
} else {
audioManager.closeAudioConnection();
}
}
public static class EchoHandler implements AudioSendHandler, AudioReceiveHandler {
private final Queue<byte[]> queue = new ConcurrentLinkedQueue<>();
@Override
public boolean canProvide() {
return !queue.isEmpty();
}
@Nullable
@Override
public ByteBuffer provide20MsAudio() {
byte[] data = queue.poll();
return data == null ? null : ByteBuffer.wrap(data); // Wrap this in a java.nio.ByteBuffer
}
@Override
public boolean canReceiveCombined() {
return queue.size() < 10;
}
@Override
public void handleCombinedAudio(@Nonnull CombinedAudio combinedAudio) {
if (combinedAudio.getUsers().isEmpty())
return;
byte[] data = combinedAudio.getAudioData(1.0f); // volume at 100% = 1.0 (50% = 0.5 / 55% = 0.55)
queue.add(data);
}
}
@Override
public String[] labels() {
return new String[]{"echo"};
}
@Override
public String description() {
return null;
}
@Override
public String usage() {
return null;
}
@Override
public String example() {
return null;
}
}

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
@ -5,24 +21,20 @@ import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
/**
* @author Skidder / GregTCLTK
*/
public class InfoCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
AudioTrack track = event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
public void executed(String[] args, CommandEvent e) {
if (e.getAudioManager().hasPlayer(e.getGuild()) && e.getAudioManager().getPlayer(e.getGuild()).getPlayingTrack() != null) {
AudioTrack track = e.getAudioManager().getPlayer(e.getGuild()).getPlayingTrack();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.info.success.title", "")
.setAuthor(track.getInfo().author)
.addField("Title", track.getInfo().title, true)
.addField("Progress", "`[ " + event.getAudioManager().getTimestamp(track.getPosition()) + " / " + event.getAudioManager().getTimestamp(track.getInfo().length) + " ]`", false)
.addField("Progress", "`[ " + e.getAudioManager().getTimestamp(track.getPosition()) + " / " + e.getAudioManager().getTimestamp(track.getInfo().length) + " ]`", false)
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
@ -7,39 +23,35 @@ import net.dv8tion.jda.api.entities.VoiceChannel;
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import net.dv8tion.jda.api.managers.AudioManager;
/*
* @author Skidder / GregTCLTK
*/
public class JoinCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getMember().getVoiceState().inVoiceChannel()) {
AudioManager audioManager = event.getGuild().getAudioManager();
public void executed(String[] args, CommandEvent e) {
if (e.getMember().getVoiceState().inVoiceChannel()) {
AudioManager audioManager = e.getGuild().getAudioManager();
if(!audioManager.isAttemptingToConnect()) {
VoiceChannel vc = event.getMember().getVoiceState().getChannel();
if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
if (!event.getGuild().getSelfMember().getVoiceState().getChannel().getId().equals(vc.getId())) {
VoiceChannel vc = e.getMember().getVoiceState().getChannel();
if (e.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
if (!e.getGuild().getSelfMember().getVoiceState().getChannel().getId().equals(vc.getId())) {
try {
event.getGuild().getAudioManager().openAudioConnection(vc);
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getGuild().getAudioManager().openAudioConnection(vc);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.join.success.title",
"",
"commands.music.join.success.description",
vc.getName())
.build()).queue();
} catch (InsufficientPermissionException e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
} catch (InsufficientPermissionException ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.join.error.permission.title",
"commands.music.join.error.permission.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(
MessageEditor.MessageType.WARNING,
"commands.music.join.error.connecting.already.title",
"commands.music.join.error.connecting.already.description")
@ -47,28 +59,28 @@ public class JoinCommand implements Command {
}
} else {
try {
event.getGuild().getAudioManager().openAudioConnection(vc);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getGuild().getAudioManager().openAudioConnection(vc);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.join.success.title", "",
"commands.music.join.success.description", vc.getName())
.build()).queue();
} catch (InsufficientPermissionException e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
} catch (InsufficientPermissionException ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.join.error.permission.title",
"commands.music.join.error.permission.description")
.build()).queue();
}
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.WARNING,
"commands.music.join.error.connecting.trying.title",
"commands.music.join.error.connecting.trying.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.music.join.error.channel.title",
"commands.music.join.error.channel.description")

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.music;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
@ -11,23 +23,23 @@ import com.bbn.hadder.utils.MessageEditor;
public class LeaveCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
event.getGuild().getAudioManager().closeAudioConnection();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
public void executed(String[] args, CommandEvent e) {
if (e.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
if (e.getMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().getChannel().equals(e.getMember().getVoiceState().getChannel())) {
e.getGuild().getAudioManager().closeAudioConnection();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.leave.success.title",
"commands.music.leave.success.description")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.leave.error.channel.title",
"commands.music.leave.error.channel.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.music.leave.error.connected.tile",
"commands.music.leave.error.connected.description")

View file

@ -1,34 +1,46 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
/**
* @author Skidder / GregTCLTK
*/
public class LoopCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
if (event.getAudioManager().getTrackManager(event.getGuild()).isLoop()) {
event.getAudioManager().getTrackManager(event.getGuild()).setLoop(false);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.music.loop.success.unloop.title", "commands.music.loop.success.unloop.description").build()).queue();
public void executed(String[] args, CommandEvent e) {
if (e.getAudioManager().hasPlayer(e.getGuild()) && e.getAudioManager().getPlayer(e.getGuild()).getPlayingTrack() != null) {
if (e.getMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().getChannel().equals(e.getMember().getVoiceState().getChannel())) {
if (e.getAudioManager().getTrackManager(e.getGuild()).isLoop()) {
e.getAudioManager().getTrackManager(e.getGuild()).setLoop(false);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.music.loop.success.unloop.title", "commands.music.loop.success.unloop.description").build()).queue();
} else {
event.getAudioManager().getTrackManager(event.getGuild()).setLoop(true);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.music.loop.success.loop.title", "commands.music.loop.success.loop.description").build()).queue();
e.getAudioManager().getTrackManager(e.getGuild()).setLoop(true);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "commands.music.loop.success.loop.title", "commands.music.loop.success.loop.description").build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.loop.error.connected.title",
"commands.music.loop.error.connected.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.music;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
@ -11,29 +23,29 @@ import com.bbn.hadder.utils.MessageEditor;
public class PauseCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
if (!event.getAudioManager().getPlayer(event.getGuild()).isPaused()) {
event.getAudioManager().getPlayer(event.getGuild()).setPaused(true);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
public void executed(String[] args, CommandEvent e) {
if (e.getAudioManager().hasPlayer(e.getGuild()) && e.getAudioManager().getPlayer(e.getGuild()).getPlayingTrack() != null) {
if (e.getMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().getChannel().equals(e.getMember().getVoiceState().getChannel())) {
if (!e.getAudioManager().getPlayer(e.getGuild()).isPaused()) {
e.getAudioManager().getPlayer(e.getGuild()).setPaused(true);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.pause.success.title",
"commands.music.pause.success.description")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.pause.error.paused.title",
"commands.music.pause.error.paused.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.pause.error.connected.title",
"commands.music.pause.error.connected.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
@ -8,55 +24,51 @@ import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import java.net.URL;
/**
* @author Skidder / GregTCLTK
*/
public class PlayCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
if (event.getMember().getVoiceState().inVoiceChannel()) {
String input = event.getMessage().getContentRaw().replaceFirst(event.getRethink().getGuildPrefix(event.getGuild().getId()) + "play ", "").replaceFirst(event.getRethink().getUserPrefix(event.getAuthor().getId()) + "play ", "");
if (e.getMember().getVoiceState().inVoiceChannel()) {
String input = e.getMessage().getContentRaw().replaceFirst(e.getRethinkServer().getPrefix() + "play ", "").replaceFirst(e.getRethinkUser().getPrefix() + "play ", "");
try {
new URL(input).toURI();
Message msg = event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
Message msg = e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.play.load.title", "",
"commands.music.play.load.description", "").build()).complete();
event.getAudioManager().loadTrack(input, event, msg);
} catch (InsufficientPermissionException e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getAudioManager().loadTrack(input, e, msg);
} catch (InsufficientPermissionException ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.join.error.permission.title",
"commands.music.join.error.permission.description")
.build()).queue();
} catch (Exception ignore) {
Message msg = event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
Message msg = e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.play.load.title", "",
"commands.music.play.load.description", "").build()).complete();
event.getAudioManager().loadTrack("ytsearch: " + input, event, msg);
e.getAudioManager().loadTrack("ytsearch: " + input, e, msg);
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.music.join.error.channel.title",
"commands.music.join.error.channel.description")
.build()).queue();
}
} else if (event.getAudioManager().getPlayer(event.getGuild()).isPaused()) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
event.getAudioManager().getPlayer(event.getGuild()).setPaused(false);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
} else if (e.getAudioManager().getPlayer(e.getGuild()).isPaused()) {
if (e.getMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().getChannel().equals(e.getMember().getVoiceState().getChannel())) {
e.getAudioManager().getPlayer(e.getGuild()).setPaused(false);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.play.success.unpause.title",
"commands.music.play.success.unpause.description")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.play.error.connected.title",
"commands.music.play.error.connected.description")
.build()).queue();
}
} else event.getHelpCommand().sendHelp(this, event);
} else e.getHelpCommand().sendHelp(this, e);
}
@Override

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.audio.AudioInfo;
@ -7,29 +23,25 @@ import com.bbn.hadder.utils.MessageEditor;
import java.util.Set;
/**
* @author Skidder / GregTCLTK
*/
public class QueueCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (!event.getAudioManager().hasPlayer(event.getGuild()) || event.getAudioManager().getTrackManager(event.getGuild()).getQueuedTracks().isEmpty()) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
public void executed(String[] args, CommandEvent e) {
if (!e.getAudioManager().hasPlayer(e.getGuild()) || e.getAudioManager().getTrackManager(e.getGuild()).getQueuedTracks().isEmpty()) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.queue.error.title",
"commands.music.queue.error.description"
).build()).queue();
} else {
Set<AudioInfo> queue = event.getAudioManager().getTrackManager(event.getGuild()).getQueuedTracks();
Set<AudioInfo> queue = e.getAudioManager().getTrackManager(e.getGuild()).getQueuedTracks();
StringBuilder builder = new StringBuilder();
long queuelength = 0;
for (AudioInfo g : queue) {
queuelength = queuelength + g.getTrack().getInfo().length;
builder.append("("+event.getAudioManager().getTimestamp(g.getTrack().getInfo().length)+") **").append(g.getTrack().getInfo().author).append("**: `").append(g.getTrack().getInfo().title).append("` \n");
builder.append("("+e.getAudioManager().getTimestamp(g.getTrack().getInfo().length)+") **").append(g.getTrack().getInfo().author).append("**: `").append(g.getTrack().getInfo().title).append("` \n");
}
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.queue.success.title", "("+String.valueOf(event.getAudioManager().getTimestamp(queuelength))+")",
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.queue.success.title", "("+String.valueOf(e.getAudioManager().getTimestamp(queuelength))+")",
"commands.music.queue.success.description", builder.toString())
.build()).queue();
}

View file

@ -0,0 +1,104 @@
/*
* @author Hax / Hax6775 / Schlauer_Hax
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
import com.bbn.hadder.core.Perms;
import net.dv8tion.jda.api.audio.AudioReceiveHandler;
import net.dv8tion.jda.api.audio.AudioSendHandler;
import net.dv8tion.jda.api.audio.UserAudio;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.managers.AudioManager;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@Perms(Perm.BOT_OWNER)
public class RecordCommand implements Command {
private final HashMap<String, Queue<byte[]>> queue = new HashMap<>();
@Override
public void executed(String[] args, CommandEvent event) {
Guild guild = event.getMember().getVoiceState().getChannel().getGuild();
AudioManager audioManager = guild.getAudioManager();
EchoHandler handler = new EchoHandler(queue);
if (!audioManager.isConnected()) {
audioManager.setSendingHandler(handler);
audioManager.setReceivingHandler(handler);
audioManager.openAudioConnection(event.getMember().getVoiceState().getChannel());
} else {
for (Map.Entry<String, Queue<byte[]>> key : queue.entrySet()) {
File file = new File("./"+event.getJDA().getUserById(key.getKey())+".wav");
}
}
}
public static class EchoHandler implements AudioSendHandler, AudioReceiveHandler {
private HashMap<String, Queue<byte[]>> queue;
public EchoHandler(HashMap<String, Queue<byte[]>> queue) {
this.queue = queue;
}
@Override
public boolean canProvide() {
return false;
}
@Nullable
@Override
public ByteBuffer provide20MsAudio() {
return null;
}
@Override
public void handleUserAudio(@Nonnull UserAudio userAudio) {
if (queue.containsKey(userAudio.getUser().getId())) {
queue.get(userAudio.getUser().getId()).add(userAudio.getAudioData(1.0f));
} else {
Queue<byte[]> newqueue = new ConcurrentLinkedQueue<>();
newqueue.add(userAudio.getAudioData(1.0f));
queue.put(userAudio.getUser().getId(), newqueue);
}
}
public HashMap<String, Queue<byte[]>> getQueue() {
return queue;
}
}
@Override
public String[] labels() {
return new String[]{"echo"};
}
@Override
public String description() {
return null;
}
@Override
public String usage() {
return null;
}
@Override
public String example() {
return null;
}
}

View file

@ -1,30 +1,42 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
/**
* @author Skidder / GregTCLTK
*/
public class SkipCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && !event.getAudioManager().getTrackManager(event.getGuild()).getQueuedTracks().isEmpty()) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
event.getAudioManager().forceSkipTrack(event);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
public void executed(String[] args, CommandEvent e) {
if (e.getAudioManager().hasPlayer(e.getGuild()) && !e.getAudioManager().getTrackManager(e.getGuild()).getQueuedTracks().isEmpty()) {
if (e.getMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().getChannel().equals(e.getMember().getVoiceState().getChannel())) {
e.getAudioManager().forceSkipTrack(e);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.skip.success.title",
"commands.music.skip.success.description").build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.skip.error.connected.title",
"commands.music.skip.error.connected.description ").build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}

View file

@ -1,34 +1,46 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
/**
* @author Skidder / GregTCLTK
*/
public class StopCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
event.getAudioManager().players.remove(event.getGuild().getId());
event.getAudioManager().getPlayer(event.getGuild()).destroy();
event.getAudioManager().getTrackManager(event.getGuild()).purgeQueue();
event.getGuild().getAudioManager().closeAudioConnection();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
public void executed(String[] args, CommandEvent e) {
if (e.getAudioManager().hasPlayer(e.getGuild()) && e.getAudioManager().getPlayer(e.getGuild()).getPlayingTrack() != null) {
if (e.getMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().getChannel().equals(e.getMember().getVoiceState().getChannel())) {
e.getAudioManager().players.remove(e.getGuild().getId());
e.getAudioManager().getPlayer(e.getGuild()).destroy();
e.getAudioManager().getTrackManager(e.getGuild()).purgeQueue();
e.getGuild().getAudioManager().closeAudioConnection();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.stop.success.title",
"commands.music.stop.success.description").build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.stop.error.connected.title",
"commands.music.stop.error.connected.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}

View file

@ -1,49 +1,59 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.music;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
/**
* @author Skidder / GregTCLTK
*/
public class VolumeCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
if (e.getAudioManager().hasPlayer(e.getGuild()) && e.getAudioManager().getPlayer(e.getGuild()).getPlayingTrack() != null) {
if (e.getMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && e.getGuild().getSelfMember().getVoiceState().getChannel().equals(e.getMember().getVoiceState().getChannel())) {
try {
int volume = Integer.parseInt(args[0]);
if (volume < 201 && volume > 0 || event.getConfig().getOwners().contains(event.getAuthor().getIdLong())) {
event.getAudioManager().getPlayer(event.getGuild()).setVolume(volume);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
if (volume < 201 && volume > 0 || e.getConfig().getOwners().contains(e.getAuthor().getIdLong())) {
e.getAudioManager().getPlayer(e.getGuild()).setVolume(volume);
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.volume.success.title", "",
"commands.music.volume.success.description", String.valueOf(volume)).build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.volume.error.int.title",
"commands.music.volume.error.int.description").build()).queue();
}
} catch (NumberFormatException e) {
event.getHelpCommand().sendHelp(this, event);
} catch (Exception e) {
e.printStackTrace();
} catch (NumberFormatException ex) {
e.getHelpCommand().sendHelp(this, e);
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.volume.error.connected.title",
"commands.music.volume.error.connected.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}
} else event.getHelpCommand().sendHelp(this, event);
} else e.getHelpCommand().sendHelp(this, e);
}
@Override

View file

@ -1,47 +1,39 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class AnalCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/anal/").build();
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Anal")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/anal/");
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Anal")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,47 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class BDSMCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/img/bdsm_lewd").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/img/bdsm_lewd");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("BDSM")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("BDSM")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,44 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class BlowjobCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://nekos.life/api/v2/img/blowjob").build();
String url = Http.getNSFW("https://nekos.life/api/v2/img/blowjob");
try {
Response response = caller.newCall(request).execute();
String url = response.body().string().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Blowjob")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Blowjob")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,48 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class BoobsCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/tits/").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/tits/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Boobs")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Boobs")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,48 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class CumCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/cum/").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/cum/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Cum")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Cum")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,44 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class EroticCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://nekos.life/api/v2/img/erok").build();
String url = Http.getNSFW("https://nekos.life/api/v2/img/erok");
try {
Response response = caller.newCall(request).execute();
String url = response.body().string().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Erotic")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Erotic")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,48 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class FeetCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/feet/").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/feet/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Feet")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Feet")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,48 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class FingeringCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/pussy_wank/").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/pussy_wank/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Fingering")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Fingering")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,48 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class LickingCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/kuni/").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/kuni/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Licking")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Licking")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,48 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class PornCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/classic/").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/classic/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Porn")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Porn")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,44 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class PussyCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://nekos.life/api/v2/img/pussy").build();
String url = Http.getNSFW("https://nekos.life/api/v2/img/pussy/");
try {
Response response = caller.newCall(request).execute();
String url = response.body().string().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Pussy")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Pussy")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,52 +1,44 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class RandomPornCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/all_tags/")
.build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/all_tags/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel()
.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"),
url.replace("\"}", ""))
.setImage(url.replace("\"}", "")).setFooter("Random Porn").build())
.queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel()
.sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Random Porn")
.build()).queue();
} else {
event.getTextChannel()
.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build())
.queue();
e.getTextChannel()
.sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,48 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class SoloCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/girls_solo/").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/girls_solo/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url.replace("\"}", ""))
.setImage(url.replace("\"}", ""))
.setFooter("Solo")
.build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Solo")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,49 +1,42 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class SpankCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://api.nekos.dev/api/v3/images/nsfw/gif/spank/").build();
String url = Http.getNSFW("https://api.nekos.dev/api/v3/images/nsfw/gif/spank/");
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
String url = response1.toString().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"),
url.replace("\"}", ""))
.setImage(url.replace("\"}", "")).setFooter("Spank").build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Spank")
.build()).queue();
} else {
event.getTextChannel()
.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build())
.queue();
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,45 +1,43 @@
package com.bbn.hadder.commands.nsfw;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.nsfw;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import com.bbn.hadder.utils.Http;
public class TransCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getTextChannel().isNSFW()) {
public void executed(String[] args, CommandEvent e) {
if (e.getTextChannel().isNSFW()) {
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("https://nekos.life/api/v2/img/trap").build();
String url = Http.getNSFW("https://nekos.life/api/v2/img/trap/");
try {
Response response = caller.newCall(request).execute();
String url = response.body().string().replace("{\"url\":\"", "");
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(event.getMessageEditor().getTerm("commands.nsfw.gif.error.title"),
url.replace("\"}", ""))
.setImage(url.replace("\"}", "")).setFooter("Trans").build()).queue();
} catch (IOException e) {
e.printStackTrace();
}
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setAuthor(e.getMessageEditor().getTerm("commands.nsfw.gif.error.title"), url)
.setImage(url)
.setFooter("Trans")
.build()).queue();
} else {
event.getTextChannel()
.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build())
.queue();
e.getTextChannel()
.sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_NSFW).build()).queue();
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.owner;
/*
* @author Hax / Hax6775 / Schlauer_Hax
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.owner;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -21,15 +33,14 @@ import java.util.List;
public class BlacklistCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length == 0) {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
} else {
switch (args[0].toLowerCase()) {
case "add":
if (args.length == 3) {
Member member = event.getMessage().getMentionedMembers().get(0);
String blacklisted = event.getRethink().getBlackListed(member.getId());
String blacklisted = e.getRethinkUser().getBlacklisted();
List<String> commands = new ArrayList<>();
if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(",")));
commands.addAll(Arrays.asList(args[1].split(",")));
@ -37,19 +48,19 @@ public class BlacklistCommand implements Command {
ArrayList<String> commandsWithoutDuplicates = new ArrayList<>(hashSet);
String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none");
event.getRethink().setBlackListed(member.getId(), newblacklisted);
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
e.getRethinkUser().setBlacklisted(newblacklisted);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Removed Blacklisted Commands from User")
.setDescription("Blacklisted commands: "+newblacklisted)
.build()).queue();
e.getRethinkUser().push();
}
break;
case "remove":
if (args.length == 3) {
Member member = event.getMessage().getMentionedMembers().get(0);
String blacklisted = event.getRethink().getBlackListed(member.getId());
String blacklisted = e.getRethinkUser().getBlacklisted();
List<String> commands = new ArrayList<>();
if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(",")));
commands.removeAll(Arrays.asList(args[1].split(",")));
@ -57,34 +68,35 @@ public class BlacklistCommand implements Command {
ArrayList<String> commandsWithoutDuplicates = new ArrayList<>(hashSet);
String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none");
event.getRethink().setBlackListed(member.getId(), newblacklisted);
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
e.getRethinkUser().setBlacklisted(newblacklisted);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Removed Blacklisted Commands from User")
.setDescription("Blacklisted commands: "+newblacklisted)
.build()).queue();
e.getRethinkUser().push();
}
break;
case "list":
StringBuilder stringBuilder = new StringBuilder();
for (User user : event.getJDA().getUsers()) {
if (!user.getId().equals(event.getJDA().getSelfUser().getId())) {
String blacklisted = event.getRethink().getBlackListed(user.getId());
for (User user : e.getJDA().getUsers()) {
if (!user.getId().equals(e.getJDA().getSelfUser().getId())) {
String blacklisted = e.getRethinkUser().getBlacklisted();
if (!"none".equals(blacklisted)) {
stringBuilder.append(user.getAsTag()).append(" (").append(user.getId()).append(") - ").append(blacklisted).append("\n");
}
}
}
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Blacklisted Users:")
.setDescription((stringBuilder.length()!=0) ? ("``" + stringBuilder.toString() + "``") : "No blacklisted Users")
.build()).queue();
break;
default:
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
break;
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.owner;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.owner;
import com.bbn.hadder.Hadder;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
@ -22,7 +34,7 @@ import java.util.concurrent.TimeUnit;
public class EvalCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
@ -32,18 +44,18 @@ public class EvalCommand implements Command {
ex.printStackTrace();
}
engine.put("msg".toLowerCase(), event.getMessage());
engine.put("msg".toLowerCase(), e.getMessage());
engine.put("shardmanager".toLowerCase(), Hadder.shardManager);
engine.put("rethink".toLowerCase(), event.getRethink());
engine.put("event".toLowerCase(), event);
engine.put("jda".toLowerCase(), event.getJDA());
engine.put("message".toLowerCase(), event.getMessage());
engine.put("guild".toLowerCase(), event.getGuild());
engine.put("channel".toLowerCase(), event.getChannel());
engine.put("author".toLowerCase(), event.getAuthor());
engine.put("member".toLowerCase(), event.getMember());
engine.put("self".toLowerCase(), event.getGuild().getSelfMember());
engine.put("audio".toLowerCase(), event.getAudioManager());
engine.put("rethink".toLowerCase(), e.getRethink());
engine.put("e".toLowerCase(), e);
engine.put("jda".toLowerCase(), e.getJDA());
engine.put("message".toLowerCase(), e.getMessage());
engine.put("guild".toLowerCase(), e.getGuild());
engine.put("channel".toLowerCase(), e.getChannel());
engine.put("author".toLowerCase(), e.getAuthor());
engine.put("member".toLowerCase(), e.getMember());
engine.put("self".toLowerCase(), e.getGuild().getSelfMember());
engine.put("audio".toLowerCase(), e.getAudioManager());
engine.put("out".toLowerCase(), System.out);
ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
@ -61,21 +73,21 @@ public class EvalCommand implements Command {
}
out = engine.eval(script.toString());
event.getTextChannel().sendMessage(event.getMessageEditor()
e.getTextChannel().sendMessage(e.getMessageEditor()
.getMessage(MessageEditor.MessageType.INFO, "commands.owner.eval.success.title", "")
.addField(event.getMessageEditor().getTerm("commands.owner.eval.success.input"),
.addField(e.getMessageEditor().getTerm("commands.owner.eval.success.input"),
"```java\n\n" + script + "```", false)
.addField(event.getMessageEditor().getTerm("commands.owner.eval.success.output"),
.addField(e.getMessageEditor().getTerm("commands.owner.eval.success.output"),
"```java\n\n" + out.toString() + "```", false)
.addField(event.getMessageEditor().getTerm("commands.owner.eval.success.timing"),
.addField(e.getMessageEditor().getTerm("commands.owner.eval.success.timing"),
System.currentTimeMillis() - startExec + " milliseconds", false)
.build()).queue();
} catch (Exception ex) {
event.getTextChannel().sendMessage(event.getMessageEditor()
e.getTextChannel().sendMessage(e.getMessageEditor()
.getMessage(MessageEditor.MessageType.INFO, "commands.owner.eval.success.title", "")
.addField(event.getMessageEditor().getTerm("error"),
.addField(e.getMessageEditor().getTerm("error"),
"```java\n\n" + ex.getMessage() + "```", false)
.addField(event.getMessageEditor().getTerm("commands.owner.eval.success.timing"),
.addField(e.getMessageEditor().getTerm("commands.owner.eval.success.timing"),
System.currentTimeMillis() - startExec + " milliseconds", false)
.build()).queue();
@ -86,7 +98,7 @@ public class EvalCommand implements Command {
}, 0, TimeUnit.MILLISECONDS);
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.owner;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.owner;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -15,22 +27,22 @@ import net.dv8tion.jda.api.entities.Guild;
public class GuildLeaveCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length > 0) {
Guild guild = event.getJDA().getGuildById(args[0]);
Guild guild = e.getJDA().getGuildById(args[0]);
try {
guild.leave().queue();
event.getTextChannel()
.sendMessage(event.getMessageEditor()
e.getTextChannel()
.sendMessage(e.getMessageEditor()
.getMessage(MessageEditor.MessageType.INFO, "commands.owner.guildleave.success.title",
"", "commands.owner.guildleave.success.description", guild.getName())
.build())
.queue();
} catch (Exception e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.owner.guildleave.error.title", "", "commands.owner.guildleave.help.description", guild.getName()).build()).queue();
} catch (Exception ex) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, "commands.owner.guildleave.error.title", "", "commands.owner.guildleave.help.description", guild.getName()).build()).queue();
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.owner;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.owner;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -13,7 +25,7 @@ import com.bbn.hadder.core.Perms;
public class RebootCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
Runtime.getRuntime().exit(69);
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.commands.owner;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.owner;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -14,9 +26,9 @@ import com.bbn.hadder.utils.MessageEditor;
public class ShutdownCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO).setTitle("Shutdown").build()).queue();
event.getJDA().getShardManager().shutdown();
public void executed(String[] args, CommandEvent e) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO).setTitle("Shutdown").build()).queue();
e.getJDA().getShardManager().shutdown();
System.out.println("Bot shut down via Command...");
Runtime.getRuntime().exit(69);
}

View file

@ -1,18 +1,30 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.owner;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor.MessageType;
/*
* @author Skidder / GregTCLTK
*/
public class TestCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageType.INFO, "commands.owner.test.success", "").build()).queue();
public void executed(String[] args, CommandEvent e) {
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageType.INFO, "commands.owner.test.success", "").build()).queue();
}
@Override

View file

@ -1,55 +1,74 @@
package com.bbn.hadder.commands.settings;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.settings;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
public class LanguageCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length == 1) {
switch (args[0].toLowerCase()) {
case "de":
setLanguage("de", "German", event);
break;
case "en":
setLanguage("en", "English", event);
break;
case "es":
setLanguage("es", "Spanish", event);
break;
case "fr":
setLanguage("fr", "French", event);
break;
case "ru":
setLanguage("ru", "Russian", event);
break;
case "tr":
setLanguage("tr", "Turkish", event);
break;
case "zh":
setLanguage("zh", "Chinese", event);
case "de":
setLanguage("de", "German", e);
break;
case "en":
setLanguage("en", "English", e);
break;
case "es":
setLanguage("es", "Spanish", e);
break;
case "fr":
setLanguage("fr", "French", e);
break;
case "ru":
setLanguage("ru", "Russian", e);
break;
case "tr":
setLanguage("tr", "Turkish", e);
break;
case "zh":
setLanguage("zh", "Chinese", e);
break;
default:
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"List",
"`de`, `en`, `es`, `fr`, `ru`, `tr`, `zh`")
.build()).queue();
break;
}
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}
public void setLanguage(String language_code, String language, CommandEvent event) {
event.getRethink().setLanguage(event.getAuthor().getId(), language_code);
event.getTextChannel()
public void setLanguage(String language_code, String language, CommandEvent e) {
e.getRethinkUser().setLanguage(language_code);
e.getTextChannel()
.sendMessage(
event.getMessageEditor()
e.getMessageEditor()
.getMessage(MessageEditor.MessageType.INFO, "commands.settings.language.success.title",
"", "commands.settings.language.success.description", language)
.build())
.queue();
.build()).queue();
e.getRethinkUser().push();
}
@Override

View file

@ -1,26 +1,39 @@
package com.bbn.hadder.commands.settings;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.settings;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
public class UserPrefixCommand implements Command {
public void executed(String[] args, CommandEvent event) {
public void executed(String[] args, CommandEvent e) {
if (args.length == 1) {
event.getRethink().setUserPrefix(args[0], event.getAuthor().getId());
event.getTextChannel()
.sendMessage(event.getMessageEditor()
e.getRethinkUser().setPrefix(args[0]);
e.getTextChannel()
.sendMessage(e.getMessageEditor()
.getMessage(MessageEditor.MessageType.INFO, "commands.settings.prefix.success.title", "",
"commands.settings.prefix.success.description", args[0])
.build())
.queue();
e.getRethinkUser().push();
} else {
event.getHelpCommand().sendHelp(this, event);
e.getHelpCommand().sendHelp(this, e);
}
}

View file

@ -1,6 +1,24 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.core;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer;
import com.bbn.hadder.RethinkUser;
import com.bbn.hadder.audio.AudioManager;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
@ -24,7 +42,7 @@ public class CommandHandler {
this.helpCommand = helpCommand;
}
public void handle(MessageReceivedEvent event, Rethink rethink, String prefix, AudioManager audioManager) {
public void handle(MessageReceivedEvent event, Rethink rethink, String prefix, AudioManager audioManager, RethinkUser rethinkUser, RethinkServer rethinkServer) {
String invoke = event.getMessage().getContentRaw().replaceFirst(prefix, "").split(" ")[0];
for (Command cmd : commandList) {
for (String label : cmd.labels()) {
@ -36,7 +54,7 @@ public class CommandHandler {
if (args.length > 0 && args[0].equals("")) args = new String[0];
CommandEvent commandEvent = new CommandEvent(event.getJDA(), event.getResponseNumber(), event.getMessage(), rethink,
config, this, helpCommand, new MessageEditor(rethink, event.getAuthor()), new EventWaiter(), audioManager);
config, this, helpCommand, new MessageEditor(rethinkUser, event.getAuthor()), new EventWaiter(), audioManager, rethinkUser, rethinkServer);
if (cmd.getClass().getAnnotations().length > 0 && !Arrays.asList(cmd.getClass().getAnnotations()).contains(Perms.class)) {
for (Perm perm : cmd.getClass().getAnnotation(Perms.class).value()) {
if (!perm.check(commandEvent)) {
@ -50,7 +68,7 @@ public class CommandHandler {
}
boolean run = true;
String blacklisted = rethink.getBlackListed(event.getAuthor().getId());
String blacklisted = rethinkUser.getBlacklisted();
if (!"none".equals(blacklisted)) {
for (String BLLabel : blacklisted.split(",")) {
if (Arrays.asList(cmd.labels()).contains(BLLabel)) {

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.core;
import org.json.JSONObject;

View file

@ -1,75 +1,86 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.core;
import com.bbn.hadder.commands.CommandEvent;
import net.dv8tion.jda.api.Permission;
/**
* @author Skidder / GregTCLTK
* @author Hax / Hax6775 / Schlauer_Hax
*/
public enum Perm {
BOT_OWNER() {
@Override
public boolean check(CommandEvent event) {
return event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
MANAGE_MESSAGES {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.MESSAGE_MANAGE) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.MESSAGE_MANAGE) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
EMBED_MESSAGES {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.MESSAGE_EMBED_LINKS) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.MESSAGE_EMBED_LINKS) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
BAN_MEMBERS {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.BAN_MEMBERS) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.BAN_MEMBERS) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
KICK_MEMBERS {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.KICK_MEMBERS) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.KICK_MEMBERS) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
MANAGE_SERVER {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.MANAGE_SERVER) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.MANAGE_SERVER) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
MANAGE_ROLES {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.MANAGE_ROLES) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.MANAGE_ROLES) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
MANAGE_NICKNAMES {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.NICKNAME_MANAGE) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.NICKNAME_MANAGE) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
ADMINISTRATOR {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.ADMINISTRATOR) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.ADMINISTRATOR) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
},
MANAGE_WEBHOOKS {
@Override
public boolean check(CommandEvent event) {
return event.getMember().hasPermission(Permission.MANAGE_WEBHOOKS) || event.getConfig().getOwners().contains(event.getAuthor().getIdLong());
public boolean check(CommandEvent e) {
return e.getMember().hasPermission(Permission.MANAGE_WEBHOOKS) || e.getConfig().getOwners().contains(e.getAuthor().getIdLong());
}
};
public abstract boolean check(CommandEvent event);
public abstract boolean check(CommandEvent e);
}

View file

@ -1,13 +1,24 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.core;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* @author Skidder / GregTCLTK
* @author Hax / Hax6775 / Schlauer_Hax
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Perms {
Perm[] value() default {};

View file

@ -1,15 +1,34 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer;
import com.bbn.hadder.RethinkUser;
import com.bbn.hadder.audio.AudioManager;
import com.bbn.hadder.core.CommandHandler;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
/*
* @author Skidder / GregTCLTK
*/
import java.awt.*;
import java.time.Instant;
public class CommandListener extends ListenerAdapter {
@ -24,19 +43,43 @@ public class CommandListener extends ListenerAdapter {
}
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.isFromType(ChannelType.TEXT) && !event.getAuthor().isBot()) {
String[] prefixes = {
rethink.getUserPrefix(event.getAuthor().getId()), rethink.getGuildPrefix(event.getGuild().getId()),
event.getGuild().getSelfMember().getAsMention() + " ", event.getGuild().getSelfMember().getAsMention(),
event.getGuild().getSelfMember().getAsMention().replace("@", "@!") + " ",
event.getGuild().getSelfMember().getAsMention().replace("@", "@!")
};
for (String prefix : prefixes) {
if (event.getMessage().getContentRaw().startsWith(prefix)) {
handler.handle(event, rethink, prefix, audioManager);
return;
public void onMessageReceived(MessageReceivedEvent e) {
if (e.isFromType(ChannelType.TEXT) && !e.getAuthor().isBot()) {
if (e.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_WRITE)) {
if (e.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_EMBED_LINKS)) {
RethinkUser rethinkUser = new RethinkUser(rethink.getObjectByID("user", e.getAuthor().getId()), rethink);
RethinkServer rethinkServer = new RethinkServer(rethink.getObjectByID("server", e.getGuild().getId()), rethink);
rethinkUser.push();
rethinkServer.push();
String[] prefixes = {
rethinkUser.getPrefix(), rethinkServer.getPrefix(),
e.getGuild().getSelfMember().getAsMention() + " ", e.getGuild().getSelfMember().getAsMention(),
e.getGuild().getSelfMember().getAsMention().replace("@", "@!") + " ",
e.getGuild().getSelfMember().getAsMention().replace("@", "@!")
};
for (String prefix : prefixes) {
if (e.getMessage().getContentRaw().startsWith(prefix)) {
handler.handle(e, rethink, prefix, audioManager, rethinkUser, rethinkServer);
return;
}
}
} else {
e.getAuthor().openPrivateChannel().complete().sendMessage(new EmbedBuilder()
.setTitle("No permission")
.setDescription("I need the `MESSAGE EMBED LINKS` permission in order to work!")
.setColor(Color.RED)
.setFooter("Hadder", "https://bigbotnetwork.com/images/Hadder.png")
.setTimestamp(Instant.now())
.build()).queue();
}
} else {
e.getAuthor().openPrivateChannel().complete().sendMessage(new EmbedBuilder()
.setTitle("No permission")
.setDescription("I need the `MESSAGE WRITE` permission in order to work!")
.setColor(Color.RED)
.setFooter("Hadder", "https://bigbotnetwork.com/images/Hadder.png")
.setTimestamp(Instant.now())
.build()).queue();
}
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.listener;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.core.Config;
import com.bbn.hadder.utils.BotList;
@ -26,48 +38,48 @@ public class GuildListener extends ListenerAdapter {
this.config = config;
}
public void onGuildJoin(GuildJoinEvent event) {
public void onGuildJoin(GuildJoinEvent e) {
new Thread(() -> {
for (Member member : event.getGuild().getMembers()) {
if (!member.getUser().getId().equals(event.getJDA().getSelfUser().getId())) {
for (Member member : e.getGuild().getMembers()) {
if (!member.getUser().getId().equals(e.getJDA().getSelfUser().getId())) {
rethink.insertUser(member.getUser().getId());
}
}
}).start();
rethink.insertGuild(event.getGuild().getId());
event.getJDA().getTextChannelById("475722540140986369").sendMessage(new MessageEditor(null, null).getMessage(MessageEditor.MessageType.INFO)
rethink.insertGuild(e.getGuild().getId());
e.getJDA().getTextChannelById("475722540140986369").sendMessage(new MessageEditor(null, null).getMessage(MessageEditor.MessageType.INFO)
.setTitle("Joined Server")
.setThumbnail(event.getGuild().getIconUrl())
.addField("Name", event.getGuild().getName(), true)
.addField("Guild ID", event.getGuild().getId(), true)
.addField("Guild Owner", event.getGuild().getOwner().getUser().getAsTag(), true)
.addField("Users", String.valueOf(event.getGuild().getMembers().size()), true)
.setFooter(event.getJDA().getSelfUser().getName(), event.getJDA().getSelfUser().getAvatarUrl())
.setThumbnail(e.getGuild().getIconUrl())
.addField("Name", e.getGuild().getName(), true)
.addField("Guild ID", e.getGuild().getId(), true)
.addField("Guild Owner", e.getGuild().getOwner().getUser().getAsTag(), true)
.addField("Users", String.valueOf(e.getGuild().getMembers().size()), true)
.setFooter(e.getJDA().getSelfUser().getName(), e.getJDA().getSelfUser().getAvatarUrl())
.setTimestamp(Instant.now())
.build()).queue();
new BotList(config).post();
}
public void onGuildLeave(GuildLeaveEvent event) {
event.getJDA().getTextChannelById("475722540140986369").sendMessage(new MessageEditor(null, null).getMessage(MessageEditor.MessageType.INFO)
public void onGuildLeave(GuildLeaveEvent e) {
e.getJDA().getTextChannelById("475722540140986369").sendMessage(new MessageEditor(null, null).getMessage(MessageEditor.MessageType.INFO)
.setTitle("Left Server")
.setThumbnail(event.getGuild().getIconUrl())
.addField("Name", event.getGuild().getName(), true)
.addField("Guild ID", event.getGuild().getId(), true)
.addField("Guild Owner", event.getGuild().getOwner().getUser().getAsTag(), true)
.addField("Users", String.valueOf(event.getGuild().getMembers().size()), true)
.setFooter(event.getJDA().getSelfUser().getName(), event.getJDA().getSelfUser().getAvatarUrl())
.setThumbnail(e.getGuild().getIconUrl())
.addField("Name", e.getGuild().getName(), true)
.addField("Guild ID", e.getGuild().getId(), true)
.addField("Guild Owner", e.getGuild().getOwner().getUser().getAsTag(), true)
.addField("Users", String.valueOf(e.getGuild().getMembers().size()), true)
.setFooter(e.getJDA().getSelfUser().getName(), e.getJDA().getSelfUser().getAvatarUrl())
.setTimestamp(Instant.now())
.build()).queue();
new BotList(config).post();
}
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
if (!event.getUser().getId().equals(event.getJDA().getSelfUser().getId())) {
rethink.insertUser(event.getUser().getId());
public void onGuildMemberJoin(GuildMemberJoinEvent e) {
if (!e.getUser().getId().equals(e.getJDA().getSelfUser().getId())) {
rethink.insertUser(e.getUser().getId());
}
}
}

View file

@ -1,10 +1,23 @@
package com.bbn.hadder.listener;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
@ -27,12 +40,13 @@ public class InviteLinkListener extends ListenerAdapter {
}
@Override
public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
if (event.getMessage().getContentRaw().contains("discord.gg/") && (!event.getMember().hasPermission(Permission.ADMINISTRATOR) && rethink.getInviteDetection(event.getGuild().getId()))) {
checkInvite(event.getMessage(), "discord.gg/");
} else if (event.getMessage().getContentRaw().contains("discordapp.com/invite") && (!event.getMember().hasPermission(Permission.ADMINISTRATOR) && rethink.getInviteDetection(event.getGuild().getId()))) {
checkInvite(event.getMessage(), "discordapp.com/invite/");
public void onMessageReceived(@Nonnull MessageReceivedEvent e) {
RethinkServer rethinkServer = new RethinkServer(rethink.getObjectByID("server", e.getGuild().getId()), rethink);
if (e.isFromType(ChannelType.TEXT)) {
if (e.getMessage().getContentRaw().contains("discord.gg/") && (!e.getMember().hasPermission(Permission.ADMINISTRATOR) && rethinkServer.isInviteDetect())) {
checkInvite(e.getMessage(), "discord.gg/");
} else if (e.getMessage().getContentRaw().contains("discordapp.com/invite") && (!e.getMember().hasPermission(Permission.ADMINISTRATOR) && rethinkServer.isInviteDetect())) {
checkInvite(e.getMessage(), "discordapp.com/invite/");
}
}
}
@ -54,12 +68,13 @@ public class InviteLinkListener extends ListenerAdapter {
}
@Override
public void onMessageUpdate(@Nonnull MessageUpdateEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
if (event.getMessage().getContentRaw().contains("discord.gg/") && !event.getMember().hasPermission(Permission.ADMINISTRATOR) && rethink.getInviteDetection(event.getGuild().getId())) {
checkInvite(event.getMessage(), "discord.gg/");
} else if (event.getMessage().getContentRaw().contains("discordapp.com/invite") && !event.getMember().hasPermission(Permission.ADMINISTRATOR) && rethink.getInviteDetection(event.getGuild().getId())) {
checkInvite(event.getMessage(), "discordapp.com/invite/");
public void onMessageUpdate(@Nonnull MessageUpdateEvent e) {
RethinkServer rethinkServer = new RethinkServer(rethink.getObjectByID("server", e.getGuild().getId()), rethink);
if (e.isFromType(ChannelType.TEXT)) {
if (e.getMessage().getContentRaw().contains("discord.gg/") && !e.getMember().hasPermission(Permission.ADMINISTRATOR) && rethinkServer.isInviteDetect()) {
checkInvite(e.getMessage(), "discord.gg/");
} else if (e.getMessage().getContentRaw().contains("discordapp.com/invite") && !e.getMember().hasPermission(Permission.ADMINISTRATOR) && rethinkServer.isInviteDetect()) {
checkInvite(e.getMessage(), "discordapp.com/invite/");
}
}
}

View file

@ -1,6 +1,24 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer;
import com.bbn.hadder.RethinkUser;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@ -18,21 +36,25 @@ public class MentionListener extends ListenerAdapter {
}
@Override
public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
if (event.isFromType(ChannelType.TEXT) && (event.getMessage().getContentRaw().equals(event.getGuild().getSelfMember().getAsMention())||
event.getMessage().getContentRaw().equals(event.getGuild().getSelfMember().getAsMention().replace("@", "@!")))) {
event.getChannel().sendMessage(new MessageEditor(rethink, event.getAuthor()).getMessage(MessageEditor.MessageType.INFO)
.setTitle("Hello I'm Hadder.")
.setAuthor(event.getJDA().getSelfUser().getName(), event.getJDA().getSelfUser().getAvatarUrl(), event.getJDA().getSelfUser().getAvatarUrl())
.addField("Users", String.valueOf(event.getJDA().getUsers().size()), false)
.addField("Guilds", String.valueOf(event.getJDA().getGuilds().size()), false)
.addField("Prefix (User)", rethink.getUserPrefix(event.getAuthor().getId()), false)
.addField("Prefix (Guild)", rethink.getGuildPrefix(event.getGuild().getId()), false)
.build()).queue();
} else if (event.getMessage().getContentRaw().equalsIgnoreCase("@someone")) {
int member = new Random().nextInt(event.getGuild().getMembers().size()-1);
if (member>0&&member<event.getGuild().getMembers().size()) {
event.getChannel().sendMessage(event.getGuild().getMembers().get(member).getAsMention()+ " (Executed by: "+event.getAuthor().getAsTag()+")").queue();
public void onMessageReceived(@Nonnull MessageReceivedEvent e) {
if (!e.getAuthor().isBot()) {
RethinkServer rethinkServer = new RethinkServer(rethink.getObjectByID("server", e.getGuild().getId()), rethink);
RethinkUser rethinkUser = new RethinkUser(rethink.getObjectByID("user", e.getAuthor().getId()), rethink);
if (e.isFromType(ChannelType.TEXT) && (e.getMessage().getContentRaw().equals(e.getGuild().getSelfMember().getAsMention()) ||
e.getMessage().getContentRaw().equals(e.getGuild().getSelfMember().getAsMention().replace("@", "@!")))) {
e.getChannel().sendMessage(new MessageEditor(rethinkUser, e.getAuthor()).getMessage(MessageEditor.MessageType.INFO)
.setTitle("Hello I'm Hadder.")
.setAuthor(e.getJDA().getSelfUser().getName(), e.getJDA().getSelfUser().getAvatarUrl(), e.getJDA().getSelfUser().getAvatarUrl())
.addField("Users", String.valueOf(e.getJDA().getUsers().size()), false)
.addField("Guilds", String.valueOf(e.getJDA().getGuilds().size()), false)
.addField("Prefix (User)", rethinkUser.getPrefix(), false)
.addField("Prefix (Guild)", rethinkServer.getPrefix(), false)
.build()).queue();
} else if (e.getMessage().getContentRaw().equalsIgnoreCase("@someone")) {
int member = new Random().nextInt(e.getGuild().getMembers().size() - 1);
if (member > 0 && member < e.getGuild().getMembers().size()) {
e.getChannel().sendMessage(e.getGuild().getMembers().get(member).getAsMention() + " (Executed by: " + e.getAuthor().getAsTag() + ")").queue();
}
}
}
}

View file

@ -1,16 +1,31 @@
package com.bbn.hadder.listener;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkUser;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.PrivateChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import java.awt.*;
import java.time.Instant;
public class PrivateMessageListener extends ListenerAdapter {
@ -21,21 +36,30 @@ public class PrivateMessageListener extends ListenerAdapter {
this.rethink = rethink;
}
public void onMessageReceived(MessageReceivedEvent event) {
if (event.isFromType(ChannelType.PRIVATE) && !event.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) {
PrivateChannel Skidder = event.getJDA().getUserById("477141528981012511").openPrivateChannel().complete();
PrivateChannel Hax = event.getJDA().getUserById("261083609148948488").openPrivateChannel().complete();
public void onMessageReceived(MessageReceivedEvent e) {
if (e.isFromType(ChannelType.PRIVATE) && !e.getAuthor().getId().equals(e.getJDA().getSelfUser().getId())) {
PrivateChannel Skidder = e.getJDA().getUserById("477141528981012511").openPrivateChannel().complete();
PrivateChannel Hax = e.getJDA().getUserById("261083609148948488").openPrivateChannel().complete();
RethinkUser rethinkUser = new RethinkUser(rethink.getObjectByID("user", "261083609148948488"), rethink);
Skidder.sendMessage(new MessageEditor(rethink, event.getJDA().getUserById("261083609148948488")).getMessage(MessageEditor.MessageType.INFO)
.setTitle("New DM by " + event.getAuthor().getAsTag())
.setAuthor(event.getAuthor().getName(), event.getAuthor().getAvatarUrl(), event.getAuthor().getAvatarUrl())
.setDescription(event.getMessage().getContentRaw())
Skidder.sendMessage(new MessageEditor(rethinkUser, e.getJDA().getUserById("261083609148948488")).getMessage(MessageEditor.MessageType.INFO)
.setTitle("New DM by " + e.getAuthor().getAsTag())
.setAuthor(e.getAuthor().getName(), e.getAuthor().getAvatarUrl(), e.getAuthor().getAvatarUrl())
.setDescription(e.getMessage().getContentRaw())
.setTimestamp(Instant.now())
.build()).queue();
Hax.sendMessage(new MessageEditor(rethink, event.getJDA().getUserById("261083609148948488")).getMessage(MessageEditor.MessageType.INFO)
.setTitle("New DM by " + event.getAuthor().getAsTag())
.setAuthor(event.getAuthor().getName(), event.getAuthor().getAvatarUrl(), event.getAuthor().getAvatarUrl())
.setDescription(event.getMessage().getContentRaw())
Hax.sendMessage(new MessageEditor(rethinkUser, e.getJDA().getUserById("261083609148948488")).getMessage(MessageEditor.MessageType.INFO)
.setTitle("New DM by " + e.getAuthor().getAsTag())
.setAuthor(e.getAuthor().getName(), e.getAuthor().getAvatarUrl(), e.getAuthor().getAvatarUrl())
.setDescription(e.getMessage().getContentRaw())
.setTimestamp(Instant.now())
.build()).queue();
e.getChannel().sendMessage(new EmbedBuilder()
.setTitle("No DM support")
.setDescription("You have to execute your commands on a guild!")
.setColor(Color.RED)
.setFooter("Hadder", "https://bigbotnetwork.com/images/Hadder.png")
.setTimestamp(Instant.now())
.build()).queue();
}

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
@ -21,15 +37,15 @@ public class ReadyListener extends ListenerAdapter {
}
@Override
public void onReady(@Nonnull ReadyEvent event) {
public void onReady(@Nonnull ReadyEvent e) {
rethink.setup();
new Thread(() -> {
for (User user : event.getJDA().getUsers()) {
if (!user.getId().equals(event.getJDA().getSelfUser().getId())) {
for (User user : e.getJDA().getUsers()) {
if (!user.getId().equals(e.getJDA().getSelfUser().getId())) {
rethink.insertUser(user.getId());
}
}
for (Guild g : event.getJDA().getGuilds()) {
for (Guild g : e.getJDA().getGuilds()) {
rethink.insertGuild(g.getId());
}
}).start();

View file

@ -1,10 +1,23 @@
package com.bbn.hadder.listener;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer;
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
@ -18,40 +31,43 @@ public class RulesListener extends ListenerAdapter {
}
@Override
public void onMessageReactionAdd(MessageReactionAddEvent event) {
if (event.getMessageId().equals(rethink.getRulesMID(event.getGuild().getId())) && !event.getMember().getUser().isBot()) {
if (event.getReactionEmote().isEmote()) {
if (rethink.getRulesAEmote(event.getGuild().getId()).equals(event.getReactionEmote().getId())) {
addRole(event);
} else if (rethink.getRulesDEmote(event.getGuild().getId()).equals(event.getReactionEmote().getId())) {
event.getReaction().removeReaction(event.getUser()).queue();
if (event.getGuild().getSelfMember().canInteract(event.getMember())) {
event.getMember().kick().reason("Declined the rules");
public void onMessageReactionAdd(MessageReactionAddEvent e) {
RethinkServer rethinkServer = new RethinkServer(rethink.getObjectByID("server", e.getGuild().getId()), rethink);
if (e.getMessageId().equals(rethinkServer.getMessageID()) && !e.getUser().isBot()) {
if (e.getReactionEmote().isEmote()) {
if (rethinkServer.getAcceptEmote().equals(e.getReactionEmote().getId())) {
addRole(e);
} else if (rethinkServer.getDeclineEmote().equals(e.getReactionEmote().getId())) {
e.getReaction().removeReaction(e.getUser()).queue();
if (e.getGuild().getSelfMember().canInteract(e.getMember())) {
e.getMember().kick().reason("Declined the rules");
}
}
} else if (event.getReactionEmote().isEmoji()) {
if (rethink.getRulesAEmote(event.getGuild().getId()).equals(event.getReactionEmote().getEmoji())) {
addRole(event);
} else if (rethink.getRulesDEmote(event.getGuild().getId()).equals(event.getReactionEmote().getEmoji())) {
event.getReaction().removeReaction(event.getUser()).queue();
if (event.getGuild().getSelfMember().canInteract(event.getMember())) {
event.getMember().kick().reason("Declined the rules");
} else if (e.getReactionEmote().isEmoji()) {
if (rethinkServer.getAcceptEmote().equals(e.getReactionEmote().getEmoji())) {
addRole(e);
} else if (rethinkServer.getDeclineEmote().equals(e.getReactionEmote().getEmoji())) {
e.getReaction().removeReaction(e.getUser()).queue();
if (e.getGuild().getSelfMember().canInteract(e.getMember())) {
e.getMember().kick().reason("Declined the rules");
}
}
}
}
}
private void addRole(MessageReactionAddEvent event) {
if (event.getMember().getRoles().contains(event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId())))) {
event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId()))).reason("Accepted rules").queue();
} else event.getGuild().addRoleToMember(event.getMember(), event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId()))).reason("Accepted rules").queue();
private void addRole(MessageReactionAddEvent e) {
RethinkServer rethinkServer = new RethinkServer(rethink.getObjectByID("server", e.getGuild().getId()), rethink);
if (e.getMember().getRoles().contains(e.getGuild().getRoleById(rethinkServer.getRoleID()))) {
e.getGuild().removeRoleFromMember(e.getMember(), e.getGuild().getRoleById(rethinkServer.getRoleID())).reason("Accepted rules").queue();
} else e.getGuild().addRoleToMember(e.getMember(), e.getGuild().getRoleById(rethinkServer.getRoleID())).reason("Accepted rules").queue();
}
@Override
public void onMessageReactionRemove(MessageReactionRemoveEvent event) {
if (event.getMessageId().equals(rethink.getRulesMID(event.getGuild().getId())) && !event.getMember().getUser().isBot()) {
event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(rethink.getRulesRID(event.getGuild().getId()))).reason("Withdrawal of the acceptance of the rules").queue();
public void onMessageReactionRemove(MessageReactionRemoveEvent e) {
RethinkServer rethinkServer = new RethinkServer(rethink.getObjectByID("server", e.getGuild().getId()), rethink);
if (e.getMessageId().equals(rethinkServer.getMessageID()) && !e.getUser().isBot()) {
e.getGuild().removeRoleFromMember(e.getMember(), e.getGuild().getRoleById(rethinkServer.getRoleID())).reason("Withdrawal of the acceptance of the rules").queue();
}
}
}

View file

@ -1,6 +1,23 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.entities.MessageReaction;
@ -20,40 +37,40 @@ public class StarboardListener extends ListenerAdapter {
}
@Override
public void onMessageReactionAdd(@Nonnull MessageReactionAddEvent event) {
update(event);
public void onMessageReactionAdd(@Nonnull MessageReactionAddEvent e) {
update(e);
}
@Override
public void onMessageReactionRemove(@Nonnull MessageReactionRemoveEvent event) {
update(event);
public void onMessageReactionRemove(@Nonnull MessageReactionRemoveEvent e) {
update(e);
}
public void update(GenericMessageReactionEvent event) {
if (event.getReaction().getReactionEmote().getName().equals("")) {
if (!rethink.hasStarboardMessage(event.getMessageId())) {
if (rethink.hasStarboardChannel(event.getGuild().getId())) {
event.getTextChannel().retrieveMessageById(event.getMessageId()).queue(
public void update(GenericMessageReactionEvent e) {
if (e.getReaction().getReactionEmote().getName().equals("")) {
RethinkServer rethinkServer = new RethinkServer(rethink.getObjectByID("server", e.getGuild().getId()), rethink);
if (!rethink.hasStarboardMessage(e.getMessageId())) {
if (rethink.hasStarboardChannel(e.getGuild().getId())) {
e.getTextChannel().retrieveMessageById(e.getMessageId()).queue(
msg -> {
Integer stars = 0;
int stars = 0;
for (MessageReaction reaction : msg.getReactions()) {
if (reaction.getReactionEmote().getName().equals("")) {
stars = reaction.getCount();
}
}
if (Integer.parseInt(rethink.getNeededStars(event.getGuild().getId())) <= stars) {
event.getGuild().getTextChannelById(rethink.getStarboardChannel(event.getGuild().getId()))
if (Integer.parseInt(rethinkServer.getNeededStars()) <= stars) {
e.getGuild().getTextChannelById(rethinkServer.getStarboard())
.sendMessage(new MessageBuilder()
.setContent("⭐ 1" + " " + event.getTextChannel().getAsMention())
.setContent("⭐ 1" + " " + e.getTextChannel().getAsMention())
.setEmbed(
new EmbedBuilder()
.setAuthor(msg.getAuthor().getAsTag())
.setDescription(msg.getContentRaw())
.setTimestamp(msg.getTimeCreated()).build()).build()).queue(
starboardmsg -> {
rethink.insertStarboardMessage(msg.getId(), event.getGuild().getId(), starboardmsg.getId());
rethink.insertStarboardMessage(msg.getId(), e.getGuild().getId(), starboardmsg.getId());
}
);
}
@ -63,23 +80,23 @@ public class StarboardListener extends ListenerAdapter {
}
} else {
event.getTextChannel().retrieveMessageById(event.getMessageId()).queue(
e.getTextChannel().retrieveMessageById(e.getMessageId()).queue(
msg -> {
Integer stars = 0;
int stars = 0;
for (MessageReaction reaction : msg.getReactions()) {
if (reaction.getReactionEmote().getName().equals("")) {
stars = reaction.getCount();
}
}
Integer finalStars = stars;
event.getGuild().getTextChannelById(rethink.getStarboardChannel(event.getGuild().getId()))
.retrieveMessageById(rethink.getStarboardMessage(event.getMessageId())).queue(
int finalStars = stars;
e.getGuild().getTextChannelById(rethinkServer.getStarboard())
.retrieveMessageById(rethink.getStarboardMessage(e.getMessageId())).queue(
msg2 -> {
if (Integer.parseInt(rethink.getNeededStars(event.getGuild().getId())) <= finalStars) {
if (Integer.parseInt(rethinkServer.getNeededStars()) <= finalStars) {
msg2.editMessage(new MessageBuilder()
.setContent("" + finalStars + " " + event.getTextChannel().getAsMention())
.setContent("" + finalStars + " " + e.getTextChannel().getAsMention())
.setEmbed(
new EmbedBuilder()
.setAuthor(msg.getAuthor().getAsTag())
@ -91,10 +108,8 @@ public class StarboardListener extends ListenerAdapter {
}
}
);
}
);
}
}
}

View file

@ -1,13 +1,25 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.listener;
import com.bbn.hadder.audio.AudioManager;
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
/**
* @author Skidder / GregTCLTK
*/
public class VoiceLeaveListener extends ListenerAdapter {
private AudioManager audioManager;
@ -17,12 +29,12 @@ public class VoiceLeaveListener extends ListenerAdapter {
}
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
if (audioManager.hasPlayer(event.getGuild()) && event.getChannelLeft().getMembers().equals(event.getGuild().getSelfMember())) {
audioManager.players.remove(event.getGuild().getId());
audioManager.getPlayer(event.getGuild()).destroy();
audioManager.getTrackManager(event.getGuild()).purgeQueue();
event.getGuild().getAudioManager().closeAudioConnection();
public void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
if (audioManager.hasPlayer(e.getGuild()) && e.getChannelLeft().getMembers().equals(e.getGuild().getSelfMember())) {
audioManager.players.remove(e.getGuild().getId());
audioManager.getPlayer(e.getGuild()).destroy();
audioManager.getTrackManager(e.getGuild()).purgeQueue();
e.getGuild().getAudioManager().closeAudioConnection();
}
}
}

View file

@ -1,9 +1,21 @@
package com.bbn.hadder.utils;
/*
* @author Skidder / GregTCLTK
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.utils;
import com.bbn.hadder.Hadder;
import com.bbn.hadder.core.Config;
import okhttp3.MediaType;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.utils;
import net.dv8tion.jda.api.JDA;

View file

@ -0,0 +1,47 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.utils;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import org.json.JSONObject;
import java.io.IOException;
public class Http {
public static String getNSFW(String url) {
OkHttpClient caller = new OkHttpClient();
okhttp3.Request request = new okhttp3.Request.Builder().url(url).build();
try {
Response response = caller.newCall(request).execute();
JSONObject json = new JSONObject(response.body().string());
try {
JSONObject data = json.getJSONObject("data");
JSONObject response1 = data.getJSONObject("response");
return response1.getString("url");
} catch (Exception ignore) {
return json.getString("url");
}
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
}

View file

@ -1,6 +1,22 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.utils;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkUser;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.User;
@ -11,11 +27,11 @@ import java.util.ResourceBundle;
public class MessageEditor {
private Rethink rethink;
private RethinkUser rethinkUser;
private User user;
public MessageEditor(Rethink rethink, User user) {
this.rethink = rethink;
public MessageEditor(RethinkUser rethinkUser, User user) {
this.rethinkUser = rethinkUser;
this.user = user;
}
@ -34,7 +50,7 @@ public class MessageEditor {
public EmbedBuilder getMessage(MessageType type, String title, String title_extra, String title_extra_two,
String description, String description_extra, String description_extra_two) {
String language = (this.user!=null) ? rethink.getLanguage(this.user.getId()) : null;
String language = (this.user!=null) ? rethinkUser.getLanguage() : null;
EmbedBuilder eb = this.getDefaultSettings(type);
if (!"".equals(title)) eb.setTitle(this.handle(language, title, title_extra, title_extra_two));
if (!"".equals(description)) eb.setDescription(this.handle(language, description, description_extra, description_extra_two));
@ -105,11 +121,11 @@ public class MessageEditor {
}
public String getTerm(String string) {
return this.handle(rethink.getLanguage(user.getId()), string, "", "");
return this.handle(rethinkUser.getLanguage(), string, "", "");
}
public String getTerm(String string, String extra, String extra_two) {
return this.handle(rethink.getLanguage(user.getId()), string, extra, extra_two);
return this.handle(rethinkUser.getLanguage(), string, extra, extra_two);
}
private String handle(String language_code, String string, String extra, String extra_two) {

View file

@ -1,5 +1,17 @@
#
# @author Skidder / GregTCLTK
# Copyright 2019-2020 GregTCLTK and Schlauer-Hax
#
# Licensed under the GNU Affero General Public License, Version 3.0;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Hadder = Hadder

View file

@ -1,5 +1,17 @@
#
# @author Skidder / GregTCLTK
# Copyright 2019-2020 GregTCLTK and Schlauer-Hax
#
# Licensed under the GNU Affero General Public License, Version 3.0;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Hadder = Hadder
@ -9,6 +21,8 @@ none = None
success\! = Success\!
commands.fun.avatar.success.title = Avatar of %extra%
commands.fun.avatar.error.title = User not found
commands.fun.avatar.error.description = I can not find a user with this id!
commands.fun.avatar.help.description = Sends the avatar of the specified member.
commands.fun.gif.error.description = Please try again with another term.
commands.fun.gif.help.description = Looks for a GIF on Giphy.

View file

@ -1,5 +1,17 @@
#
# @author Skidder / GregTCLTK
# Copyright 2019-2020 GregTCLTK and Schlauer-Hax
#
# Licensed under the GNU Affero General Public License, Version 3.0;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Hadder = Hadder

View file

@ -1,5 +1,17 @@
#
# @author Skidder / GregTCLTK
# Copyright 2019-2020 GregTCLTK and Schlauer-Hax
#
# Licensed under the GNU Affero General Public License, Version 3.0;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Hadder = Hadder

View file

@ -1,5 +1,17 @@
#
# @author Skidder / GregTCLTK
# Copyright 2019-2020 GregTCLTK and Schlauer-Hax
#
# Licensed under the GNU Affero General Public License, Version 3.0;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Hadder = Hadder

View file

@ -1,5 +1,17 @@
#
# @author Skidder / GregTCLTK
# Copyright 2019-2020 GregTCLTK and Schlauer-Hax
#
# Licensed under the GNU Affero General Public License, Version 3.0;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Hadder = Hadder

View file

@ -1,5 +1,17 @@
#
# @author Skidder / GregTCLTK
# Copyright 2019-2020 GregTCLTK and Schlauer-Hax
#
# Licensed under the GNU Affero General Public License, Version 3.0;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Hadder = Hadder