use of net.dv8tion.jda.api.entities.PrivateChannel in project JDA by DV8FromTheWorld.
the class UserImpl method openPrivateChannel.
@Nonnull
@Override
public RestAction<PrivateChannel> openPrivateChannel() {
return new DeferredRestAction<>(getJDA(), PrivateChannel.class, this::getPrivateChannel, () -> {
Route.CompiledRoute route = Route.Self.CREATE_PRIVATE_CHANNEL.compile();
DataObject body = DataObject.empty().put("recipient_id", getId());
return new RestActionImpl<>(getJDA(), route, body, (response, request) -> {
PrivateChannel priv = api.getEntityBuilder().createPrivateChannel(response.getObject(), this);
UserImpl.this.privateChannelId = priv.getIdLong();
return priv;
});
});
}
use of net.dv8tion.jda.api.entities.PrivateChannel in project ExciteBot by TheGameCommunity.
the class BanCommand method banProfile.
@SuppressWarnings("rawtypes")
private static int banProfile(MessageContext context, Player profile, Duration duration, String reason) {
if (context.isAdmin()) {
Ban ban = profile.ban(context, duration, reason);
String message = "Banned profile " + profile.getPrettyDiscord() + ": \n\n" + ban;
if (context.isConsoleMessage()) {
context.sendMessage(message);
} else {
PrivateChannel privateChannel;
if (context.isPrivateMessage()) {
privateChannel = (PrivateChannel) context.getChannel();
} else {
privateChannel = context.getDiscordAuthor().getJDAUser().openPrivateChannel().complete();
}
privateChannel.sendMessage(message);
}
} else {
context.sendMessage("You do not have permission to execute this command");
}
return 1;
}
use of net.dv8tion.jda.api.entities.PrivateChannel in project ExciteBot by TheGameCommunity.
the class BanCommand method banDiscordUser.
@SuppressWarnings("rawtypes")
private static int banDiscordUser(MessageContext context, DiscordUser user, Duration duration, String reason) {
if (context.isAdmin()) {
Ban ban = user.ban(context, duration, parseReason(duration, reason));
String message = "Banned discord user" + user + ": \n\n" + ban;
if (context.isConsoleMessage()) {
context.sendMessage(message);
} else {
PrivateChannel privateChannel;
if (context.isPrivateMessage()) {
privateChannel = (PrivateChannel) context.getChannel();
} else {
privateChannel = context.getDiscordAuthor().getJDAUser().openPrivateChannel().complete();
}
privateChannel.sendMessage(message);
}
} else {
context.sendMessage("You do not have permission to execute this command");
}
return 1;
}
use of net.dv8tion.jda.api.entities.PrivateChannel in project Lauren by Yuhtin.
the class ShardLootTask method startRunnable.
public void startRunnable() {
logger.info("Registered ShardLootTask");
val allowedChannels = Arrays.asList(704342124732350645L, 700673056414367825L);
val embed = new EmbedBuilder();
embed.setAuthor("Shard Loot", null, "https://cdn.discordapp.com/emojis/772285522852839445.png?v=1");
val guild = bot.getGuilds().get(0);
embed.setFooter("© ^Aincrad™ servidor de jogos", guild.getIconUrl());
embed.setThumbnail("https://www.pcguia.pt/wp-content/uploads/2019/11/lootbox.jpg");
embed.setColor(Color.MAGENTA);
embed.setDescription("Você encontrou um **shardloot**, seja o primeiro a reajir\n" + "no ícone abaixo para garantir seus **<:boost_emoji:772285522852839445> shards**\n");
TaskHelper.runTaskTimerAsync(new TimerTask() {
@Override
public void run() {
logger.info("Running ShardLootTask");
if (new Random().nextInt(100) > 25)
return;
val value = new Random().nextInt(allowedChannels.size());
val channelID = allowedChannels.get(value);
val channel = guild.getTextChannelById(channelID);
if (channel == null) {
logger.warning("Can't select a random channel to drop a loot");
return;
}
logger.info("Dropped shardloot on channel " + channel.getName());
val message = channel.sendMessageEmbeds(embed.build()).complete();
message.addReaction(":boost_emoji:772285522852839445").queue();
eventWaiter.waitForEvent(MessageReactionAddEvent.class, event -> !event.getMember().getUser().isBot() && event.getMessageIdLong() == message.getIdLong(), event -> {
message.delete().queue();
val player = playerController.get(event.getUserIdLong());
val shard = 30 + new Random().nextInt(50);
player.addMoney(shard);
val privateChannel = event.getUser().openPrivateChannel().complete();
if (event.getUser().hasPrivateChannel()) {
var nickname = event.getMember().getNickname();
if (nickname == null)
nickname = event.getMember().getEffectiveName();
privateChannel.sendMessage("<:felizpakas:742373250037710918> " + "Parabéns **" + nickname + "**, você capturou um shardloot, " + "você recebeu <:boost_emoji:772285522852839445> **$" + shard + " shards**").queue();
}
logger.info("The player " + event.getUser().getAsTag() + " getted the sharddrop");
}, 25, TimeUnit.SECONDS, () -> message.delete().queue());
}
}, 10, 55, TimeUnit.MINUTES);
}
use of net.dv8tion.jda.api.entities.PrivateChannel in project reputation-bot by RainbowDashLabs.
the class GdprService method resolveUserRequest.
private boolean resolveUserRequest(Long userId) {
User user;
try {
user = shardManager.retrieveUserById(userId).complete();
} catch (RuntimeException e) {
log.info("Could not process gdpr request for user {}. User could not be retrieved.", userId);
return false;
}
if (user == null) {
log.info("Could not process gdpr request for user {}. User could not be retrieved.", userId);
return false;
}
PrivateChannel privateChannel;
try {
privateChannel = user.openPrivateChannel().complete();
} catch (RuntimeException e) {
log.info("Could not process gdpr request for user {}. Could not open private channel.", userId);
return false;
}
if (privateChannel == null) {
log.info("Could not process gdpr request for user {}. Could not open private channel.", userId);
return false;
}
var userData = gdprData.getUserData(user);
if (userData.isEmpty()) {
log.info("Could not process gdpr request for user {}. Data aggregation failed.", userId);
return false;
}
Path tempFile;
try {
tempFile = Files.createTempFile("repbot_gdpr", ".json");
} catch (IOException e) {
log.info("Coult not create temp file", e);
return false;
}
try {
Files.writeString(tempFile, userData.get());
} catch (IOException e) {
log.info("Could not write to temp file", e);
return false;
}
try {
privateChannel.sendMessage("Here is your requested data. You can request it again in 30 days.").addFile(tempFile.toFile()).complete();
} catch (RuntimeException e) {
log.info("Could not send gdpr data to user {}. File sending failed.", userId);
return false;
}
return true;
}
Aggregations