Skip to content

Commit 7edea7a

Browse files
committed
Add the ability to set a secondary mod role
1 parent a82d211 commit 7edea7a

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

src/Bot/Helpers/DiscordHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static bool IsAdmin(this VolteContext ctx, IGuildUser user)
3838

3939
public static bool IsModerator(this VolteContext ctx, IGuildUser user)
4040
=> user.HasRole(ctx.GuildData.Settings.Moderation.ModRole)
41+
|| user.HasRole(ctx.GuildData.Settings.Moderation.SecondaryModRole)
4142
|| ctx.IsAdmin(user)
4243
|| IsGuildOwner(user);
4344

src/Bot/Systems/Commands/Text/Modules/Settings/ModRoleCommand.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,21 @@ public Task<ActionResult> ModRoleAsync(
1616
Context.Modify(data => data.Settings.Moderation.ModRole = role.Id);
1717
return Ok($"Set {role.Mention} as the Moderator role for this guild.");
1818
}
19+
20+
[Command("SecondaryModRole", "ModRole2", "Mod2")]
21+
[Description("Sets a secondary role able to use Moderation commands for the current guild.")]
22+
public Task<ActionResult> SecondaryModRoleAsync(
23+
[Remainder,
24+
Description("The role to be set as the secondary Moderator role; or none if you want to reset.")]
25+
SocketRole role = null)
26+
{
27+
if (role is null)
28+
{
29+
Context.Modify(data => data.Settings.Moderation.SecondaryModRole = 0);
30+
return Ok("Reset the secondary Moderator role.");
31+
}
32+
33+
Context.Modify(data => data.Settings.Moderation.ModRole = role.Id);
34+
return Ok($"Set {role.Mention} as the secondary Moderator role for this guild.");
35+
}
1936
}

src/Bot/Systems/Database/EntitiesV2/GuildDataV2.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static GuildDataV2 CreateFrom(IGuild guild)
5151
ActionLogChannel = default,
5252
AdminRole = default,
5353
ModRole = default,
54+
SecondaryModRole = default,
5455
CheckAccountAge = false,
5556
VerifiedRole = default,
5657
UnverifiedRole = default,
@@ -104,6 +105,7 @@ public static GuildDataV2 CreateFrom(IGuild guild)
104105
ActionLogChannel = v1.Configuration.Moderation.ModActionLogChannel,
105106
AdminRole = v1.Configuration.Moderation.AdminRole,
106107
ModRole = v1.Configuration.Moderation.ModRole,
108+
SecondaryModRole = default,
107109
CheckAccountAge = v1.Configuration.Moderation.CheckAccountAge,
108110
VerifiedRole = v1.Configuration.Moderation.VerifiedRole,
109111
UnverifiedRole = v1.Configuration.Moderation.UnverifiedRole,

src/Bot/Systems/Database/EntitiesV2/ModerationData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class ModerationData
44
{
55
public ulong CurrentModActionCase { get; set; }
6-
6+
77
public HashSet<WarnV2> Warns { get; set; }
88

99
public bool AddWarn(WarnInitializer warnInitializer)
@@ -13,6 +13,6 @@ public bool AddWarn(WarnInitializer warnInitializer)
1313

1414
return AddWarn(warn);
1515
}
16-
16+
1717
public bool AddWarn(WarnV2 warn) => Warns.Add(warn);
1818
}

src/Bot/Systems/Database/EntitiesV2/ModerationSettings.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
public class ModerationSettings
44
{
55
public ulong ActionLogChannel { get; set; }
6-
6+
77
public ulong ModRole { get; set; }
8-
8+
9+
public ulong SecondaryModRole { get; set; }
10+
911
public ulong AdminRole { get; set; }
10-
12+
1113
public bool CheckAccountAge { get; set; }
12-
14+
1315
public ulong UnverifiedRole { get; set; }
14-
16+
1517
public ulong VerifiedRole { get; set; }
16-
18+
1719
public bool ShowResponsibleModerator { get; set; }
1820
}

0 commit comments

Comments
 (0)