v1.0.2 #368

Merged
greg6775 merged 10 commits from greg-dev into master 2020-02-06 02:24:07 +01:00
7 changed files with 88 additions and 10 deletions

View file

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>Hadder</groupId>
<artifactId>Hadder</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<name>Hadder</name>

View file

@ -125,7 +125,8 @@ public class Hadder {
new BassCommand(),
new EchoCommand(),
new ServerStatsCommand(),
new ProfileCommand()), config, helpCommand);
new ProfileCommand(),
new CodeCommand()), config, helpCommand);
builder.addEventListeners(
new MentionListener(rethink),

View file

@ -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) {
try {
String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn);

View 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";
}
}

View file

@ -42,7 +42,7 @@ public class ServerStatsCommand implements Command {
.addField("MFA Level", String.valueOf(e.getGuild().getRequiredMFALevel().getKey()), true)
.addField("Member Count", String.valueOf(e.getGuild().getMemberCount()), 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())
.setImage(e.getGuild().getBannerUrl());

View file

@ -28,7 +28,6 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import javax.annotation.Nonnull;
import java.io.FileReader;
import java.io.IOException;
import java.util.Random;
@ -51,7 +50,7 @@ public class MentionListener extends ListenerAdapter {
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = null;
try {
model = reader.read(new FileReader("pom.xml"));
model = reader.read(this.getClass().getClassLoader().getResourceAsStream("pom.xml"));
} catch (IOException | XmlPullParserException ex) {
ex.printStackTrace();
}

View file

@ -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.description = I can't find 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.description = I successfully baned %extra%