discord.js

Discord.js message.react fails when adding specific unicode emotes

偶尔善良 提交于 2021-02-08 05:04:48
问题 Yesterday I started coding a bot using the guide from discord.js. The core is just with what you finish the Command Handler part with. I was working on a voting command, where the bot would react with Unicode symbols like :one: :two: :three:. This is where I encounter my problem. Using: module.exports = { name: 'testing', description: 'creates a reaction', aliases: ['test'], cooldown: 1, execute(message, args) { if (!args.length) { message.react(':one:'); } } }; Gives me a DiscordAPIError:

Get collected message before time limit in discord.js

我的梦境 提交于 2021-02-08 04:42:33
问题 Is there a way to receive messages from discord.js collectors before the time limit expires? I tried using collector.on collected, but it triggered after the time limit I set. Here is what I currently have: this.collected = false this.collector = new Discord.MessageCollector(msg.channel, m => m.author.bot === false,{time: 10000}); this.collector.on('collect', message =>{ if(!this.collected){ this.collected = true console.log(message) msg.channel.send(message.content) this.collector.stop() /

How can I make a random response in Discord.js

和自甴很熟 提交于 2021-02-05 11:56:19
问题 The title explains it I guess. I have no code written down and it would be nice if someone explains the steps to the code. I want it to send a random link for a wallpaper from a website each time the command 'a wallpaper' is used. Any helpers? 回答1: client.on('message', (message) => { if (message.content.startsWith('!wallpaper')) { // Here you can choose between creating your array with your own links or use a api that will generate it for you. For now i'll use an array const wallpapers = [

How can I make a random response in Discord.js

烈酒焚心 提交于 2021-02-05 11:56:11
问题 The title explains it I guess. I have no code written down and it would be nice if someone explains the steps to the code. I want it to send a random link for a wallpaper from a website each time the command 'a wallpaper' is used. Any helpers? 回答1: client.on('message', (message) => { if (message.content.startsWith('!wallpaper')) { // Here you can choose between creating your array with your own links or use a api that will generate it for you. For now i'll use an array const wallpapers = [

Why does client.guilds.cache.size only say “0” in my playing status even if it's in 2 servers?

强颜欢笑 提交于 2021-02-05 09:27:11
问题 i have seen many people who had trouble with client.guilds.size but I switched to the recently suggested client.guilds.cache.size . In my playing status, it only says "WATCHING my prefix | 0 servers." same happens for trying to fetch the member count and channel count. let activities = [ `${client.guilds.cache.size} servers`, `${client.channels.cache.size} channels`, `${client.users.cache.size} users` ], i = 0; setInterval(() => client.user.setActivity(`${prefix}help | ${activities[i ++ %

Why does client.guilds.cache.size only say “0” in my playing status even if it's in 2 servers?

别说谁变了你拦得住时间么 提交于 2021-02-05 09:27:09
问题 i have seen many people who had trouble with client.guilds.size but I switched to the recently suggested client.guilds.cache.size . In my playing status, it only says "WATCHING my prefix | 0 servers." same happens for trying to fetch the member count and channel count. let activities = [ `${client.guilds.cache.size} servers`, `${client.channels.cache.size} channels`, `${client.users.cache.size} users` ], i = 0; setInterval(() => client.user.setActivity(`${prefix}help | ${activities[i ++ %

Creating an invite and send it to an user that is not in your server/guild

孤人 提交于 2021-02-05 09:12:34
问题 I have a site where users register. In the registration process, I ask them to provide their discord user to let them access a discord community we own. Is it possible to create an invite for my guild/channel and send it to a discord user using discord.js? I need this invite to be unique and limited to one use. So, I need to create a new one everytime a user registers at the site. 回答1: It is possible to create a unique invite, but you cannot send it to the user inside Discord, you'll need to

Got “Unexpected end of input” in Javascript when making a Discord Bot

ⅰ亾dé卋堺 提交于 2021-02-05 09:12:28
问题 client.on("message", (message) => { message.channel.send({ embed: { color: 3447003, author: { name: client.user.username, icon_url: client.user.avatarURL }, title: "commands", description: "all current commands", fields: [{ name: "admin only", value: "ban" }, { name: "moderator only", value: "kick" }, { name: "everyone", value: "ping \n help \n invite \n sinvite \n gay \n owner " }], timestamp: new Date(), footer: { icon_url: client.user.avatarURL, text: "~Isabelle~" } } }); ^ SyntaxError;

Got “Unexpected end of input” in Javascript when making a Discord Bot

江枫思渺然 提交于 2021-02-05 09:12:05
问题 client.on("message", (message) => { message.channel.send({ embed: { color: 3447003, author: { name: client.user.username, icon_url: client.user.avatarURL }, title: "commands", description: "all current commands", fields: [{ name: "admin only", value: "ban" }, { name: "moderator only", value: "kick" }, { name: "everyone", value: "ping \n help \n invite \n sinvite \n gay \n owner " }], timestamp: new Date(), footer: { icon_url: client.user.avatarURL, text: "~Isabelle~" } } }); ^ SyntaxError;

Creating an invite and send it to an user that is not in your server/guild

寵の児 提交于 2021-02-05 09:04:51
问题 I have a site where users register. In the registration process, I ask them to provide their discord user to let them access a discord community we own. Is it possible to create an invite for my guild/channel and send it to a discord user using discord.js? I need this invite to be unique and limited to one use. So, I need to create a new one everytime a user registers at the site. 回答1: It is possible to create a unique invite, but you cannot send it to the user inside Discord, you'll need to