Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js role giveving

bot.on('message', (message) => {
    if (!message.content.startsWith(PREFIX) || message.author.bot) return;

    const args = message.content
        .toLowerCase()
        .slice(PREFIX.length)
        .trim()
        .split(/s+/);
    const [command, input] = args;

    if (command === 'clear' || command === 'c') {
        if (!message.member.hasPermission('MANAGE_MESSAGES')) {
            return message.channel
                .send(
                    "Sorry, ale nemáš na to dostatečná práva (`MANAGE_MESSAGES`) :shield: ",
                );
        }

        if (isNaN(input)) {
            return message.channel
                .send('Napiš kolik zpráv mám smazat :eyes: ')
                .then((sent) => {
                    setTimeout(() => {
                        sent.delete();
                    }, 2500);
                });
        }

        if (Number(input) < 0) {
            return message.channel
                .send('Brácho .... rozumím, nemažu nic :clown: ')
                .then((sent) => {
                    setTimeout(() => {
                        sent.delete();
                    }, 2500);
                });
        }

        // add an extra to delete the current message too
        const amount = Number(input) > 100 ?
            101 :
            Number(input) + 1;

        message.channel.bulkDelete(amount, true)
            .then((_message) => {
                message.channel
                    // do you want to include the current message here?
                    // if not it should be ${_message.size - 1}
                    .send(`Smazal jsem `${_message.size}` zpráv :broom:`)
                    .then((sent) => {
                        setTimeout(() => {
                            sent.delete();
                        }, 2500);
                    });
            });
    }

    if (command === 'help' && input === 'clear') {
        const embed = new Discord.MessageEmbed()
            .setColor('#00B2B2')
            .setTitle('**Clear Help**')
            .setDescription(
                `Tento příkaz maže správy. Například takto: `${PREFIX}clear 5` nebo `${PREFIX}c 5`.`,
            )
            .setFooter(
                `Vyžádáno uživatelem: ${message.author.tag}`,
                message.author.displayAvatarURL(),
            )
            .setTimestamp();

        message.channel.send(embed);
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord.js add role command 
Javascript :: check if string contains a value in array 
Javascript :: python to java script 
Javascript :: self invoking function in javascript 
Javascript :: javascript find ip and information 
Javascript :: set className with ref react 
Javascript :: how to declare objects inside arrays in javascript 
Javascript :: update TextInput value react-hook-form react-admin 
Javascript :: i get two times event click of button javascript 
Javascript :: buttons js before submit 
Javascript :: Argument #1 ($client) must be of type AwsS3Client 
Javascript :: change one element in array javascript 
Javascript :: how to select text from event.target.value 
Javascript :: react js how to do array range 
Javascript :: findOne 
Javascript :: change the focus to next in angular forms 
Javascript :: javascript closest child 
Javascript :: call function add parameter javascript 
Javascript :: eaf doom emacs 
Javascript :: convert arrow function to normal function javascript online 
Python :: pandemonium 
Python :: python update pip3 
Python :: python wait 1 sec 
Python :: dataframe to csv without ids 
Python :: convert date string to date time string python 
Python :: how to make pyautogui faster 
Python :: sleep 5 seconds py 
Python :: get stats from array python 
Python :: how to feature selection in python 
Python :: local image embed discord py 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =