Skip to content

Commit

Permalink
Merge pull request #1 from outerwinnie/test
Browse files Browse the repository at this point in the history
Make text non mandatory
  • Loading branch information
outerwinnie authored Sep 2, 2024
2 parents fab9580 + 776d187 commit 0f6e375
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hall-of-fame-bot.generated.sln
15 changes: 11 additions & 4 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions obj/ConfessBot.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Binary file modified obj/Debug/net7.0/ConfessBot.assets.cache
Binary file not shown.
6 changes: 3 additions & 3 deletions obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0f6e375

Please sign in to comment.