forked from ya64/Toybot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is just ?listtags but renamed
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/com/jagrosh/vortex/commands/general/TagsCmd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |