From 0b6c3fc2237a864584acc00f0063fb1d646a4d2c Mon Sep 17 00:00:00 2001 From: zobweyt Date: Thu, 27 Jun 2024 14:04:10 +0300 Subject: [PATCH] Remove reference options --- .../Common/Options/ReferenceOptions.cs | 25 ------------- src/Giveaways/Modules/GeneralModule.cs | 35 ------------------- src/Giveaways/Program.cs | 1 - src/Giveaways/appsettings.json | 4 --- 4 files changed, 65 deletions(-) delete mode 100644 src/Giveaways/Common/Options/ReferenceOptions.cs delete mode 100644 src/Giveaways/Modules/GeneralModule.cs diff --git a/src/Giveaways/Common/Options/ReferenceOptions.cs b/src/Giveaways/Common/Options/ReferenceOptions.cs deleted file mode 100644 index 8b4abda..0000000 --- a/src/Giveaways/Common/Options/ReferenceOptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Giveaways; - -/// -/// Represents the reference options associated with this app. -/// -public class ReferenceOptions : INamedOptions -{ - public static string GetSectionName() => "Reference"; - - /// - /// The URL of the support server in Discord. - /// - [Required] - [Url] - public required string SupportServerUrl { get; init; } - - /// - /// The URL of the source repository. - /// - [Required] - [Url] - public required string SourceRepositoryUrl { get; init; } -} diff --git a/src/Giveaways/Modules/GeneralModule.cs b/src/Giveaways/Modules/GeneralModule.cs deleted file mode 100644 index 8d82f7a..0000000 --- a/src/Giveaways/Modules/GeneralModule.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Discord; -using Discord.Interactions; -using Microsoft.Extensions.Options; - -namespace Giveaways.Modules; - -public class GeneralModule(IOptions options) : ModuleBase -{ - [SlashCommand("about", "Shows information about the app.")] - public async Task AboutAsync() - { - var app = await Context.Client.GetApplicationInfoAsync(); - - var embed = new EmbedBuilder() - .WithTitle(app.Name) - .WithDescription(app.Description) - .AddField("Servers", Context.Client.Guilds.Count, true) - .AddField("Latency", Context.Client.Latency + "ms", true) - .AddField("Version", Assembly.GetExecutingAssembly().GetName().Version, true) - .WithAuthor(app.Owner.Username, app.Owner.GetDisplayAvatarUrl()) - .WithFooter(string.Join(" ยท ", app.Tags.Select(t => '#' + t))) - .WithColor(Colors.Primary) - .Build(); - - var components = new ComponentBuilder() - .WithLink("Support", Emotes.Logos.Discord, options.Value.SupportServerUrl) - .WithLink("Source", Emotes.Logos.Github, options.Value.SourceRepositoryUrl) - .Build(); - - await RespondAsync(embed: embed, components: components); - } -} diff --git a/src/Giveaways/Program.cs b/src/Giveaways/Program.cs index 9218d94..c2ef11d 100644 --- a/src/Giveaways/Program.cs +++ b/src/Giveaways/Program.cs @@ -17,7 +17,6 @@ var builder = Host.CreateApplicationBuilder(args); builder.Services.AddNamedOptions(); -builder.Services.AddNamedOptions(); builder.Services.AddSqlite(builder.Configuration.GetConnectionString("Default")); diff --git a/src/Giveaways/appsettings.json b/src/Giveaways/appsettings.json index bba317f..fb26a46 100644 --- a/src/Giveaways/appsettings.json +++ b/src/Giveaways/appsettings.json @@ -3,10 +3,6 @@ "Token": "", "DevGuildId": 0 }, - "Reference": { - "SupportServerUrl": "", - "SourceRepositoryUrl": "" - }, "Logging": { "LogLevel": { "Default": "Debug",