discord-jda

Repetitive Consumer For Loop

百般思念 提交于 2021-02-11 12:33:44
问题 I am using a library with a method where I call a method that takes an event class and a consumer to call when the event fires. This method returns a void. I need to call the method again in the consumer then in that consumer call it again etc. (a lot of times). How can I put this in a for loop to avoid typing out this method loads of times? Code: ShurikenBot.getInstance().getEventWaiter().waitForEvent(MessageReactionAddEvent.class, t -> t.getMessageId().equals(m.getId()) && event.getAuthor()

How to create a private channel in a Discord server (not a user/bot DM) using JDA: Java Discord API

二次信任 提交于 2021-02-05 11:44:25
问题 I'm trying to get the bot to create a private channel in the guild but can't find anything in the JDA documentation that allows that to happen. The ChannelAction that gets returned when you call createTextChannel() has text as the channel type explicitly in the return ( return new ChannelAction(route, name, guild, ChannelType.TEXT); ). Currently I have it working to just create a text channel with: guild.getController().createTextChannel(channelName).complete(); but I need it to be a private

JDA. GuildMemberJoin/LeaveEvent

大城市里の小女人 提交于 2021-02-05 09:26:11
问题 I have written the following methods and they both are not working. Anyone know why and how to fix it? PS: The bot has admin perms. public class GuildMemberJoin extends ListenerAdapter { public void onGuildMemberJoin(GuildMemberJoinEvent event) { EmbedBuilder join = new EmbedBuilder(); join.setColor(Color.getHSBColor(227, 74, 64)); join.setTitle("SERVER UPDATE"); join.setDescription(event.getMember().getAsMention() + " has now joined The server!"); event.getGuild().getDefaultChannel()

How to make a Discord Bot wait for a specific user to send a message with JDA?

你说的曾经没有我的故事 提交于 2021-02-02 09:30:59
问题 I'm currently taking an intro to programming class in Java, and have recently started experimenting with the JDA tools to make a basic Discord bot for my server. Ideally, I want my bot to respond when someone says "Hello Apples!" by asking them for their name, then responding with "Hi !" if this message was sent by the same person who said "Hello Apples!" Right now my bot fails to await any user input past the initial "Hello Apples!" message, and spills out all of its text at once. I believe

How to make a Discord Bot wait for a specific user to send a message with JDA?

牧云@^-^@ 提交于 2021-02-02 09:30:42
问题 I'm currently taking an intro to programming class in Java, and have recently started experimenting with the JDA tools to make a basic Discord bot for my server. Ideally, I want my bot to respond when someone says "Hello Apples!" by asking them for their name, then responding with "Hi !" if this message was sent by the same person who said "Hello Apples!" Right now my bot fails to await any user input past the initial "Hello Apples!" message, and spills out all of its text at once. I believe

How to make a Discord Bot wait for a specific user to send a message with JDA?

浪子不回头ぞ 提交于 2021-02-02 09:30:12
问题 I'm currently taking an intro to programming class in Java, and have recently started experimenting with the JDA tools to make a basic Discord bot for my server. Ideally, I want my bot to respond when someone says "Hello Apples!" by asking them for their name, then responding with "Hi !" if this message was sent by the same person who said "Hello Apples!" Right now my bot fails to await any user input past the initial "Hello Apples!" message, and spills out all of its text at once. I believe

Heroku Discord Bot builds but doesn't work

倾然丶 夕夏残阳落幕 提交于 2021-01-29 20:22:23
问题 I am trying to host a discord bot on Heroku (Discord JDA, Maven). I do this by connecting to Github and then deploying. The bot 'deploys' (view attachment) but doesn't actually work (view attachment). What could I be doing wrong, or has anyone else come across a similar issue? 回答1: Quick and dirty way to deploy it: You'll need to setup a Procfile, extensive info on that right here: https://devcenter.heroku.com/articles/procfile The procfile is basically a file with no extension that tells the

Discord JDA using a local image in an embed?

一笑奈何 提交于 2021-01-28 07:03:06
问题 Is it possible to use a local image file as a thumbnail/image in an embedded message with Discord JDA? For one of my commands i'm building an image programmatically and uploading it via the Imgur API before displaying it in an embedded message using the Imgur URL. I know I can send the file to the channel directly but i'd like it to be contained within an embed that displays other relevant info. Cheers 回答1: You can use attachment://filename.ext as described in the documentation for setImage.

Discord bot unusually repeats

久未见 提交于 2021-01-28 05:52:29
问题 So I'm trying to create a discord bot that has simple access to a database for printing out values, my code currently will print the values to the discord server but it repeats them 5 times. Bot functionality class: private MySQLAccess sql = new MySQLAccess(); public static void main(String[] args) throws Exception { JDABuilder ark = new JDABuilder(AccountType.BOT); ark.setToken("insert_discord_token_here"); ark.addEventListener(new MessageListener()); ark.buildAsync(); } @Override public

How to check is an user has a role on discord

霸气de小男生 提交于 2020-12-26 11:49:02
问题 I am struggling to find a way to check if an user has a role. I know how to find a certain role: public Role findRole(Guild guild, String name) { List<Role> roles = guild.getRolesByName(name, true); if (roles.size() <= 0) { throw new RuntimeException("Role with name " + name + " on Guild " + guild.getName() + " not found!"); } else { return roles.get(0); } } and i have a role: Role neededEole=findRole(event.getGuild(),"Admin"); I know how to search an user: String user=event.getAuthor().getId