Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Require admin permissions for $clear #56

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/java/listeners/MainEventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ private void help(Member member, TextChannel channel, Server server, String[] ar

if (isMentor(member) || isAdmin(member)) {
embedBuilder.addField("$ready <topic> (mentor only)", "Retrieve the next person from the queue.", false);
embedBuilder.addField("$kick <@user> <topic> <reason>", "Kick the specified user from the queue.", false);
embedBuilder.addField("$clear <topic> (mentor only)", "Clear the specified queue.", false);
embedBuilder.addField("$kick <@user> <topic> <reason> (mentor only)", "Kick the specified user from the queue.", false);
embedBuilder.addField("$finish (mentor only)", "Finish a mentoring session. Must be run inside the text channel for that session.", false);
}

if (isAdmin(member)) {
embedBuilder.addField("$maketopic <name> (admin only)", "Create a new topic.", false);
embedBuilder.addField("$deletetopic <name> (admin only)", "Delete a topic.", false);
embedBuilder.addField("$clear <topic> (admin only)", "Clear the specified queue.", false);
}

channel.sendMessage(embedBuilder.build()).queue();
Expand Down Expand Up @@ -362,10 +362,10 @@ private void clear(Member member, TextChannel channel, Server server, String[] a
Optional<Topic> optionalTopic = checkTopicExists(member, channel, server, topicName);
if (optionalTopic.isEmpty()) return;

// do not run if caller does not have mentor role for this topic or admin privileges
// do not run if caller is not an admin
Topic topic = optionalTopic.get();
if (!isMentor(member, topic) && !isAdmin(member)) {
BotResponses.noPermission(channel, member);
if (!isAdmin(member)) {
BotResponses.noAdminPermission(channel, member);
return;
}

Expand Down