mercredi 16 juin 2021

Trying to execute a random command without having to restart bot

I was trying to follow this link: Random Message Reply Discord.js 2020

But am stuck when trying to get it implemented. Basically, using the discord.js library I have one channel that I want to allow one word and one word only. When someone posts anything in said channel that is NOT that word, I want the bot to delete it and send a randomly picked reply from an array. I have gotten it to randomly select an indexed item, but it does not truly stay random. The only time the reply changes, is if the bot is restarted. I want it to execute after every time the event takes place, but every time I try, I get ReferenceError: execute is not defined.

Today is my first day ever working with Javascript, so any way of simplifying this would be GREATLY appreciated. I have repeatedly tested it, and it works great until I tried working with the execute function. I am using Visual Code Studio for the coding, and node.js for running the file.

I have not imported any other files besides discord.js, dotenv, and nodemon. I don't know what execute is supposed to do. I was just blindly following the link.

Here is my code:

const client = new Client();

const bredfreply = [
    'Excuse me person. I see you are participating in the "bredf" channel in the INCREDIBLE Realm of Eden. Unfortunately, this channel is only limited to bredf. I cannot believe you would speak any other word. You should be ashamed!',
    'Did you do what I think you just did? EXCUSE ME, but bredf is only for bredf. You MUST say bredf because it is bredf and everyone knows bredf is only bredf and not whatever you thought it was. bredf. Only bredf.',
    'You person, are in trouble. For the fact that you are rebelling against the bredf, you have lost one cookie. I do not care if you already did not have cookie because now you have less than no cookies. You actually OWE cookies so pay up.',
    'Whatever you just did? That was not bredf.',
    'bredf bredf bredf bredf bredf bredf bredf bredf bredf bredf bredf bredf',
    'PLEASE only post bredf in the channel. You are scaring the other bredfs.',
    'Did you hear about bredf? It is this really cool thing that all the cool kids post in bredf. Oh, you must not be bredf because I do not see you in there. You should be bredf.',
    '*sniffles* I want bredf. Can you help me? Put it in the channel then because I do not think you can.',
    'I only like people that say bredf. Since you apparently are not, that must mean I do not like you. Hmph'
];

    client.on('ready', () => {
console.log(`${client.user.username} is ready to start the day!`);
});

client.on('message', (message) => {
if(message.channel.id == '840422367829164052' && message.content != 'bredf'
    && message.author.id != '854877244157853716')
        execute(message,)
            const randombredfreply = bredfreply[Math.floor(Math.random(1)) * bredfreply.length];
            message.author.send(randombredfreply);
            message.delete()
        }
)```



Aucun commentaire:

Enregistrer un commentaire