mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 13:43:06 -04:00
fix command delete logic for non-commands
This commit is contained in:
parent
d2dcde8ee2
commit
086ef3d2f9
1 changed files with 12 additions and 3 deletions
|
@ -85,7 +85,7 @@ const interactionClient = new InteractionCommandClient(cluster, {
|
||||||
useClusterClient: true
|
useClusterClient: true
|
||||||
})
|
})
|
||||||
|
|
||||||
const { maintower, basecamp, ingest, formatErrorMessage } = require('#logging');
|
const { maintower, basecamp, formatErrorMessage } = require('#logging');
|
||||||
|
|
||||||
const { createEmbed } = require('#utils/embed');
|
const { createEmbed } = require('#utils/embed');
|
||||||
const { icon, highlight } = require('#utils/markdown');
|
const { icon, highlight } = require('#utils/markdown');
|
||||||
|
@ -119,8 +119,17 @@ commandClient.on('commandDelete', async ({context, reply}) => {
|
||||||
if(context.message?.deleted) return reply.delete();
|
if(context.message?.deleted) return reply.delete();
|
||||||
|
|
||||||
let hasPrefix = false;
|
let hasPrefix = false;
|
||||||
for(const p of commandPrefixes) if(context.message.content.toLowerCase().startsWith(p)) hasPrefix = true;
|
for(const p of [...commandPrefixes, context.client.user.mention]) if(context.message.content.toLowerCase().startsWith(p)) hasPrefix = true;
|
||||||
if(context.message.content.startsWith(context.client.user.mention)) hasPrefix = true;
|
|
||||||
|
// TODO: there has to be a better way to do this, see if the command
|
||||||
|
// client exposes a parser or whatever
|
||||||
|
if(hasPrefix){
|
||||||
|
// Extract command
|
||||||
|
let command = context.message.content.toLowerCase()
|
||||||
|
for(const p of [...commandPrefixes, context.client.user.mention]) if(command.startsWith(p)) command = command.replace(p, "");
|
||||||
|
while(command.startsWith(" ") && command.length) command = command.substring(1,command.length)
|
||||||
|
if(!context.client.commandClient.commands.map((c)=>[c.name, ...c.aliases]).flat().includes(command.split(" ")[0])) hasPrefix=false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!reply.deleted && !hasPrefix) reply.delete();
|
if(!reply.deleted && !hasPrefix) reply.delete();
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue