Skip to content

Commit 3fd1433

Browse files
committed
fix register slash command error
1 parent af069bd commit 3fd1433

5 files changed

Lines changed: 24 additions & 44 deletions

File tree

src/Disc.NET.Commands/Attributes/SlashCommandAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Disc.NET.Commands.Attributes
1111
public class SlashCommandAttribute : Attribute
1212
{
1313
public string Name { get; init; }
14+
// Talvez abstrair isso para um unico tipo de comando futuramente
1415
public InteractionType Type { get; init; }
1516
public string Description { get; init; }
1617

src/Disc.NET.Commands/ISlashCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Disc.NET.Commands
1111
public interface ISlashCommand : ICommand<InteractionContext>
1212
{
1313
Task<bool> RunAsync(InteractionContext context, SlashCommandParamsResult paramsResult);
14-
List<SlashCommandOptions> BuildOptions();
14+
List<SlashCommandOptions> BuildOptions() => [];
1515

1616
}
1717
}

src/Disc.NET/Handlers/EventHandlers/SlashCommandRegisterHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override async Task HandleAsync(GatewayEvent @event, JsonDocument context
2626
foreach (var attribute in attributes)
2727
{
2828
var command = (ISlashCommand)
29-
GetCommandByAttribute<SlashCommandAttribute, CommandContext>(attribute.Name);
29+
GetCommandByAttribute<SlashCommandAttribute, InteractionContext>(attribute.Name);
3030
if (command == null)
3131
{
3232
continue;

tests/GenericBot/SlashCommandTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace GenericBot
1212
{
13-
[SlashCommand("teste3", InteractionType.SubCommand, "teste comand", GuildId = "1336392659992051762")]
13+
[SlashCommand("comando_com_parametros", InteractionType.SubCommand, "teste comand", GuildId = "1336392659992051762")]
1414
public class SlashCommandTest : CommandBase, ISlashCommand
1515
{
1616
public async Task<bool> RunAsync(InteractionContext context, SlashCommandParamsResult paramsResult)
Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,23 @@
1-
//using Disc.NET.Commands;
2-
//using Disc.NET.Commands.Attributes;
3-
//using Disc.NET.Commands.Contexts;
4-
//using Disc.NET.Shared.Enums;
5-
//using System;
6-
//using System.Collections.Generic;
7-
//using System.Linq;
8-
//using System.Text;
9-
//using System.Threading.Tasks;
1+
using Disc.NET.Commands;
2+
using Disc.NET.Commands.Attributes;
3+
using Disc.NET.Commands.Contexts;
4+
using Disc.NET.Shared.Enums;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
1010

11-
//namespace GenericBot
12-
//{
13-
// [SlashCommand("teste2", InteractionType.String, "teste comand2")]
11+
namespace GenericBot
12+
{
13+
[SlashCommand("comando_sem_parametros", InteractionType.SubCommand, "teste comand2")]
1414

15-
// internal class SlashCommandTest2 : CommandBase, ISlashCommand<CommandContext>
16-
// {
17-
// public Task<bool> RunAsync(CommandContext context, SlashCommandParamsResult result)
18-
// {
19-
// throw new NotImplementedException();
20-
// }
15+
internal class SlashCommandTest2 : CommandBase, ISlashCommand
16+
{
17+
public async Task<bool> RunAsync(InteractionContext context, SlashCommandParamsResult result)
18+
{
19+
return true;
20+
}
2121

22-
// public List<SlashCommandOptions> BuildOptions()
23-
// {
24-
// return new List<SlashCommandOptions>()
25-
// {
26-
// new()
27-
// {
28-
// Name = "param1",
29-
// Description = "Primeiro parâmetro",
30-
// Type = InteractionType.String,
31-
// Required = true,
32-
// Choices = new List<SlashCommandChoices>()
33-
// {
34-
// new ()
35-
// {
36-
// Name = "Dog",
37-
// Value = "animal_dog"
38-
// }
39-
// }
40-
// }
41-
// };
42-
// }
43-
// }
44-
//}
22+
}
23+
}

0 commit comments

Comments
 (0)