1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-04 04:56:30 +03:00

Add /ban command v1

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-06-08 21:04:17 +05:00
parent a83aa03cf0
commit 806746925e
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
10 changed files with 275 additions and 81 deletions

View file

@ -1,8 +1,11 @@
using Boyfriend.Data.Services;
using Boyfriend.Commands;
using Boyfriend.Services;
using Boyfriend.Services.Data;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Remora.Commands.Extensions;
using Remora.Discord.API.Abstractions.Gateway.Commands;
using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Gateway.Commands;
@ -26,16 +29,10 @@ 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 slashService.UpdateSlashCommandsAsync();
await host.RunAsync();
}
@ -71,10 +68,13 @@ public class Boyfriend {
services.AddTransient<IConfigurationBuilder, ConfigurationBuilder>()
.AddDiscordCaching()
.AddDiscordCommands()
.AddDiscordCommands(true)
.AddInteractivity()
.AddInteractionGroup<InteractionResponders>()
.AddSingleton<GuildDataService>();
.AddSingleton<GuildDataService>()
.AddSingleton<UtilityService>()
.AddCommandTree()
.WithCommandGroup<BanCommand>();
var responderTypes = typeof(Boyfriend).Assembly
.GetExportedTypes()
.Where(t => t.IsResponder());
@ -86,8 +86,4 @@ public class Boyfriend {
.AddFilter("System.Net.Http.HttpClient.*.ClientHandler", LogLevel.Warning)
);
}
public static string GetLocalized(string key) {
return Messages.ResourceManager.GetString(key, Messages.Culture) ?? key;
}
}