-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/Commands/Moderation/GuildSettingsCommand/GuildSettingsCommand.RestoreRoles.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Threading.Tasks; | ||
using DSharpPlus.Commands; | ||
using DSharpPlus.Commands.ContextChecks; | ||
using DSharpPlus.Entities; | ||
using OoLunar.Tomoe.Database.Models; | ||
|
||
namespace OoLunar.Tomoe.Commands.Moderation | ||
{ | ||
public sealed partial class GuildSettingsCommand | ||
{ | ||
/// <summary> | ||
/// Whether or not to restore roles when a member rejoins the server. | ||
/// </summary> | ||
/// <param name="restoreRoles">Whether or not to restore roles when a member rejoins the server.</param> | ||
[Command("restore_roles")] | ||
[RequirePermissions(DiscordPermissions.ManageRoles, DiscordPermissions.ManageGuild)] | ||
public static async ValueTask RestoreRolesAsync(CommandContext context, bool restoreRoles = false) | ||
{ | ||
GuildSettingsModel? settings = await GuildSettingsModel.GetSettingsAsync(context.Guild!.Id); | ||
if (settings is null) | ||
{ | ||
await context.RespondAsync(NOT_SETUP_TEXT); | ||
return; | ||
} | ||
|
||
await GuildSettingsModel.UpdateSettingsAsync(settings with | ||
{ | ||
RestoreRoles = restoreRoles | ||
}); | ||
|
||
await context.RespondAsync("I will " + (restoreRoles ? "now restore" : "no longer restore") + " a member's previous roles when they rejoin server."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters