Which one of these is a method?
msg.author
msg.channel.send
msg.channel.send does something, while msg.author finds something
msg.channel.send()
It sends a message back in the channel the command was sent in
What does this event check for?
bot.on("message");
It checks for when a message is sent.
What does this method find?
msg.author
It finds the user that sent the message
let channel = msg.channel;
channel.send(msg.author + " is your username.");
Is this a method or a function?
msg.channel
It is a method:
while msg.channel.send is a function, msg.channel just finds the channel the message was sent in.
What does this function do?
msg.reply();
It sends a message in the same channel the command was sent in, mentioning the user who sent it first.
bot.on("guildMemberAdd");
It checks for when someone joins the server the bot is in.
What does this method find?
msg.guild.channels
It finds all the channels in the server!
if (!msg.author.username === "RandomUser") return;
msg.channel.send("Hello @RandomUser!");
You would use (value1 !== value2) instead of (!value1 === value2)
msg.guild.channels.find("name", "examplechannel");
Is this a method?
No:
although msg.guild and msg.guild.channels are both methods, it takes them and does something with them, making it a function.
msg.channel.setTopic();
It sets the topic of the channel that the command was sent in.
What is the parameter in this event?
bot.on("message", something => {
It is the message that was sent.
What does this method find?
msg.tts
If the message was Text To Speech
const discord = require(discord.js);
const bot = new discord.Client();
discord.js should be in quotes, because it's a string.
msg.mentions.users.first();
Is this a method?
Yes:
Every part of that statement is a method: msg.mentions finds the mentions in the message, msg.users finds the users from those mentions, and msg.first gets the first one. None of these actually do an action.
What does this function do?
msg.channel.setParent();
It changes the category of the channel that the command was sent in.
bot.on("guildMemberAdd", something => {
});
The member that joined.
What does this method find?
let server = msg.guild;
msg.server.channels;
Nothing: the code is wrong.
bot.on("message", () => {
}
There should be a parameter to the arrow function, like msg or message.
Which one of these is not a method?
msg.author.username
msg.guild.members.find()
msg.guild.channels
Although the msg.guild and msg.members are both methods, the find function does something: it finds an exact member.
How would you fill in the blanks to make a command that would give the user that sent it a role?
let role = msg.guild.roles.find("name", "testrole");
__________.addRole(____);
You would use:
msg.member.addRole(role);
What type of function is used in events?
How would you fill in the blanks so that it is a command that finds a user and creates a new channel with their username?
let user = ___.mentions._____.first();
msg.____d.createChannel(user.________);
Like this:
let user = msg.mentions.users.first();
msg.guild.createChannel(user.username);
let user = msg.mentions.users.first();
let role = msg.guild.roles.find("name", "testrole");
if (!user.roles.has(role)) return;
if (!user.roles.has(role.id)) return;