diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e60a3d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +hall-of-fame-bot.generated.sln diff --git a/Program.cs b/Program.cs index 14d2794..98d020f 100644 --- a/Program.cs +++ b/Program.cs @@ -52,7 +52,7 @@ private async Task RegisterCommandsAsync() var postCommand = new SlashCommandBuilder() .WithName("post") .WithDescription("Post something anonymously") - .AddOption("text", ApplicationCommandOptionType.String, "The text to post", isRequired: true) + .AddOption("text", ApplicationCommandOptionType.String, "The text to post", isRequired: false) .AddOption("file", ApplicationCommandOptionType.Attachment, "Optional file to attach", isRequired: false); // Replace 'your_guild_id_here' with your actual guild ID @@ -77,8 +77,11 @@ private async Task HandleInteraction(SocketInteraction interaction) var user = command.User; // Get the user who triggered the command - // Log the user and the message text - Console.WriteLine($"[{DateTime.Now}] {user.Username} ({user.Id}) sent: {text}"); + // Log the user and the message text or file information + if (!string.IsNullOrWhiteSpace(text)) + { + Console.WriteLine($"[{DateTime.Now}] {user.Username} ({user.Id}) sent: {text}"); + } await command.RespondAsync("Your post has been sent!", ephemeral: true); // Responds privately @@ -90,9 +93,13 @@ private async Task HandleInteraction(SocketInteraction interaction) await command.Channel.SendFileAsync(stream, attachmentOption.Filename, text); // Sends the message with the file in the channel } } + else if (!string.IsNullOrWhiteSpace(text)) + { + await command.Channel.SendMessageAsync(text); // Sends the message in the channel if text is provided + } else { - await command.Channel.SendMessageAsync(text); // Sends the message in the channel + await command.RespondAsync("You need to provide either text or a file.", ephemeral: true); } } } diff --git a/obj/ConfessBot.csproj.nuget.dgspec.json b/obj/ConfessBot.csproj.nuget.dgspec.json index 3c84847..cbf7ba8 100644 --- a/obj/ConfessBot.csproj.nuget.dgspec.json +++ b/obj/ConfessBot.csproj.nuget.dgspec.json @@ -1,17 +1,17 @@ { "format": 1, "restore": { - "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\ConfessBot.csproj": {} + "D:\\Winnie\\Documentos\\hall-of-fame-bot\\ConfessBot.csproj": {} }, "projects": { - "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\ConfessBot.csproj": { + "D:\\Winnie\\Documentos\\hall-of-fame-bot\\ConfessBot.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\ConfessBot.csproj", + "projectUniqueName": "D:\\Winnie\\Documentos\\hall-of-fame-bot\\ConfessBot.csproj", "projectName": "ConfessBot", - "projectPath": "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\ConfessBot.csproj", + "projectPath": "D:\\Winnie\\Documentos\\hall-of-fame-bot\\ConfessBot.csproj", "packagesPath": "C:\\Users\\Winnie\\.nuget\\packages\\", - "outputPath": "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\obj\\", + "outputPath": "D:\\Winnie\\Documentos\\hall-of-fame-bot\\obj\\", "projectStyle": "PackageReference", "configFilePaths": [ "C:\\Users\\Winnie\\AppData\\Roaming\\NuGet\\NuGet.Config" diff --git a/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs b/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs new file mode 100644 index 0000000..4257f4b --- /dev/null +++ b/obj/Debug/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")] diff --git a/obj/Debug/net7.0/ConfessBot.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net7.0/ConfessBot.GeneratedMSBuildEditorConfig.editorconfig index 8c551da..5fa8ed1 100644 --- a/obj/Debug/net7.0/ConfessBot.GeneratedMSBuildEditorConfig.editorconfig +++ b/obj/Debug/net7.0/ConfessBot.GeneratedMSBuildEditorConfig.editorconfig @@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = ConfessBot -build_property.ProjectDir = C:\Users\Winnie\Desktop\hall-of-fame-bot\ +build_property.ProjectDir = D:\Winnie\Documentos\hall-of-fame-bot\ diff --git a/obj/Debug/net7.0/ConfessBot.assets.cache b/obj/Debug/net7.0/ConfessBot.assets.cache index 711dbf7..300fe47 100644 Binary files a/obj/Debug/net7.0/ConfessBot.assets.cache and b/obj/Debug/net7.0/ConfessBot.assets.cache differ diff --git a/obj/project.assets.json b/obj/project.assets.json index bf24d22..66e5e18 100644 --- a/obj/project.assets.json +++ b/obj/project.assets.json @@ -660,11 +660,11 @@ "project": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\ConfessBot.csproj", + "projectUniqueName": "D:\\Winnie\\Documentos\\hall-of-fame-bot\\ConfessBot.csproj", "projectName": "ConfessBot", - "projectPath": "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\ConfessBot.csproj", + "projectPath": "D:\\Winnie\\Documentos\\hall-of-fame-bot\\ConfessBot.csproj", "packagesPath": "C:\\Users\\Winnie\\.nuget\\packages\\", - "outputPath": "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\obj\\", + "outputPath": "D:\\Winnie\\Documentos\\hall-of-fame-bot\\obj\\", "projectStyle": "PackageReference", "configFilePaths": [ "C:\\Users\\Winnie\\AppData\\Roaming\\NuGet\\NuGet.Config" diff --git a/obj/project.nuget.cache b/obj/project.nuget.cache index 641fdc3..7112426 100644 --- a/obj/project.nuget.cache +++ b/obj/project.nuget.cache @@ -1,8 +1,8 @@ { "version": 2, - "dgSpecHash": "MZMWTKxAAadmNCnyAnlv/BJt4zTSOPCYtsRkVl2ErPUx0DGjkq2fB8zD4K2jS653h+/KGzj7AG/u6Rvw3qs24A==", + "dgSpecHash": "nVvEYynI15TnbFxZexpfyfxJnTyOvD7Zm4LAhiS+juUuzAEkJbDmX752BQ9v9PiGwghMIXCvoL2vbsEDb9k7BQ==", "success": true, - "projectFilePath": "C:\\Users\\Winnie\\Desktop\\hall-of-fame-bot\\ConfessBot.csproj", + "projectFilePath": "D:\\Winnie\\Documentos\\hall-of-fame-bot\\ConfessBot.csproj", "expectedPackageFiles": [ "C:\\Users\\Winnie\\.nuget\\packages\\discord.net\\3.15.3\\discord.net.3.15.3.nupkg.sha512", "C:\\Users\\Winnie\\.nuget\\packages\\discord.net.commands\\3.15.3\\discord.net.commands.3.15.3.nupkg.sha512",