Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional commands with regex #200

Open
Ahmadh26 opened this issue Feb 12, 2021 · 1 comment
Open

Conditional commands with regex #200

Ahmadh26 opened this issue Feb 12, 2021 · 1 comment

Comments

@Ahmadh26
Copy link

i'm trying to make an autoresponse with my bot and trying to use conditional commands to know whether the command is enabled or disabled. here is the code that i have for it:

const { Command } = require('discord-akairo');
const typeorm = require('typeorm');

class ReeCommand extends Command {
	constructor() {
		super('ree', {
			regex: /^ree+$/i,
			typing: true,
			cooldown: 25000,
		});
	}
	async condition(message) {
		const connection = typeorm.getConnection();
		const getStatus = await connection.query(`SELECT status FROM autores WHERE ar = "ree" AND channel = "${message.channel.id}"`);
		// if(getStatus.length < 1) {
		// 	connection.query(`INSERT INTO autores (ar, status, channel) VALUES ("ree", "1", "${message.channel.id}")`);
		// }
		return await getStatus[0]['status'] === 1;
	}
	async exec(message) {

			return message.util.send(`${message.content.toUpperCase()}E`);

	}
}

module.exports = ReeCommand;

the bot responds to the message whether the trigger is enabled or not, i use a MySQL database where i have a status set to either 0 or 1 per channel to know if it's enabled there or no.

i have tried using aliases rather than regex and it worked fine, the issue is only happening with regex :/
the bot also edits the message for some unknown reason. there is a Gif attached.

dfw8D9tLMC

what could cause this? Am i doing something wrong?
thanks for the help

@Ahmadh26
Copy link
Author

Ahmadh26 commented Mar 5, 2021

no reply yet :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant