mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
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:
parent
375e650c9e
commit
be89f907a0
7 changed files with 31 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue