fix: fail-fast if we don't have Send Messages permissions in the current channel

This commit is contained in:
spiral 2022-03-30 05:11:55 -04:00
parent 233d0341a2
commit 36e242986d
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -63,6 +63,8 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
if (evt.Type != Message.MessageType.Default && evt.Type != Message.MessageType.Reply) return; if (evt.Type != Message.MessageType.Default && evt.Type != Message.MessageType.Reply) return;
if (IsDuplicateMessage(evt)) return; if (IsDuplicateMessage(evt)) return;
if (!(await _cache.PermissionsIn(evt.ChannelId)).HasFlag(PermissionSet.SendMessages)) return;
// spawn off saving the private channel into another thread // spawn off saving the private channel into another thread
// it is not a fatal error if this fails, and it shouldn't block message processing // it is not a fatal error if this fails, and it shouldn't block message processing
_ = _dmCache.TrySavePrivateChannel(evt); _ = _dmCache.TrySavePrivateChannel(evt);