From a83aa03cf095af83d2ebf9e9a3389a0f0a5fdb37 Mon Sep 17 00:00:00 2001 From: nrdk Date: Thu, 8 Jun 2023 17:29:45 +0500 Subject: [PATCH] start working on /ban command --- Boyfriend.cs | 12 ++++++++++++ Boyfriend.csproj | 14 +++++++------- Commands/BanCommand.cs | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 Commands/BanCommand.cs diff --git a/Boyfriend.cs b/Boyfriend.cs index 0d42939..ecbd911 100644 --- a/Boyfriend.cs +++ b/Boyfriend.cs @@ -10,6 +10,7 @@ using Remora.Discord.API.Objects; using Remora.Discord.Caching.Extensions; using Remora.Discord.Caching.Services; using Remora.Discord.Commands.Extensions; +using Remora.Discord.Commands.Services; using Remora.Discord.Gateway; using Remora.Discord.Gateway.Extensions; using Remora.Discord.Hosting.Extensions; @@ -24,6 +25,17 @@ public class Boyfriend { public static async Task Main(string[] args) { var host = CreateHostBuilder(args).UseConsoleLifetime().Build(); + var services = host.Services; + var configuration = services.GetRequiredService(); + + + + + var slashService = services.GetRequiredService(); + var updateSlash = await slashService.UpdateSlashCommandsAsync(new Snowflake(1115043975573811250)); + if (!updateSlash.IsSuccess) { + Console.WriteLine("Failed to update slash commands: {Reason}", updateSlash.Error.Message); + } await host.RunAsync(); } diff --git a/Boyfriend.csproj b/Boyfriend.csproj index 444f4ab..915de88 100644 --- a/Boyfriend.csproj +++ b/Boyfriend.csproj @@ -19,15 +19,15 @@ - - - - + + + + - + True True @@ -36,7 +36,7 @@ - + ResXFileCodeGenerator Messages.Designer.cs @@ -44,6 +44,6 @@ - + diff --git a/Commands/BanCommand.cs b/Commands/BanCommand.cs new file mode 100644 index 0000000..131eb4c --- /dev/null +++ b/Commands/BanCommand.cs @@ -0,0 +1,36 @@ +using System.ComponentModel; +using Remora.Commands.Attributes; +using Remora.Commands.Groups; +using Remora.Discord.API.Abstractions.Objects; +using Remora.Discord.API.Gateway.Events; +using Remora.Discord.API.Objects; +using Remora.Discord.Commands.Attributes; +using Remora.Discord.Commands.Feedback.Services; +using Remora.Rest.Core; +using Remora.Results; + +namespace Boyfriend.Commands; + +public class BanCommand : CommandGroup{ + private readonly FeedbackService _feedbackService; + + /// + /// Initializes a new instance of the class. + /// + /// The feedback service. + public BanCommand(FeedbackService feedbackService) + { + _feedbackService = feedbackService; + } + + + [Command("ban")] + [Description("банит пидора")] + public async Task BanAsync([Description("Юзер, кого банить")] IUser user, string reason) { + var banan = new Ban(reason, user); + var embed = new Embed(Colour: _feedbackService.Theme.Secondary, Description: "забанен нахуй"); + + return (Result)await _feedbackService.SendContextualEmbedAsync(embed, ct: this.CancellationToken); + + } +}