Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

discord js give role to all member

// find the role with the name "Community"
let role = message.guild.roles.find(r => r.name == 'Community')

// if role doesn't exist, notify the author of command that the role couldn't be found
if (!role) return message.channel.send(`**${message.author.username}**, role not found`)

// find all guild members that aren't bots, and add the "Community" role to each
message.guild.members.filter(m => !m.user.bot).forEach(member => member.addRole(role))

// notify the author of the command that the role was successfully added to all members
message.channel.send(`**${message.author.username}**, role **${role.name}** was added to all members`)
Comment

add role to channel discord.js

// deleting the channels overwrite for the message author
channel.permissionOverwrites.get(message.author.id).delete();
Comment

add role to channel discord.js

channel.updateOverwrite(channel.guild.roles.everyone, { VIEW_CHANNEL: false });
Comment

discord.js give role command

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 :: DeleteAsync 
Javascript :: modulos nodejs 
Javascript :: window.getselection outside 
Javascript :: Chaining methods in jShell 
Javascript :: declarative language example 
Javascript :: outline none react native web 
Javascript :: skipping test suites chai 
Javascript :: ES6 template literals sum example 
Javascript :: how to make password star star on input html 
Javascript :: maximum element in an array javascript 
Javascript :: bootstrap off canvas not working 
Javascript :: amazing js hacls prank 
Javascript :: js % 
Javascript :: ionic vue electron 
Javascript :: express access static files in post request 
Javascript :: runjs 
Javascript :: pragmatic view on the meaning of life 
Javascript :: how is coa useful npm 
Javascript :: jquery keyup only alphanumeric 
Javascript :: wrap three three set div in a single div 
Javascript :: what is the difference between throttling and debounce and raf throttling in react 
Javascript :: convert javascript function to typescript online 
Javascript :: google sheets simulate edit event 
Javascript :: jquery toucheswipe 
Javascript :: Remove a class when the backspace-key is pressed inside the input field 
Javascript :: Half or Left Triangle Pattern in JavaScript 
Javascript :: js get key value from url 
Javascript :: javascript uuid generator 
Javascript :: how to create a snake game in html css js 
Javascript :: FTP Get a directory listing of the current 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =