Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js role giver

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 give role command 
Javascript :: break loop after time javascript 
Javascript :: to htmlhow can i add the list in javascript 
Javascript :: how to identify debug and release build in react native 
Javascript :: if page is loading then show loader in js 
Javascript :: how to sort one element in property javascript 
Javascript :: add array type to sequelize migration 
Javascript :: onClick={ (window.open react js 
Javascript :: eliminar duplicados javascript 
Javascript :: jquery padding top 
Javascript :: ajax stand for 
Javascript :: class keyword es6 
Javascript :: javascript javascript javascript javascript javascript 
Javascript :: never give up 
Javascript :: p5js right mouse button released 
Javascript :: apoolo uselaxyQuery bypass cache 
Javascript :: convert number to indian rupee format in javascript 
Javascript :: how to create a search engine with javascript 
Javascript :: tablica w javascript 
Javascript :: sum in javascript 
Python :: python request remove warning 
Python :: pip3 upgrade 
Python :: matplotlib dark mode 
Python :: to_csv without index 
Python :: string to datetime convert 
Python :: python list files in current directory 
Python :: How to have add break for a few seconds in python 
Python :: get stats from array 
Python :: python text tkinter not typable 
Python :: scrapy get current url 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =