|
29 | 29 | $logger.info("Message from #{event.user.name} (#{event.user.id})") |
30 | 30 | $logger.info(event.message.content) |
31 | 31 |
|
32 | | - if /(?<trigger>!moderation)\s(?<command>watchlist)(\s(?<subcommand>add|remove)\s<@(?<user_id>\d+)>)?/i =~ event.message.content |
| 32 | + if /(?<trigger>!moderation)(\s(?<command>watchlist))?(\s(?<subcommand>add|remove)\s<@(?<user_id>\d+)>)?/i =~ event.message.content |
33 | 33 | $logger.info("Moderation command from #{event.user.name} (#{event.user.id})") |
34 | 34 | event.server.members.each do |member| |
35 | 35 | # ensure triggering user has proper privileges |
36 | 36 | if member.id == event.user.id && member.permission?(:administrator) |
37 | 37 | # handle watchlist commands |
38 | | - if trigger && command == "watchlist" && subcommand.nil? |
39 | | - event.respond("Watch list: " + get_watch_list_users(event.server.id).map { |user_id| "<@#{user_id}>" }.join(", ")) |
40 | | - elsif subcommand == "add" && user_id |
41 | | - add_user_to_watch_list(event.server.id, user_id.to_i) |
42 | | - event.respond("Added <@#{user_id}> to watch list") |
43 | | - elsif subcommand == "remove" && user_id |
44 | | - remove_user_from_watch_list(event.server.id, user_id.to_i) |
45 | | - event.respond("Removed <@#{user_id}> from watch list") |
| 38 | + if trigger && command == "watchlist" |
| 39 | + if subcommand.nil? |
| 40 | + event.respond("Watch list: " + get_watch_list_users(event.server.id).map { |user_id| "<@#{user_id}>" }.join(", ")) |
| 41 | + elsif subcommand == "add" && user_id |
| 42 | + add_user_to_watch_list(event.server.id, user_id.to_i) |
| 43 | + event.respond("Added <@#{user_id}> to watch list") |
| 44 | + elsif subcommand == "remove" && user_id |
| 45 | + remove_user_from_watch_list(event.server.id, user_id.to_i) |
| 46 | + event.respond("Removed <@#{user_id}> from watch list") |
| 47 | + else |
| 48 | + event.respond("Usage: !moderation watchlist [add|remove @user]") |
| 49 | + end |
46 | 50 | else |
| 51 | + event.respond("Usage: !moderation watchlist [add|remove @user]") |
47 | 52 | end |
48 | 53 | # break early if we found the right user |
49 | 54 | break |
|
0 commit comments