forked from TeamInklings/Octobot
Fix calling commands with @mentions
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
a2e0707ade
commit
cac0bdc801
1 changed files with 3 additions and 3 deletions
|
@ -8,6 +8,7 @@ using Discord.WebSocket;
|
||||||
namespace Boyfriend;
|
namespace Boyfriend;
|
||||||
|
|
||||||
public sealed class CommandProcessor {
|
public sealed class CommandProcessor {
|
||||||
|
private static readonly string Mention = $"<@{Boyfriend.Client.CurrentUser.Id}>";
|
||||||
private static readonly TimeSpan Infinity = TimeSpan.FromMilliseconds(-1);
|
private static readonly TimeSpan Infinity = TimeSpan.FromMilliseconds(-1);
|
||||||
|
|
||||||
public static readonly ICommand[] Commands = {
|
public static readonly ICommand[] Commands = {
|
||||||
|
@ -57,10 +58,9 @@ public sealed class CommandProcessor {
|
||||||
|
|
||||||
private async Task RunCommandOnLine(string line, string cleanLine, string prefix) {
|
private async Task RunCommandOnLine(string line, string cleanLine, string prefix) {
|
||||||
var prefixed = line.StartsWith(prefix);
|
var prefixed = line.StartsWith(prefix);
|
||||||
var mention = Boyfriend.Client.CurrentUser.Mention;
|
if (!prefixed && !line.StartsWith(Mention)) return;
|
||||||
if (!prefixed && !line.StartsWith(mention)) return;
|
|
||||||
foreach (var command in Commands) {
|
foreach (var command in Commands) {
|
||||||
var lineNoMention = line.Remove(0, prefixed ? prefix.Length : mention.Length);
|
var lineNoMention = line.Remove(0, prefixed ? prefix.Length : Mention.Length);
|
||||||
if (!command.Aliases.Contains(lineNoMention.Trim().Split()[0])) continue;
|
if (!command.Aliases.Contains(lineNoMention.Trim().Split()[0])) continue;
|
||||||
|
|
||||||
var args = lineNoMention.Trim().Split().Skip(1).ToArray();
|
var args = lineNoMention.Trim().Split().Skip(1).ToArray();
|
||||||
|
|
Reference in a new issue