本文整理汇总了Java中sx.blah.discord.handle.obj.IPrivateChannel类的典型用法代码示例。如果您正苦于以下问题:Java IPrivateChannel类的具体用法?Java IPrivateChannel怎么用?Java IPrivateChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPrivateChannel类属于sx.blah.discord.handle.obj包,在下文中一共展示了IPrivateChannel类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: deleteprivateMessages
import sx.blah.discord.handle.obj.IPrivateChannel; //导入依赖的package包/类
@Command(
command = "deleteprivmsg",
description = "Shutdown the bot",
alias = "dpm",
arguments = {"Count"},
permission = Globals.BOT_INFO,
prefix = Globals.INFO_PREFIX
)
public boolean deleteprivateMessages(MessageReceivedEvent event, String[] args) {
new Thread(() -> {
try {
IPrivateChannel privateChannel = event.getAuthor().getOrCreatePMChannel();
List<IMessage> messageList = privateChannel.getMessageHistory(Integer.parseInt(args[0]));
for (IMessage message : messageList) {
if (message.getAuthor().isBot()) {
BotUtils.deleteMessageOne(message);
}
}
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.SUCCESS + LANG.getTranslation("deleteprivinfo")), true);
} catch (Exception ex) {
Console.error(String.format(LANG.getTranslation("commonmessage_error"), ex.getMessage()));
}
}).start();
return true;
}
开发者ID:ModdyLP,项目名称:MoMuOSB,代码行数:26,代码来源:Moderation.java
示例2: send
import sx.blah.discord.handle.obj.IPrivateChannel; //导入依赖的package包/类
/**
* Buffers and sends a message in a channel
*
* @param content Message content
* @param channel The channel to send in
*/
public static void send(String content, IChannel channel) {
RequestBuffer.request(() -> {
try {
String cnt = "\u200b" + content;
if (cnt.length() > 2000) {
cnt = cnt.substring(0, 1999);
}
new MessageBuilder(Launcher.getInstance().getClient()).withChannel(channel)
.appendContent(cnt).build();
} catch (DiscordException | MissingPermissionsException e) {
String desc = "";
if (channel.isPrivate()) {
desc += "DM To " +
((IPrivateChannel) channel).getRecipient().getName()
+ '#' + ((IPrivateChannel) channel).getRecipient().getDiscriminator()
+ " (ID: " + ((IPrivateChannel) channel).getRecipient().getID();
} else {
desc += channel + " (Guild: " + channel.getGuild().getName() + ')';
}
Launcher.getInstance().getLogger().error(
MessageFormatter.format("Could not send message! Channel: {}", desc).getMessage(), e);
}
});
}
开发者ID:ArsenArsen,项目名称:ABot,代码行数:31,代码来源:Messages.java
示例3: Battle
import sx.blah.discord.handle.obj.IPrivateChannel; //导入依赖的package包/类
public Battle(IDiscordClient client, Battler one, Battler two) {
this.client = client;
battlers[0] = one;
battlers[1] = two;
one.opponent = two;
two.opponent = one;
for (int i = 0; i < battlers.length; i++) {
final int index = i;
RequestBuffer.request(() -> {
try {
IPrivateChannel priv = battlers[index].owner.getOrCreatePMChannel();
privateChannels[index] = priv;
} catch (DiscordException e) {
e.printStackTrace();
}
}).get();
}
}
开发者ID:chrislo27,项目名称:Baristron,代码行数:21,代码来源:Battle.java
示例4: sendDirectMessage
import sx.blah.discord.handle.obj.IPrivateChannel; //导入依赖的package包/类
public static IMessage sendDirectMessage(String message, IUser user) {
return RequestBuffer.request(() -> {
try {
IPrivateChannel pc = user.getOrCreatePMChannel();
return new MessageBuilder(Main.client).withChannel(pc).appendContent(message).build();
} catch (DiscordException | MissingPermissionsException e) {
//Failed to send message.
return null;
}
}).get();
}
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:12,代码来源:Message.java
示例5: checkCustomPing
import sx.blah.discord.handle.obj.IPrivateChannel; //导入依赖的package包/类
private void checkCustomPing(IMessage msg) {
if (msg.getChannel().isPrivate() || msg.getAuthor().equals(MCBot.instance.getOurUser())) return;
Multimap<Long, CustomPing> pings = HashMultimap.create();
CommandCustomPing.this.getPingsForGuild(msg.getGuild()).forEach(pings::putAll);
for (Entry<Long, CustomPing> e : pings.entries()) {
if (e.getKey() == msg.getAuthor().getLongID()) {
continue;
}
IUser owner = msg.getGuild().getUserByID(e.getKey());
if (owner == null || !msg.getChannel().getModifiedPermissions(owner).contains(Permissions.READ_MESSAGES)) {
continue;
}
Matcher matcher = e.getValue().getPattern().matcher(msg.getContent());
if (matcher.find()) {
final IPrivateChannel channel = owner.getOrCreatePMChannel();
RequestBuffer.request(() -> {
EmbedObject embed = new EmbedBuilder()
.withAuthorIcon(msg.getAuthor().getAvatarURL())
.withAuthorName("New ping from: " + msg.getAuthor().getDisplayName(msg.getGuild()))
.withTitle(e.getValue().getText())
.withDesc(msg.getContent())
.build();
channel.sendMessage("<#" + msg.getChannel().getStringID() + ">", embed);
return true;
});
}
}
}
开发者ID:tterrag1098,项目名称:MCBot,代码行数:30,代码来源:CommandCustomPing.java
示例6: dispatch
import sx.blah.discord.handle.obj.IPrivateChannel; //导入依赖的package包/类
@Override
public void dispatch(String[] args, IUser sender, IChannel channel) {
try {
IPrivateChannel msg = Launcher.getInstance().getClient().getOrCreatePMChannel(sender);
Messages.send(Launcher.getInvite(sender.mention()), msg);
Messages.send("Check your DMs!", channel);
} catch (DiscordException | RateLimitException e) {
Messages.sendException("Well that went very wrong", e, channel);
}
}
开发者ID:ArsenArsen,项目名称:ABot,代码行数:11,代码来源:Invite.java
示例7: getTickTaskToNotify
import sx.blah.discord.handle.obj.IPrivateChannel; //导入依赖的package包/类
public static TickTask getTickTaskToNotify(String userID, Bot bot) {
return () -> {
IUser user = bot.client.getUserByID(userID);
Goat goat = Userdata.getGson("goat_" + userID, Goat.class);
if (goat == null) {
Main.info(userID + " has no goat to notify");
return;
}
goat.alreadySentNotification = true;
goat.saveUser(userID);
Userdata.instance().save();
if (user == null) {
// Main.debug("The user " + userID + " is null");
return;
}
if (!goat.shouldSendNotifications) {
Main.info("Skipping notification, user " + user.getName() + "#" + user.getDiscriminator() + " (" +
user.getID() + ") has notifications off");
return;
}
RequestBuffer.request(() -> {
try {
IPrivateChannel pm = bot.client.getOrCreatePMChannel(user);
MessageBuilder b = Bot.getNewBuilder(pm);
b.appendContent(
"I'm messaging you to tell you that **your goat is ready** to be" + " fed again!\n\n");
b.appendContent("*Don't like these notifications? Simply tell me* `%goat " +
"notifications` *to toggle them off.*");
// Main.info("Attempting to notify for goat: " + user.getName() + "#" + user.getDiscriminator() + " (" +
// user.getID() + ")");
Bot.sendMessage(b);
Main.info("Notified " + user.getName() + "#" + user.getDiscriminator() + " (" + user.getID() +
") about their goat");
} catch (DiscordException e) {
Main.error("Couldn't warn " + user.getName() + "#" + user.getDiscriminator() + " (" + user.getID
() +
") about their goat");
e.printStackTrace();
}
});
};
}
开发者ID:chrislo27,项目名称:Baristron,代码行数:52,代码来源:Goat.java
示例8: handle
import sx.blah.discord.handle.obj.IPrivateChannel; //导入依赖的package包/类
@Override
public void handle(MessageReceivedEvent event) {
if (finished || !ready)
return;
final IMessage messageObj = event.getMessage();
final IChannel channel = messageObj.getChannel();
String message = messageObj.getContent();
final IUser author = messageObj.getAuthor();
if (!channel.isPrivate())
return;
boolean matchAny = false;
for (IPrivateChannel ch : privateChannels) {
if (channel.equals(ch)) {
matchAny = true;
break;
}
}
if (!matchAny)
return;
final int index = author.equals(battlers[0].owner) ? 0 : (author.equals(battlers[1].owner) ? 1 : -1);
if (index == -1)
return;
if (message.length() == 1) {
char c = Character.toLowerCase(message.charAt(0));
if (c == 'r') {
// resign
finished = true;
client.getDispatcher().unregisterListener(this);
for (IPrivateChannel pc : privateChannels) {
Bot.sendMessage(Bot.getNewBuilder(pc).withContent(
"**" + author.getName() + "**#" + author.getDiscriminator() +
" __resigned__ from the battle."));
}
Userdata.addLong("goatBattlesLost_" + author.getID(), 1, 0);
Userdata.addLong("goatBattlesWon_" + battlers[index].opponent.owner.getID(), 1, 0);
Userdata.instance().save();
return;
} else if (selection[index] == 0 && c >= '1' &&
c <= Integer.toString(battlers[index].moves.length).charAt(0)) {
selection[index] = c - '1' + 1;
final int moveIndex = selection[index] - 1;
final Move m = battlers[index].moves[moveIndex];
boolean noPPRemaining = true;
for (int pp : battlers[index].pp) {
if (pp > 0) {
noPPRemaining = false;
break;
}
}
if (!noPPRemaining && battlers[index].pp[moveIndex] == 0) {
Bot.sendMessage(
Bot.getNewBuilder(privateChannels[index]).withContent("That move is **out of PP**."));
selection[index] = 0;
}
}
}
if (selection[0] != 0 && selection[1] != 0) {
executeTurn(event);
}
}
开发者ID:chrislo27,项目名称:Baristron,代码行数:76,代码来源:Battle.java
注:本文中的sx.blah.discord.handle.obj.IPrivateChannel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论