commit
bd8a412ef4
7 changed files with 88 additions and 10 deletions
2
pom.xml
2
pom.xml
|
|
@ -5,7 +5,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>Hadder</groupId>
|
<groupId>Hadder</groupId>
|
||||||
<artifactId>Hadder</artifactId>
|
<artifactId>Hadder</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.0.2</version>
|
||||||
|
|
||||||
<name>Hadder</name>
|
<name>Hadder</name>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,8 @@ public class Hadder {
|
||||||
new BassCommand(),
|
new BassCommand(),
|
||||||
new EchoCommand(),
|
new EchoCommand(),
|
||||||
new ServerStatsCommand(),
|
new ServerStatsCommand(),
|
||||||
new ProfileCommand()), config, helpCommand);
|
new ProfileCommand(),
|
||||||
|
new CodeCommand()), config, helpCommand);
|
||||||
|
|
||||||
builder.addEventListeners(
|
builder.addEventListeners(
|
||||||
new MentionListener(rethink),
|
new MentionListener(rethink),
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,6 @@ public class Rethink {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
|
||||||
conn.close();
|
|
||||||
System.out.println("DISCONNECTED");
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSONArray getAsArray(String table, String where, String value) {
|
private JSONArray getAsArray(String table, String where, String value) {
|
||||||
try {
|
try {
|
||||||
String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn);
|
String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn);
|
||||||
|
|
|
||||||
78
src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java
Normal file
78
src/main/java/com/bbn/hadder/commands/misc/CodeCommand.java
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public class CodeCommand implements Command {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executed(String[] args, CommandEvent e) {
|
||||||
|
if (args.length > 0) {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder().url("https://canary.discordapp.com/api/v6/invite/" + args[0]).addHeader("Authorization", "Bot " + e.getConfig().getBotToken()).build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
JSONObject json = new JSONObject(response.body().string());
|
||||||
|
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
|
||||||
|
"commands.misc.code.success.title",
|
||||||
|
"commands.misc.code.success.description")
|
||||||
|
.addField("Code", "[" + args[0] + "](https://discord.gg/" + args[0] + ")", true)
|
||||||
|
.addField("Guild Name", json.getJSONObject("guild").getString("name"), true)
|
||||||
|
.addField("Guild ID", json.getJSONObject("guild").getString("id"), true)
|
||||||
|
.addField("Verification Level", json.getJSONObject("guild").getString("verification_level"), true)
|
||||||
|
.setThumbnail("https://cdn.discordapp.com/icons/" + json.getJSONObject("guild").getString("id") + "/" + json.getJSONObject("guild").getString("icon") + ".png")
|
||||||
|
.build()).queue();
|
||||||
|
e.getTextChannel().sendMessage(json.toString()).queue();
|
||||||
|
} catch (JSONException ex) {
|
||||||
|
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
|
||||||
|
"commands.misc.code.error.title",
|
||||||
|
"commands.misc.code.error.description").build()).queue();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
} else e.getHelpCommand().sendHelp(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] labels() {
|
||||||
|
return new String[]{"code", "invite-code", "ic"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description() {
|
||||||
|
return "commands.misc.code.help.description";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String usage() {
|
||||||
|
return "[Invite-code]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String example() {
|
||||||
|
return "58My2dM";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ public class ServerStatsCommand implements Command {
|
||||||
.addField("MFA Level", String.valueOf(e.getGuild().getRequiredMFALevel().getKey()), true)
|
.addField("MFA Level", String.valueOf(e.getGuild().getRequiredMFALevel().getKey()), true)
|
||||||
.addField("Member Count", String.valueOf(e.getGuild().getMemberCount()), true)
|
.addField("Member Count", String.valueOf(e.getGuild().getMemberCount()), true)
|
||||||
.addField("Explicit Content Level", e.getGuild().getExplicitContentLevel().getKey() + ": " + e.getGuild().getExplicitContentLevel(), true)
|
.addField("Explicit Content Level", e.getGuild().getExplicitContentLevel().getKey() + ": " + e.getGuild().getExplicitContentLevel(), true)
|
||||||
//TODO: Features
|
.addField("Features", e.getGuild().getFeatures().toString().replaceAll("\\[", "`").replaceAll(",", "`, `").replaceAll("]", "`"), true)
|
||||||
.setThumbnail(e.getGuild().getIconUrl())
|
.setThumbnail(e.getGuild().getIconUrl())
|
||||||
.setImage(e.getGuild().getBannerUrl());
|
.setImage(e.getGuild().getBannerUrl());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
|
@ -51,7 +50,7 @@ public class MentionListener extends ListenerAdapter {
|
||||||
MavenXpp3Reader reader = new MavenXpp3Reader();
|
MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||||
Model model = null;
|
Model model = null;
|
||||||
try {
|
try {
|
||||||
model = reader.read(new FileReader("pom.xml"));
|
model = reader.read(this.getClass().getClassLoader().getResourceAsStream("pom.xml"));
|
||||||
} catch (IOException | XmlPullParserException ex) {
|
} catch (IOException | XmlPullParserException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,11 @@ commands.misc.serverstats.help.description = Shows information about a server.
|
||||||
commands.misc.profile.error.title = Not found
|
commands.misc.profile.error.title = Not found
|
||||||
commands.misc.profile.error.description = I can't find the specified user.
|
commands.misc.profile.error.description = I can't find the specified user.
|
||||||
commands.misc.profile.help.description = Shows some information about the specified user.
|
commands.misc.profile.help.description = Shows some information about the specified user.
|
||||||
|
commands.misc.code.success.title = Invite code information
|
||||||
|
commands.misc.code.success.description = This message contains some information about the specified invite code.
|
||||||
|
commands.misc.code.error.title = Code not found
|
||||||
|
commands.misc.code.error.description = I can't find the specified invite code.
|
||||||
|
commands.misc.code.help.description = Shows information about a invite code.
|
||||||
|
|
||||||
commands.moderation.ban.success.title = Successfully banned
|
commands.moderation.ban.success.title = Successfully banned
|
||||||
commands.moderation.ban.success.description = I successfully baned %extra%
|
commands.moderation.ban.success.description = I successfully baned %extra%
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue