public async Task RunAsync(CoreMessage message)
        {
            var(prefix, typeResult) = await GetPrefixAsync(message);

            if (typeResult == PrefixTypeResult.None)
            {
                return;
            }

            var prefixLess = message.Content.Substring(prefix !.Length).TrimStart();

            if (prefixLess == "" && typeResult == PrefixTypeResult.MentionPrefix)
            {
                await message.SendAsync(message.GuildId == null
                                        ?$"The prefix for my commands is `{DefaultPrefix}`"
                                        : $"The prefix for my commands in this server is `{await RetrieveGuildPrefixAsync((ulong) message.GuildId)}`");

                return;
            }

            var commandName = GetCommandName(prefixLess);

            if (Client.Commands.TryGetValue(commandName.ToLower(), out var command))
            {
                await RunInhibitorsAsync(message, command, prefixLess.Substring(commandName.Length));
            }
            else
            {
                await Client.EventHandler.OnCommandUnknownAsync(message, commandName);
            }
        }
Ejemplo n.º 2
0
 private async Task RunAsync(CoreMessage message, string command, InhibitorException exception)
 {
     if (exception.Silent)
     {
         await Task.FromResult(true);
     }
     else
     {
         await message.SendAsync($"Inhibitor Error: {exception.Message}");
     }
 }
Ejemplo n.º 3
0
        public async Task RunAsync(CoreMessage message, string code)
        {
            var globals = new ScriptGlobals {
                Message = message
            };

            try
            {
                var result = await _eval.EvaluateAsync(code, globals);

                if (result != null)
                {
                    await message.SendAsync(result.ToString() !);
                }
            }
            catch (CompilationErrorException e)
            {
                await message.SendAsync(String.Join("\n", e.Diagnostics.Select(x => x.ToString())));
            }
        }
Ejemplo n.º 4
0
 private async Task RunAsync(CoreMessage message, string command, object?[] parameters, Exception exception)
 {
     Client.Logger.Error("[COMMANDS]: {Name} | {Exception}", command, exception);
     await message.SendAsync("Whoops! Something happened while processing the command!");
 }
 private async Task RunAsync(CoreMessage message, string command, ArgumentException exception)
 {
     await message.SendAsync($"Argument Error: {exception.InnerException?.Message ?? exception.Message}");
 }
Ejemplo n.º 6
0
 public async Task RunAsync(CoreMessage message,
                            [Argument(Rest = true)] string content = "I got absolutely nothing!")
 {
     await message.SendAsync($"A string! {content}");
 }
Ejemplo n.º 7
0
 public async Task RunAsync(CoreMessage message, string content, int[] integers)
 {
     await message.SendAsync(
         $"With the content of {content}, you have given me {integers.Length} number(s), with a sum of {integers.Sum()}");
 }
Ejemplo n.º 8
0
 public async Task RunAsync(CoreMessage message, DateTime time,
                            string content = "Something, you did not specify what")
 {
     await message.SendAsync(
         $"Alright! Reminder added. I'll remember you \"{content}\" at {time.ToShortDateString()}");
 }
Ejemplo n.º 9
0
 public async Task RunAsync(CoreMessage message, [Argument(Minimum = -5)] int number)
 {
     await message.SendAsync($"A number! {number.ToString()}");
 }
Ejemplo n.º 10
0
 private async Task RunAsync(CoreMessage message, string command, Exception exception)
 {
     Client.Logger.Error("[ARGUMENTS]: {Name} | {Exception}", command, exception);
     await message.SendAsync("Whoops! Something while processing arguments!");
 }