Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Commit

Permalink
updated atochannel function, updated gif command
Browse files Browse the repository at this point in the history
  • Loading branch information
ゼクロ committed Sep 24, 2017
1 parent 37e9798 commit 76ae6e4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
35 changes: 8 additions & 27 deletions src/main/java/commands/chat/Gif.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package commands.chat;

import commands.Command;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;
Expand Down Expand Up @@ -41,40 +42,16 @@ public boolean called(String[] args, MessageReceivedEvent event) {
public void action(String[] args, MessageReceivedEvent event) throws ParseException, IOException {

TextChannel tc = event.getTextChannel();

/*
File f = new File("giphykey.txt");
User owner = event.getJDA().getUserById(STATICS.BOT_OWNER_ID);
if (!f.exists()) {
tc.sendMessage(MSGS.error().setDescription(
String.format("Gif command is disabled because of missing giphy API key!\nPlease contact the bot's host (%s#%s) to add the `giphykey.txt` file with a valid giphy API token!",
owner.getName(), owner.getDiscriminator())
).build()).queue();
return;
}
BufferedReader br = new BufferedReader(new FileReader(f));
String token = br.readLine().replace("\n", "");
if (token.length() < 1) {
tc.sendMessage(MSGS.error().setDescription(
String.format("Gif command is disabled because of invalid giphy API key!\nPlease contact the bot's host (%s#%s) to update the giphy key in the `giphykey.txt` file!",
owner.getName(), owner.getDiscriminator())
).build()).queue();
return;
}
*/
User author = event.getAuthor();

if (args.length < 1) {
tc.sendMessage(MSGS.error().setDescription(help()).build()).queue();
return;
}

String query = Arrays.stream(args).filter(s -> !s.startsWith("-")).collect(Collectors.joining(" "));
String query = Arrays.stream(args).filter(s -> !s.startsWith("-")).collect(Collectors.joining("-"));
int index = args[args.length - 1].startsWith("-") ? Integer.parseInt(args[args.length - 1].substring(1)) - 1 : 0;

System.out.println(query + "\n" + index);

Message msg = event.getTextChannel().sendMessage("Collecting data...").complete();
event.getMessage().delete().queue();

Expand All @@ -87,7 +64,11 @@ public void action(String[] args, MessageReceivedEvent event) throws ParseExcept
gifs.add(g.getUrl())
);

msg.editMessage(gifs.get(index)).queue();
msg.editMessage(
String.format("[%s]\n", author.getName()) +
gifs.get(index)
).queue();


}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/listeners/AutochannelHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public void onGuildVoiceJoin(GuildVoiceJoinEvent event) {
.setBitrate(vc.getBitrate())
.setUserlimit(vc.getUserLimit())
.complete();
System.out.println(vc.getParent());

if (vc.getParent() != null)
nvc.getManager().setParent(vc.getParent()).queue();

g.getController().modifyVoiceChannelPositions().selectPosition(nvc).moveTo(vc.getPosition() + 1).queue();
g.getController().modifyVoiceChannelPositions().selectPosition(nvc).moveTo(vc.getPosition() + 1).queue();
g.getController().moveVoiceMember(event.getMember(), nvc).queue();
active.add(nvc);
Expand All @@ -53,6 +59,10 @@ public void onGuildVoiceMove(GuildVoiceMoveEvent event) {
.setBitrate(vc.getBitrate())
.setUserlimit(vc.getUserLimit())
.complete();

if (vc.getParent() != null)
nvc.getManager().setParent(vc.getParent()).queue();

g.getController().modifyVoiceChannelPositions().selectPosition(nvc).moveTo(vc.getPosition() + 1).queue();
g.getController().moveVoiceMember(event.getMember(), nvc).queue();
active.add(nvc);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/utils/STATICS.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class STATICS {
//######### GENERAL BOT SETTINGS #########//


public static String VERSION = "1.41.0.0";
public static String VERSION = "1.41.1.0";


public static String PREFIX = "-";
Expand Down

0 comments on commit 76ae6e4

Please sign in to comment.