From c4033d0135d17ef1a5ec51e56ebdc2cc8aca9a30 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:02:05 +0800 Subject: [PATCH] Changed the verbiage to role as it sounds a bit better and gave guest role a descriptor "Rat" --- KfChatDotNetBot/Commands/AdminCommands.cs | 14 +++++++------- KfChatDotNetBot/Models/DbModels/UserDbModel.cs | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/KfChatDotNetBot/Commands/AdminCommands.cs b/KfChatDotNetBot/Commands/AdminCommands.cs index e047901..500aaaf 100644 --- a/KfChatDotNetBot/Commands/AdminCommands.cs +++ b/KfChatDotNetBot/Commands/AdminCommands.cs @@ -7,21 +7,21 @@ using Microsoft.EntityFrameworkCore; namespace KfChatDotNetBot.Commands; -public class SetRightCommand : ICommand +public class SetRoleCommand : ICommand { public List Patterns => [ - new Regex(@"^admin role set (?\d+) (?\d+)$"), - new Regex(@"^admin right set (?\d+) (?\d+)$") + new Regex(@"^admin role set (?\d+) (?\d+)$"), + new Regex(@"^admin right set (?\d+) (?\d+)$") ]; - public string? HelpText => "Set a user's right"; + public string? HelpText => "Set a user's role"; public UserRight RequiredRight => UserRight.Admin; public TimeSpan Timeout => TimeSpan.FromSeconds(10); public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, CancellationToken ctx) { await using var db = new ApplicationDbContext(); var targetUserId = Convert.ToInt32(arguments["user"].Value); - var right = (UserRight)Convert.ToInt32(arguments["right"].Value); + var role = (UserRight)Convert.ToInt32(arguments["role"].Value); var targetUser = await db.Users.FirstOrDefaultAsync(u => u.KfId == targetUserId, cancellationToken: ctx); if (targetUser == null) { @@ -29,9 +29,9 @@ public class SetRightCommand : ICommand return; } - targetUser.UserRight = right; + targetUser.UserRight = role; await db.SaveChangesAsync(ctx); - botInstance.SendChatMessage($"@{message.Author.Username}, {targetUser.KfUsername}'s right set to {right.Humanize()}", true); + botInstance.SendChatMessage($"@{message.Author.Username}, {targetUser.KfUsername}'s role set to {role.Humanize()}", true); } } diff --git a/KfChatDotNetBot/Models/DbModels/UserDbModel.cs b/KfChatDotNetBot/Models/DbModels/UserDbModel.cs index 5aeaafe..a41a554 100644 --- a/KfChatDotNetBot/Models/DbModels/UserDbModel.cs +++ b/KfChatDotNetBot/Models/DbModels/UserDbModel.cs @@ -16,6 +16,7 @@ public enum UserRight Admin = 1000, [Description("True and Honest")] TrueAndHonest = 100, + [Description("Rat")] Guest = 10, Loser = 0 } \ No newline at end of file