Top confidential Clyde command

This commit is contained in:
GregTCLTK 2019-12-19 21:05:25 +01:00
parent 860d035a63
commit e7afeacce7
No known key found for this signature in database
GPG key ID: A91BADE5C070FF67
3 changed files with 51 additions and 2 deletions

View file

@ -20,5 +20,6 @@
"DiscordBotReviews": "", "DiscordBotReviews": "",
"DiscordBots": "", "DiscordBots": "",
"BotListSpace": "" "BotListSpace": ""
} },
"Clyde": ""
} }

View file

@ -4,16 +4,59 @@ package com.bbn.hadder.commands.fun;
* @author Skidder / GregTCLTK * @author Skidder / GregTCLTK
*/ */
import club.minnced.discord.webhook.WebhookClient;
import club.minnced.discord.webhook.WebhookClientBuilder;
import com.bbn.hadder.commands.Command; import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent; import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.commands.Perm; import com.bbn.hadder.commands.Perm;
import com.bbn.hadder.commands.Perms; import com.bbn.hadder.commands.Perms;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Icon;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.Webhook;
import java.io.InputStream;
import java.net.URL;
import java.util.concurrent.TimeUnit;
@Perms(Perm.MANAGE_SERVER) @Perms(Perm.MANAGE_SERVER)
public class ClydeCommand implements Command { public class ClydeCommand implements Command {
@Override @Override
public void executed(String[] args, CommandEvent event) { public void executed(String[] args, CommandEvent event) {
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", "");
Webhook webhook = channel.createWebhook(event.getConfig().getClydeName()).complete();
try {
InputStream s = new URL("https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png").openStream();
webhook.getManager().setAvatar(Icon.from(s)).queue();
WebhookClientBuilder builder = new WebhookClientBuilder(webhook.getUrl());
WebhookClient client = builder.build();
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
client.send(content);
} catch (Exception e) {
e.printStackTrace();
}
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
}
webhook.delete().queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
} else event.getHelpCommand().sendHelp(this, event);
} }
@ -24,7 +67,7 @@ public class ClydeCommand implements Command {
@Override @Override
public String description() { public String description() {
return ""; return "Send a message as a Clyde webhook.";
} }
@Override @Override

View file

@ -63,6 +63,7 @@ public class Config {
.value("DiscordExtremeList").value(null) .value("DiscordExtremeList").value(null)
.value("DiscordBotReviews").value(null) .value("DiscordBotReviews").value(null)
.value("DiscordBots").value(null) .value("DiscordBots").value(null)
.value("BotListSpace").value(null)
.endObject().endObject().toString(); .endObject().endObject().toString();
} }
@ -141,4 +142,8 @@ public class Config {
public String getBotListSpaceToken() { public String getBotListSpaceToken() {
return config.getJSONObject("Tokens").getString("BotListSpace"); return config.getJSONObject("Tokens").getString("BotListSpace");
} }
public String getClydeName() {
return config.getString("Clyde");
}
} }