use of datadog.trace.api.Trace in project Vinny by kikkia.
the class AliasesCommand method executeCommand.
@Override
@Trace(operationName = "executeCommand", resourceName = "Aliases")
protected void executeCommand(CommandEvent commandEvent) {
// TODO: Will need updating for channel and user aliases
InternalGuild guild = guildDAO.getGuildById(commandEvent.getGuild().getId());
if (guild.getAliasList().isEmpty()) {
commandEvent.reply("There are no aliases available to you here");
return;
}
ArrayList<String> aliases = new ArrayList<>();
for (Map.Entry<String, Alias> entry : guild.getAliasList().entrySet()) {
aliases.add(entry.getKey() + " -> " + entry.getValue().getCommand());
}
builder.setText("Aliases you can use here: ");
builder.setItems(aliases.toArray(new String[] {}));
builder.build().paginate(commandEvent.getChannel(), 1);
}
use of datadog.trace.api.Trace in project Vinny by kikkia.
the class RemoveGuildAliasCommand method executeCommand.
@Override
@Trace(operationName = "executeCommand", resourceName = "RemoveGuildAlias")
protected void executeCommand(CommandEvent commandEvent) {
InternalGuild guild = guildDAO.getGuildById(commandEvent.getGuild().getId());
Alias alias = guild.getAliasList().get(commandEvent.getArgs());
if (alias == null) {
commandEvent.replyWarning("Could not find that alias, make sure its typed correctly.");
return;
}
try {
aliasDAO.removeGuildAlias(alias, commandEvent.getGuild().getId());
guild.getAliasList().remove(commandEvent.getArgs());
guildDAO.updateGuildInCache(guild);
commandEvent.reactSuccess();
} catch (SQLException e) {
logger.severe("Failed to remove alias", e);
commandEvent.replyError("Failed to remove alias from db");
}
}
use of datadog.trace.api.Trace in project Vinny by kikkia.
the class ServerInfoCommand method executeCommand.
@Override
@Trace(operationName = "executeCommand", resourceName = "ServerInfo")
protected void executeCommand(CommandEvent commandEvent) {
Guild g = commandEvent.getGuild();
int botCount = g.getMembers().stream().filter(m -> m.getUser().isBot()).collect(Collectors.toList()).size();
int staticEmojiCount = g.getEmotes().stream().filter(m -> !m.isAnimated()).collect(Collectors.toList()).size();
int animatedEmojiCount = g.getEmotes().stream().filter(Emote::isAnimated).collect(Collectors.toList()).size();
int membersCount = g.getMembers().stream().filter(m -> !m.getUser().isBot()).collect(Collectors.toList()).size();
int onlineCount = g.getMembers().stream().filter(m -> m.getOnlineStatus().getKey().equals("online")).collect(Collectors.toList()).size();
String customEmojis = "**Static**: " + staticEmojiCount + "\n**Animated:** " + animatedEmojiCount;
String channels = "Voice Channels: " + g.getVoiceChannels().size() + "\nText Channels: " + g.getTextChannels().size() + "\n**Total:** " + g.getChannels().size();
String members = "Members: " + membersCount + "\nBots: " + botCount + "\n**Total:** " + g.getMembers().size() + "\nOnline: " + onlineCount;
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setTitle(g.getName());
embedBuilder.setDescription("**Owner:** " + g.getOwner().getAsMention());
embedBuilder.setImage(g.getIconUrl());
embedBuilder.addField("Members", members, false);
embedBuilder.addField("Channels", channels, false);
embedBuilder.addField("Roles", g.getRoles().size() + "", false);
embedBuilder.addField("Custom Emojis", customEmojis, false);
embedBuilder.addField("Region", g.getRegionRaw(), false);
embedBuilder.addField("Shard", commandEvent.getJDA().getShardInfo().getShardString(), false);
embedBuilder.setFooter(FormattingUtils.formatOffsetDateTimeToDay(g.getTimeCreated()), null);
commandEvent.reply(embedBuilder.build());
}
use of datadog.trace.api.Trace in project Vinny by kikkia.
the class SetVoiceRoleCommand method executeCommand.
@Override
@Trace(operationName = "executeCommand", resourceName = "SetVoiceRole")
protected void executeCommand(CommandEvent commandEvent) {
InternalGuild guild = null;
Guild commandGuild = commandEvent.getGuild();
try {
guild = guildDAO.getGuildById(commandGuild.getId());
} catch (Exception e) {
logger.log(Level.SEVERE, "Problem getting guild settings " + e.getMessage());
commandEvent.reply(commandEvent.getClient().getError() + " There was a problem getting the settings for your guild. Please contact the developer on the support server. " + Bot.SUPPORT_INVITE_LINK);
metricsManager.markCommandFailed(this, commandEvent.getAuthor(), commandEvent.getGuild());
return;
}
if (guild == null) {
logger.log(Level.WARNING, "Guild not found in db, attempting to add: " + commandGuild.getId());
commandEvent.reply(commandEvent.getClient().getWarning() + " This guild was not found in my database. I am going to try to add it. Please standby.");
if (!guildDAO.addGuild(commandGuild)) {
logger.log(Level.SEVERE, "Failed to add the guild to the db");
commandEvent.reply(commandEvent.getClient().getError() + " Error adding the guild to the db. Please contact the developer on the support server. " + Bot.SUPPORT_INVITE_LINK);
metricsManager.markCommandFailed(this, commandEvent.getAuthor(), commandEvent.getGuild());
return;
}
commandEvent.reply(commandEvent.getClient().getSuccess() + " Added the guild to the database. Retrying");
executeCommand(commandEvent);
return;
}
// If nothing then set to all
if (commandEvent.getArgs().isEmpty()) {
if (!guildDAO.updateMinVoiceRole(guild.getId(), commandEvent.getGuild().getPublicRole().getId())) {
logger.log(Level.SEVERE, "Failed to update voice role for guild " + guild.getId());
commandEvent.reply("Something went wrong. Please contact the developers on the support server. " + Bot.SUPPORT_INVITE_LINK);
metricsManager.markCommandFailed(this, commandEvent.getAuthor(), commandEvent.getGuild());
}
commandEvent.getMessage().addReaction(commandEvent.getClient().getSuccess()).queue();
return;
}
List<Role> mentionedRoles = commandEvent.getMessage().getMentionedRoles();
if (mentionedRoles == null || mentionedRoles.isEmpty()) {
commandEvent.reply(commandEvent.getClient().getWarning() + " You must specify a role.");
return;
}
// Just use the first mentioned roles
if (!guildDAO.updateMinVoiceRole(guild.getId(), mentionedRoles.get(0).getId())) {
commandEvent.reply(commandEvent.getClient().getError() + " Something went wrong! Please contact the devs on the support server. " + Bot.SUPPORT_INVITE_LINK);
metricsManager.markCommandFailed(this, commandEvent.getAuthor(), commandEvent.getGuild());
}
commandEvent.getMessage().addReaction(commandEvent.getClient().getSuccess()).queue();
}
use of datadog.trace.api.Trace in project Vinny by kikkia.
the class AddPrefixCommand method executeCommand.
@Override
@Trace(operationName = "executeCommand", resourceName = "AddPrefix")
protected void executeCommand(CommandEvent commandEvent) {
InternalGuild guild = guildDAO.getGuildById(commandEvent.getGuild().getId());
if (commandEvent.getArgs().isEmpty()) {
commandEvent.reply(commandEvent.getClient().getWarning() + " You must specify at least one custom prefix to add.");
return;
}
ArrayList<String> prefixes = guild.getPrefixList();
prefixes.addAll(Arrays.asList(commandEvent.getArgs().split(" ")));
String newPrefixes = GuildUtils.convertListToPrefixesString(prefixes);
if (newPrefixes.length() > 254) {
commandEvent.reply(commandEvent.getClient().getWarning() + " Failed to add custom prefixes. The length of all" + " prefixes on the server cannot be more than 250 characters. You can remove custom prefixes with the `removeprefix` command.");
return;
}
if (guildDAO.updateGuildPrefixes(commandEvent.getGuild().getId(), prefixes)) {
commandEvent.getMessage().addReaction(commandEvent.getClient().getSuccess()).queue();
} else {
commandEvent.reply(commandEvent.getClient().getError() + " Failed to update prefixes for server. Please contact a developer on the support server if this issue persists.");
metricsManager.markCommandFailed(this, commandEvent.getAuthor(), commandEvent.getGuild());
}
}
Aggregations