feat: block running commands / proxying when system is being deleted
Large systems take way too long to delete, which causes any insert for that system to block a connection, which exhausts the connection pool
This commit is contained in:
@@ -120,6 +120,17 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
|
||||
if (!HasCommandPrefix(content, ourUserId, out var cmdStart) || cmdStart == content.Length)
|
||||
return false;
|
||||
|
||||
if (ctx.IsDeleting)
|
||||
{
|
||||
await _rest.CreateMessage(evt.ChannelId, new()
|
||||
{
|
||||
Content = $"{Emojis.Error} Your system is currently being deleted."
|
||||
+ " Due to database issues, it is not possible to use commands while a system is being deleted. Please wait a few minutes and try again.",
|
||||
MessageReference = new(guild?.Id, channel.Id, evt.Id)
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// Trim leading whitespace from command without actually modifying the string
|
||||
// This just moves the argPos pointer by however much whitespace is at the start of the post-argPos string
|
||||
var trimStartLengthDiff =
|
||||
@@ -164,6 +175,8 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
|
||||
private async ValueTask<bool> TryHandleProxy(MessageCreateEvent evt, Guild guild, Channel channel,
|
||||
MessageContext ctx)
|
||||
{
|
||||
if (ctx.IsDeleting) return false;
|
||||
|
||||
var botPermissions = await _cache.PermissionsIn(channel.Id);
|
||||
|
||||
try
|
||||
|
Reference in New Issue
Block a user