Skip to content

Commit

Permalink
Create TagsCmd.java
Browse files Browse the repository at this point in the history
This is just ?listtags but renamed
  • Loading branch information
ya64 committed Jun 10, 2020
1 parent e85385d commit f99eb5e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/main/java/com/jagrosh/vortex/commands/general/TagsCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.jagrosh.vortex.commands.general;

import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.vortex.Vortex;
import com.jagrosh.vortex.commands.CommandTools;
import net.dv8tion.jda.core.Permission;

import java.util.List;

public class TagsCmd extends Command
{
private final Vortex vortex;

public TagsCmd(Vortex vortex)
{
this.name = "tags";
this.arguments = "";
this.help = "lists all tags";
this.guildOnly = true;
this.vortex = vortex;
}

@Override
public void execute(CommandEvent event)
{
if (!CommandTools.hasGeneralCommandPerms(vortex, event, Permission.MESSAGE_MANAGE))
return;

List<String> tags = vortex.getDatabase().tags.getTagNames(event.getGuild());

if (tags.isEmpty())
{
event.reply("There are no tags on this server");
return;
}

String response = tags.get(0).toUpperCase().substring(0,1) + tags.get(0).substring(1) + (tags.size() != 1 ? ", " : ".");
for (int i = 1; i < tags.size(); i++)
{
response += tags.get(i) + (i == tags.size() - 1 ? "." : ", ");
}

event.reply(response);
}
}

0 comments on commit f99eb5e

Please sign in to comment.