mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-09 15:27:54 +00:00
feat: implement proper ("static") parameters handling command parser -> bot
feat: handle few more commands bot side fix(commands): handle missing parameters and return error refactor(commands): use ordermap instead of relying on a sort function to sort tokens
This commit is contained in:
parent
1a781014bd
commit
eec9f64026
16 changed files with 358 additions and 502 deletions
|
|
@ -137,8 +137,22 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
|
|||
var system = await _repo.GetSystemByAccount(evt.Author.Id);
|
||||
var config = system != null ? await _repo.GetSystemConfig(system.Id) : null;
|
||||
var guildConfig = guild != null ? await _repo.GetGuild(guild.Id) : null;
|
||||
|
||||
await _tree.ExecuteCommand(new Context(_services, shardId, guild, channel, evt, cmdStart, system, config, guildConfig, _config.Prefixes ?? BotConfig.DefaultPrefixes));
|
||||
var ctx = new Context(_services, shardId, guild, channel, evt, cmdStart, system, config, guildConfig, _config.Prefixes ?? BotConfig.DefaultPrefixes);
|
||||
try
|
||||
{
|
||||
var parameters = new Parameters(evt.Content?.Substring(cmdStart));
|
||||
var resolved_parameters = await parameters.ResolveParameters(ctx);
|
||||
await _tree.ExecuteCommand(ctx, resolved_parameters);
|
||||
}
|
||||
catch (PKError e)
|
||||
{
|
||||
// don't send an "invalid command" response if the guild has those turned off
|
||||
if (!(ctx.GuildConfig != null && ctx.GuildConfig!.InvalidCommandResponseEnabled != true))
|
||||
{
|
||||
await ctx.Reply($"{Emojis.Error} {e.Message}");
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (PKError)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue