本文整理汇总了Java中net.dv8tion.jda.core.events.message.MessageReceivedEvent.getResponseNumber方法的典型用法代码示例。如果您正苦于以下问题:Java MessageReceivedEvent.getResponseNumber方法的具体用法?Java MessageReceivedEvent.getResponseNumber怎么用?Java MessageReceivedEvent.getResponseNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.events.message.MessageReceivedEvent
的用法示例。
在下文中一共展示了MessageReceivedEvent.getResponseNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessageReceived
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void onMessageReceived(MessageReceivedEvent event) {
JDA jda = event.getJDA();
long responseNumber = event.getResponseNumber();
User author = event.getAuthor(); //The user that sent the message
Message message = event.getMessage(); //The message that was received
MessageChannel channel = event.getChannel(); //The channel the message was sent in
TransparentDiscord.receiveMessage(message, channel);
}
示例2: onMessageReceived
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void onMessageReceived(MessageReceivedEvent event)
{
JDA jda = event.getJDA();
//Amount of Discord events that JDA has received since the last reconnect
long responsNo = event.getResponseNumber();
//Event specific information
User user = event.getAuthor();
Message message = event.getMessage();
MessageChannel channel = event.getChannel(); //Could be a TextChannel, PrivateChannel or Group
String messageText = message.getContent();
boolean isBot = user.isBot();
//FYI in the API, Guilds are Servers
ChannelType type = event.getChannelType();
String guildName;
String channelName = channel.getName();
String userName = user.getName();
if(type.isGuild())
{
guildName = event.getGuild().getName();
Member member = event.getMember();
//If this is a Webhook message then there is no Member associated with the User, so we use User for the name
//If not a Webhook message, we'll use the Member's nickname if they have one. Otherwise we'll use their username
userName = message.isWebhookMessage() ? user.getName() : member.getEffectiveName();
}
else
{
guildName = type.toString();
}
if(isBot) userName = "BOT:" + userName;
Util.info(getClass(),"(" + guildName + ")[" + channelName + "]<" + userName + ">: " + messageText);
if(messageText.equals("hello"))
channel.sendMessage("Hello " + user.getAsMention() + "!").queue();
else if(messageText.equals("roll"))
{
int roll = new Random().nextInt(6) + 1;
channel.sendMessage("Your roll: " + roll).queue(message1 ->
{
if(roll < 3)
channel.sendMessage("Ohh that was a bit of a low roll...").queue();
});
}
}