From 2869a60d6c9702b215450964a2f0d4bbf9e4636a Mon Sep 17 00:00:00 2001 From: snippet Date: Wed, 5 Apr 2017 23:04:37 +1000 Subject: [PATCH 1/2] Adds .rolehoist command --- docs/Commands List.md | 1 + .../Modules/Administration/Administration.cs | 12 +++++++++ .../Resources/CommandStrings.Designer.cs | 27 +++++++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 9 +++++++ 4 files changed, 49 insertions(+) diff --git a/docs/Commands List.md b/docs/Commands List.md index 715df776..da4d922c 100644 --- a/docs/Commands List.md +++ b/docs/Commands List.md @@ -26,6 +26,7 @@ Commands and aliases | Description | Usage `.removeallroles` `.rar` | Removes all roles from a mentioned user. **Requires ManageRoles server permission.** | `.rar @User` `.createrole` `.cr` | Creates a role with a given name. **Requires ManageRoles server permission.** | `.cr Awesome Role` `.rolecolor` `.rc` | Set a role's color to the hex or 0-255 rgb color value provided. **Requires ManageRoles server permission.** | `.rc Admin 255 200 100` or `.rc Admin ffba55` +`.rolehoist` `.rh` | Set whether the role should be displayed separately in the sidebar **Requires ManageRoles server permission.** | `.rh Guests true` or `.rolehoist "Space Wizards" true` `.deafen` `.deaf` | Deafens mentioned user or users. **Requires DeafenMembers server permission.** | `.deaf "@Someguy"` or `.deaf "@Someguy" "@Someguy"` `.undeafen` `.undef` | Undeafens mentioned user or users. **Requires DeafenMembers server permission.** | `.undef "@Someguy"` or `.undef "@Someguy" "@Someguy"` `.delvoichanl` `.dvch` | Deletes a voice channel with a given name. **Requires ManageChannels server permission.** | `.dvch VoiceChannelName` diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 6ecefe10..5b0adfaa 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -196,6 +196,18 @@ namespace NadekoBot.Modules.Administration await ReplyConfirmLocalized("cr", Format.Bold(r.Name)).ConfigureAwait(false); } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.ManageRoles)] + [RequireBotPermission(GuildPermission.ManageRoles)] + public async Task RoleHoist(string roleSearchName, bool targetState) + { + var roleName = roleSearchName.ToUpperInvariant(); + var role = Context.Guild.Roles.FirstOrDefault(r => r.Name.ToUpperInvariant() == roleName); + + await role.ModifyAsync(r => r.Hoist = targetState).ConfigureAwait(false); + } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [RequireUserPermission(GuildPermission.ManageRoles)] diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index d021e161..ef52ebd4 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -6593,6 +6593,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to rolehoist rh. + /// + public static string rolehoist_cmd { + get { + return ResourceManager.GetString("rolehoist_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Toggles if this role is displayed in the sidebar or not. + /// + public static string rolehoist_desc { + get { + return ResourceManager.GetString("rolehoist_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}rh Guests true` or `{0}rh "Space Wizards" true. + /// + public static string rolehoist_usage { + get { + return ResourceManager.GetString("rolehoist_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to rolemdl rm. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 1a943af1..859f0043 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -3366,4 +3366,13 @@ `{0}time London, UK` + + rolehoist rh + + + Toggles if this role is displayed in the sidebar or not + + + `{0}rh Guests true` or `{0}rh "Space Wizards" true + \ No newline at end of file From 80cb6e86c45ead7552002c49bbc967223833966e Mon Sep 17 00:00:00 2001 From: snippet Date: Wed, 5 Apr 2017 23:30:29 +1000 Subject: [PATCH 2/2] Adds response to .rh / .rolehoist Also swaps to PermissionAction from bool --- src/NadekoBot/Modules/Administration/Administration.cs | 6 ++++-- src/NadekoBot/Resources/ResponseStrings.Designer.cs | 9 +++++++++ src/NadekoBot/Resources/ResponseStrings.resx | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 5b0adfaa..fffac1f7 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -12,6 +12,7 @@ using NadekoBot.Services.Database.Models; using static NadekoBot.Modules.Permissions.Permissions; using System.Collections.Concurrent; using NLog; +using NadekoBot.Modules.Permissions; namespace NadekoBot.Modules.Administration { @@ -200,12 +201,13 @@ namespace NadekoBot.Modules.Administration [RequireContext(ContextType.Guild)] [RequireUserPermission(GuildPermission.ManageRoles)] [RequireBotPermission(GuildPermission.ManageRoles)] - public async Task RoleHoist(string roleSearchName, bool targetState) + public async Task RoleHoist(string roleSearchName, PermissionAction targetState) { var roleName = roleSearchName.ToUpperInvariant(); var role = Context.Guild.Roles.FirstOrDefault(r => r.Name.ToUpperInvariant() == roleName); - await role.ModifyAsync(r => r.Hoist = targetState).ConfigureAwait(false); + await role.ModifyAsync(r => r.Hoist = targetState.Value).ConfigureAwait(false); + await ReplyConfirmLocalized("rh", Format.Bold(role.Name), Format.Bold(targetState.Value.ToString())).ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index f4171166..1836004a 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -1168,6 +1168,15 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to Set the display of guild role {0} to {1}.. + /// + public static string administration_rh { + get { + return ResourceManager.GetString("administration_rh", resourceCulture); + } + } + /// /// Looks up a localized string similar to Role {0} as been added to the list.. /// diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index 2a1d1e7f..e3de1903 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -2406,4 +2406,7 @@ Owner ID: {2} Time in {0} is {1} - {2} Time in London, UK is 15:30 - Time Zone Name + + Set the display of guild role {0} to {1}. + \ No newline at end of file