Don't attempt to send log messages if the bot doesn't have permissions

This commit is contained in:
Ske
2020-02-22 01:54:10 +01:00
parent 493f7b12e5
commit 8d3be79d33
4 changed files with 15 additions and 11 deletions

View File

@@ -33,9 +33,14 @@ namespace PluralKit.Bot {
// Bail if we can't find the channel
if (!(await _client.GetChannelAsync(guildCfg.Value.LogChannel.Value) is ITextChannel logChannel)) return;
// Bail if we don't have permission to send stuff here
if (!logChannel.HasPermission(ChannelPermission.SendMessages) || !logChannel.HasPermission(ChannelPermission.EmbedLinks))
return;
var embed = _embed.CreateLoggedMessageEmbed(system, member, messageId, originalMsgId, sender, content, originalChannel);
var url = $"https://discordapp.com/channels/{originalChannel.GuildId}/{originalChannel.Id}/{messageId}";
await logChannel.SendMessageAsync(text: url, embed: embed);
}
}