discord-jda

How to check is an user has a role on discord

☆樱花仙子☆ 提交于 2020-12-26 11:48:20
问题 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

use JDA delete message 10 seconds after sending

▼魔方 西西 提交于 2020-06-29 03:44:08
问题 I am making a discord bot that sends an embed to display a users inventory(im making a game bot). To avoid clutter I want to delete the message after 10-20 seconds. Anyone know how I can do this(If you completely understand the questions then pls dont say, "oh you need to follow blah blah format"). I am using Java eclipse with JDA. Yes, I've looked it up and I couldn't find anything for JDA. 回答1: You can use queueAfter which will delay the execution of the RestAction provided by delete() .

JDA - send message

此生再无相见时 提交于 2020-06-21 05:44:07
问题 I have my own Discord BOT based on JDA. I need to send a text message to the specific channel. I know how to send the message as onEvent response, but in my situation I do not have such event. I have: Author (BOT), Token and Channel number. My question is: how to send the message to this channel without an event ? 回答1: Ok I think I know what you mean. You don't need to have an event to get an ID of a channel and send a message. The only thing you need to do is to instantiate the JDA, call

Discord JDA - Invalid Member List

拈花ヽ惹草 提交于 2020-05-16 19:10:27
问题 I am creating a Discord bot and have encountered a strange problem. I need to go through each user on the server and perform a conditional action. But when receiving a list of all Members, it contains only me and the bot itself. public class Bot extends ListenerAdapter { public void onGuildMessageReceived(GuildMessageReceivedEvent Event) { String Message = Event.getMessage().getContentRaw(); if(Message.charAt(0) == Globals.BOT_PREFIX) { String[] Args = Message.split("\\s+"); if(Args[0]

Is it possible to check if user have PM's enabled?

白昼怎懂夜的黑 提交于 2020-01-11 14:07:13
问题 I'd like to know if there is a way to check if a User have Private Messages Enabled. This Feature is for an Support Bot. Currently I use the GuildMessageRecievedEvent and send a Private Message to the User. 回答1: No, there is not. You can only send a message and handle the failure: user.openPrivateChannel().submit() .thenCompose(channel -> channel.sendMessage(x).submit()) .whenComplete((message, error) -> { if (error != null) failed(); else success(); }); This is also shown as an example in

Is it possible to check if user have PM's enabled?

做~自己de王妃 提交于 2020-01-11 14:05:53
问题 I'd like to know if there is a way to check if a User have Private Messages Enabled. This Feature is for an Support Bot. Currently I use the GuildMessageRecievedEvent and send a Private Message to the User. 回答1: No, there is not. You can only send a message and handle the failure: user.openPrivateChannel().submit() .thenCompose(channel -> channel.sendMessage(x).submit()) .whenComplete((message, error) -> { if (error != null) failed(); else success(); }); This is also shown as an example in

Send message to specific channel in Discord with JDA

你说的曾经没有我的故事 提交于 2019-12-24 07:57:35
问题 How to ask the bot to send a message to another channel (specific channel) that is not the same as the bot receive command? Let's say bot receives the message !ban @xxx in channel #a and if action is completed, bot sends ban to user @xxx is given to channel #b . code Main.java : import net.dv8tion.jda.core.*; public class Main { private static String token = "NDk0MjI2Mjk2OTY5MjMyMzk0.DowgCA.j0sQHnBV3wm70rzz7Q78rX0NVPU"; public static void main(String[] args) throws Exception{ try { JDA api =

Send message to specific channel in Discord with JDA

三世轮回 提交于 2019-12-24 07:57:24
问题 How to ask the bot to send a message to another channel (specific channel) that is not the same as the bot receive command? Let's say bot receives the message !ban @xxx in channel #a and if action is completed, bot sends ban to user @xxx is given to channel #b . code Main.java : import net.dv8tion.jda.core.*; public class Main { private static String token = "NDk0MjI2Mjk2OTY5MjMyMzk0.DowgCA.j0sQHnBV3wm70rzz7Q78rX0NVPU"; public static void main(String[] args) throws Exception{ try { JDA api =

How to add reaction to an embed message JDA

风流意气都作罢 提交于 2019-12-11 15:09:56
问题 I'm trying to send and embed message when I do the command ~verify and then it sends an embed message and I cant find how to add to there a reaction. I did already the embed message and sent it but can add the reaction import Main.Bot; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.MessageBuilder; import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; import net.dv8tion.jda.core.hooks.ListenerAdapter;