Skip to content

Commit 392d429

Browse files
committed
Custom Command system fully implemented.
1 parent 6f6c357 commit 392d429

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

SIVA/Core/Discord/EventHandler.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,19 @@ public async Task HandleMessageOrCommand(SocketMessage s)
7979

8080
var argPos = 0;
8181

82-
var msgStrip = ctx.Message.Content.Replace(prefix, string.Empty);
82+
var msgStrip = msg.Content.Replace(prefix, string.Empty);
83+
8384

84-
foreach (var command in config.CustomCommands)
85+
if (msg.HasStringPrefix(prefix, ref argPos) || msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
8586
{
86-
if (msg.HasStringPrefix(prefix + command.Key, ref argPos))
87+
if (config.CustomCommands.ContainsKey(msgStrip))
8788
{
88-
await ctx.Channel.SendMessageAsync(command.Value);
89+
await ctx.Channel.SendMessageAsync(
90+
config.CustomCommands.FirstOrDefault(c => c.Key.ToLower() == msgStrip.ToLower()).Value
91+
);
92+
8993
}
90-
}
91-
92-
if (msg.HasStringPrefix(prefix, ref argPos) || msg.HasMentionPrefix(_client.CurrentUser, ref argPos))
93-
{
94+
9495
var result = await _service.ExecuteAsync(ctx, argPos);
9596

9697
if (result.IsSuccess == false && result.ErrorReason != "Unknown command.")

0 commit comments

Comments
 (0)