1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-19 16:33:36 +03:00

start working on /ban command

This commit is contained in:
nrdk 2023-06-08 17:29:45 +05:00 committed by Octol1ttle
parent 91516a899c
commit a83aa03cf0
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
3 changed files with 55 additions and 7 deletions

View file

@ -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<IConfiguration>();
var slashService = services.GetRequiredService<SlashService>();
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();
}

View file

@ -19,15 +19,15 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DiffPlex" Version="1.7.1"/>
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1"/>
<PackageReference Include="Remora.Discord" Version="2023.3.0"/>
<PackageReference Include="DiffPlex" Version="1.7.1" />
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Remora.Discord" Version="2023.3.0" />
</ItemGroup>
<!-- TODO: remove this when done -->
<ItemGroup>
<Compile Remove="old\**"/>
<Compile Remove="old\**" />
<Compile Update="Messages.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
@ -36,7 +36,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="old\**"/>
<EmbeddedResource Remove="old\**" />
<EmbeddedResource Update="Messages.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
@ -44,6 +44,6 @@
</ItemGroup>
<ItemGroup>
<None Remove="old\**"/>
<None Remove="old\**" />
</ItemGroup>
</Project>

36
Commands/BanCommand.cs Normal file
View file

@ -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;
/// <summary>
/// Initializes a new instance of the <see cref="HttpCatCommands"/> class.
/// </summary>
/// <param name="feedbackService">The feedback service.</param>
public BanCommand(FeedbackService feedbackService)
{
_feedbackService = feedbackService;
}
[Command("ban")]
[Description("банит пидора")]
public async Task<IResult> 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);
}
}