Merge branch 'main' into rust-command-parser

This commit is contained in:
libglfw 2024-11-02 15:16:29 -07:00
commit 77276c15e6
119 changed files with 4837 additions and 1017 deletions

View file

@ -72,7 +72,7 @@ public class Context
public readonly int ShardId;
public readonly Cluster Cluster;
public Task<PermissionSet> BotPermissions => Cache.BotPermissionsIn(Channel.Id);
public Task<PermissionSet> BotPermissions => Cache.BotPermissionsIn(Guild?.Id ?? 0, Channel.Id);
public Task<PermissionSet> UserPermissions => Cache.PermissionsForMCE((MessageCreateEvent)Message);
@ -110,7 +110,7 @@ public class Context
// {
// Sensitive information that might want to be deleted by :x: reaction is typically in an embed format (member cards, for example)
// but since we can, we just store all sent messages for possible deletion
await _commandMessageService.RegisterMessage(msg.Id, msg.ChannelId, Author.Id);
await _commandMessageService.RegisterMessage(msg.Id, Guild?.Id ?? 0, msg.ChannelId, Author.Id);
// }
return msg;

View file

@ -91,8 +91,12 @@ public static class ContextArgumentsExt
public static bool MatchClear(this Context ctx)
=> ctx.Match("clear", "reset", "default") || ctx.MatchFlag("c", "clear");
public static bool MatchRaw(this Context ctx) =>
ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw");
public static ReplyFormat MatchFormat(this Context ctx)
{
if (ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw")) return ReplyFormat.Raw;
if (ctx.Match("pt", "plaintext") || ctx.MatchFlag("pt", "plaintext")) return ReplyFormat.Plaintext;
return ReplyFormat.Standard;
}
public static bool MatchToggle(this Context ctx, bool? defaultValue = null)
{
@ -184,4 +188,11 @@ public static class ContextArgumentsExt
return groups;
}
}
public enum ReplyFormat
{
Standard,
Raw,
Plaintext
}

View file

@ -188,7 +188,8 @@ public static class ContextEntityArgumentsExt
if (!MentionUtils.TryParseChannel(ctx.PeekArgument(), out var id))
return null;
var channel = await ctx.Cache.TryGetChannel(id);
// todo: match channels in other guilds
var channel = await ctx.Cache.TryGetChannel(ctx.Guild!.Id, id);
if (channel == null)
channel = await ctx.Rest.GetChannelOrNull(id);
if (channel == null)