Merge Greg's branch into the master branch #230
3 changed files with 51 additions and 2 deletions
|
|
@ -20,5 +20,6 @@
|
|||
"DiscordBotReviews": "",
|
||||
"DiscordBots": "",
|
||||
"BotListSpace": ""
|
||||
}
|
||||
},
|
||||
"Clyde": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,16 +4,59 @@ package com.bbn.hadder.commands.fun;
|
|||
* @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.CommandEvent;
|
||||
import com.bbn.hadder.commands.Perm;
|
||||
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)
|
||||
public class ClydeCommand implements Command {
|
||||
|
||||
@Override
|
||||
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
|
||||
public String description() {
|
||||
return "";
|
||||
return "Send a message as a Clyde webhook.";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public class Config {
|
|||
.value("DiscordExtremeList").value(null)
|
||||
.value("DiscordBotReviews").value(null)
|
||||
.value("DiscordBots").value(null)
|
||||
.value("BotListSpace").value(null)
|
||||
.endObject().endObject().toString();
|
||||
}
|
||||
|
||||
|
|
@ -141,4 +142,8 @@ public class Config {
|
|||
public String getBotListSpaceToken() {
|
||||
return config.getJSONObject("Tokens").getString("BotListSpace");
|
||||
}
|
||||
|
||||
public String getClydeName() {
|
||||
return config.getString("Clyde");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue