@@ -15,18 +15,15 @@ public class CommandHandler
15
15
private readonly IServiceProvider _serviceProvider ;
16
16
private InteractionService _interactionService { get ; set ; }
17
17
18
- private char Prefix ;
19
-
20
18
// Retrieve client and CommandService instance via vector
21
- public CommandHandler ( DiscordSocketClient client , CommandService commands , IServiceProvider serviceProvider , char prefix )
19
+ public CommandHandler ( DiscordSocketClient client , CommandService commands , IServiceProvider serviceProvider )
22
20
{
23
21
InteractionServiceConfig _interationServiceConfig = new InteractionServiceConfig ( ) ;
24
22
_interationServiceConfig . EnableAutocompleteHandlers = true ;
25
23
_interactionService = new ( _client , config : _interationServiceConfig ) ;
26
24
_commands = commands ;
27
25
_client = client ;
28
26
_serviceProvider = serviceProvider ;
29
- Prefix = prefix ;
30
27
}
31
28
32
29
/// <summary>
@@ -36,7 +33,6 @@ public CommandHandler(DiscordSocketClient client, CommandService commands, IServ
36
33
public async Task InstallCommandsAsync ( )
37
34
{
38
35
// Hook the MessageReceived event into our command handler
39
- _client . MessageReceived += HandleCommandAsync ;
40
36
_client . AutocompleteExecuted += AutocompleteExecuted ;
41
37
_client . SlashCommandExecuted += SlashCommandHandler ;
42
38
_client . InteractionCreated += InteractionCreated ;
@@ -69,38 +65,6 @@ private async Task InteractionCreated(SocketInteraction interaction)
69
65
}
70
66
}
71
67
72
-
73
- /// <summary>
74
- /// Handle the command execution
75
- /// </summary>
76
- /// <param name="messageParam"></param>
77
- /// <returns></returns>
78
- private async Task HandleCommandAsync ( SocketMessage messageParam )
79
- {
80
- // Don't process the command if it was a system message
81
- var message = messageParam as SocketUserMessage ;
82
- if ( message == null ) return ;
83
-
84
- // Create a number to track where the prefix ends and the command begins
85
- int argPos = 0 ;
86
-
87
- // Determine if the message is a command based on the prefix and make sure no bots trigger commands
88
- if ( ! ( message . HasCharPrefix ( Prefix , ref argPos ) ||
89
- message . HasMentionPrefix ( _client . CurrentUser , ref argPos ) ) ||
90
- message . Author . IsBot )
91
- return ;
92
-
93
- // Create a WebSocket-based command context based on the message
94
- var context = new SocketCommandContext ( _client , message ) ;
95
-
96
- // Execute the command with the command context we just
97
- // created, along with the service provider for precondition checks.
98
- await _commands . ExecuteAsync (
99
- context : context ,
100
- argPos : argPos ,
101
- services : _serviceProvider ) ;
102
- }
103
-
104
68
/// <summary>
105
69
/// Slash command handler
106
70
/// </summary>
0 commit comments