File tree Expand file tree Collapse file tree 5 files changed +12
-19
lines changed
Volte/Core/Commands/Modules Expand file tree Collapse file tree 5 files changed +12
-19
lines changed Original file line number Diff line number Diff line change 11using System . Linq ;
22using System . Threading . Tasks ;
33using Discord ;
4+ using Discord . WebSocket ;
45using Qmmands ;
56using Volte . Core . Commands . Preconditions ;
67using Volte . Core . Extensions ;
@@ -11,23 +12,18 @@ public partial class AdminModule : VolteModule
1112 {
1213 [ Command ( "AdminRole" ) ]
1314 [ Description ( "Sets the role able to use Admin commands for the current guild." ) ]
14- [ Remarks ( "Usage: |prefix|adminrole {roleName }" ) ]
15+ [ Remarks ( "Usage: |prefix|adminrole {role }" ) ]
1516 [ RequireGuildAdmin ]
16- public async Task AdminRoleAsync ( [ Remainder ] string roleName )
17+ public async Task AdminRoleAsync ( SocketRole role )
1718 {
1819 var embed = Context . CreateEmbed ( string . Empty ) . ToEmbedBuilder ( ) ;
1920 var config = Db . GetConfig ( Context . Guild ) ;
20- var role = Context . Guild . Roles . FirstOrDefault ( r => r . Name . EqualsIgnoreCase ( roleName ) ) ;
2121 if ( role != null )
2222 {
2323 config . ModerationOptions . AdminRole = role . Id ;
2424 Db . UpdateConfig ( config ) ;
2525 embed . WithDescription ( $ "Set **{ role . Name } ** as the Admin role for this server.") ;
2626 }
27- else
28- {
29- embed . WithDescription ( $ "**{ roleName } ** doesn't exist in this server.") ;
30- }
3127
3228 await embed . SendTo ( Context . Channel ) ;
3329 }
Original file line number Diff line number Diff line change 11using System . Linq ;
22using System . Threading . Tasks ;
3+ using Discord . WebSocket ;
34using Qmmands ;
45using Volte . Core . Commands . Preconditions ;
56using Volte . Core . Extensions ;
@@ -10,17 +11,12 @@ public partial class AdminModule : VolteModule
1011 {
1112 [ Command ( "ModRole" ) ]
1213 [ Description ( "Sets the role able to use Moderation commands for the current guild." ) ]
13- [ Remarks ( "Usage: |prefix|modrole {roleName }" ) ]
14+ [ Remarks ( "Usage: |prefix|modrole {role }" ) ]
1415 [ RequireGuildAdmin ]
15- public async Task ModRoleAsync ( [ Remainder ] string roleName )
16+ public async Task ModRoleAsync ( SocketRole role )
1617 {
1718 var config = Db . GetConfig ( Context . Guild ) ;
18- var role = Context . Guild . Roles . FirstOrDefault ( r => r . Name . EqualsIgnoreCase ( roleName ) ) ;
19- if ( role is null )
20- {
21- await Context . CreateEmbed ( $ "{ roleName } doesn't exist in this server.") . SendTo ( Context . Channel ) ;
22- }
23- else
19+ if ( role != null )
2420 {
2521 config . ModerationOptions . ModRole = role . Id ;
2622 Db . UpdateConfig ( config ) ;
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ public async Task CommandAsync([Remainder] string cmdName)
2222
2323 if ( ( c . Module . SanitizeName ( ) . EqualsIgnoreCase ( "admin" ) && ! UserUtil . IsAdmin ( Context ) ) ||
2424 ( c . Module . SanitizeName ( ) . EqualsIgnoreCase ( "owner" ) && ! UserUtil . IsBotOwner ( Context . User ) ) ||
25- ( c . Module . SanitizeName ( ) . EqualsIgnoreCase ( "moderation" ) && ! UserUtil . IsModerator ( Context ) ) )
25+ ( c . Module . SanitizeName ( ) . EqualsIgnoreCase ( "moderation" ) && ! UserUtil . IsModerator ( Context ) ) ||
26+ ( c . Module . SanitizeName ( ) . EqualsIgnoreCase ( "serveradmin" ) && ! UserUtil . IsAdmin ( Context ) ) )
2627 {
2728 await Context . CreateEmbed ( $ "{ EmojiService . X } You don't have permission to use the module that command is from.")
2829 . SendTo ( Context . Channel ) ;
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ public async Task CommandsAsync(string module)
2222
2323 if ( ( target . SanitizeName ( ) . EqualsIgnoreCase ( "admin" ) && ! UserUtil . IsAdmin ( Context ) ) ||
2424 ( target . SanitizeName ( ) . EqualsIgnoreCase ( "owner" ) && ! UserUtil . IsBotOwner ( Context . User ) ) ||
25- ( target . SanitizeName ( ) . EqualsIgnoreCase ( "moderation" ) && ! UserUtil . IsModerator ( Context ) ) )
25+ ( target . SanitizeName ( ) . EqualsIgnoreCase ( "moderation" ) && ! UserUtil . IsModerator ( Context ) ) ||
26+ ( target . SanitizeName ( ) . EqualsIgnoreCase ( "serveradmin" ) && ! UserUtil . IsAdmin ( Context ) ) )
2627 {
2728 await Context . CreateEmbed ( $ "{ EmojiService . X } You don't have permission to use the module that command is from.")
2829 . SendTo ( Context . Channel ) ;
Original file line number Diff line number Diff line change @@ -12,8 +12,7 @@ public partial class HelpModule : VolteModule
1212 [ Remarks ( "Usage: |prefix|modules" ) ]
1313 public async Task ModulesAsync ( )
1414 {
15- var modules = CommandService . GetAllModules ( ) . Aggregate ( string . Empty ,
16- ( current , module ) => current + $ "`{ module . SanitizeName ( ) } `, ") ;
15+ var modules = $ "`{ string . Join ( "`, `" , CommandService . GetAllModules ( ) . Select ( x => x . SanitizeName ( ) ) ) } `";
1716 await Context . CreateEmbedBuilder ( modules . Remove ( modules . LastIndexOf ( "," ) ) ) . WithTitle ( "Available Modules" )
1817 . SendTo ( Context . Channel ) ;
1918 }
You can’t perform that action at this time.
0 commit comments