mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
Handle send message/embed links permission erorrs gracefully
This commit is contained in:
parent
9d4993b121
commit
a95d12639d
3 changed files with 26 additions and 8 deletions
|
|
@ -53,8 +53,17 @@ namespace PluralKit.Bot
|
|||
public bool HasNext(bool skipFlags = true) => RemainderOrNull(skipFlags) != null;
|
||||
public string FullCommand => _parameters.FullCommand;
|
||||
|
||||
public Task<IUserMessage> Reply(string text = null, Embed embed = null) =>
|
||||
Channel.SendMessageAsync(text, embed: embed);
|
||||
public Task<IUserMessage> Reply(string text = null, Embed embed = null)
|
||||
{
|
||||
if (!this.BotHasPermission(ChannelPermission.SendMessages))
|
||||
// Will be "swallowed" during the error handler anyway, this message is never shown.
|
||||
throw new PKError("PluralKit does not have permission to send messages in this channel.");
|
||||
|
||||
if (embed != null && !this.BotHasPermission(ChannelPermission.EmbedLinks))
|
||||
throw new PKError("PluralKit does not have permission to send embeds in this channel. Please ensure I have the **Embed Links** permission enabled.");
|
||||
|
||||
return Channel.SendMessageAsync(text, embed: embed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the next parameter is equal to one of the given keywords. Case-insensitive.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue