Reputation: 1
i saw another post asking the same question and it was answered and the guys said it worked, but i literally copied pasted what the guy wrote and it doesnt work, the code is this:
client.on("message", async message => {
const filter = msg => msg.author.id == message.author.id;
const options = {
maxMatches: 1
};
if (message.content === ";color") {
// request
message.channel.send("What's your fav color?");
// collector
let collector = await message.channel.awaitMessages(filter, options);
let answer = collector.first().content;
// response
await message.reply("your fav color is " + answer + "!");
}
});
Anyone knows what's wrong with it or if i need to install anything?
Upvotes: 0
Views: 51
Reputation: 29
It looks like you need to define client, and login. Make also sure to install discord.js.
const Discord = require("discord.js");
const client = new Discord.Client()
client.on("message", async message => {
const filter = msg => msg.author.id == message.author.id;
const options = {
maxMatches: 1
};
if (message.content === ";color") {
// request
message.channel.send("What's your fav color?");
// collector
let collector = await message.channel.awaitMessages(filter, options);
let answer = collector.first().content;
// response
await message.reply("your fav color is " + answer + "!");
}
});
client.login("<your token>");
This would probably work, but I recommend looking up some more in-depth tutorials on setting up your first discord bot. This tutorial for example: https://learn.g2.com/how-to-make-discord-bot.
Upvotes: 2