discord.js

Cannot read property 'send' of underfined

陌路散爱 提交于 2020-11-30 00:22:12
问题 const mudaeon = require('./mudaetime.json'); const cron = require('cron'); const Discord = require('discord.js'); const client = new Discord.Client(); module.exports = { name: 'mudaetime', description: '...', execute(message, args) { if (mudaeon) { const channel = client.channels.cache.get('id'); let scheduledMessage = new cron.CronJob( '* * * * *', () => { scheduledMessage.start(); }, message.react('✅'), channel.send('check $tu ! <@&id') ); } else !mudaeon; { cancel(); } }, }; Please help

Cannot read property 'send' of underfined

强颜欢笑 提交于 2020-11-30 00:21:16
问题 const mudaeon = require('./mudaetime.json'); const cron = require('cron'); const Discord = require('discord.js'); const client = new Discord.Client(); module.exports = { name: 'mudaetime', description: '...', execute(message, args) { if (mudaeon) { const channel = client.channels.cache.get('id'); let scheduledMessage = new cron.CronJob( '* * * * *', () => { scheduledMessage.start(); }, message.react('✅'), channel.send('check $tu ! <@&id') ); } else !mudaeon; { cancel(); } }, }; Please help

Cannot read property 'send' of underfined

那年仲夏 提交于 2020-11-30 00:21:00
问题 const mudaeon = require('./mudaetime.json'); const cron = require('cron'); const Discord = require('discord.js'); const client = new Discord.Client(); module.exports = { name: 'mudaetime', description: '...', execute(message, args) { if (mudaeon) { const channel = client.channels.cache.get('id'); let scheduledMessage = new cron.CronJob( '* * * * *', () => { scheduledMessage.start(); }, message.react('✅'), channel.send('check $tu ! <@&id') ); } else !mudaeon; { cancel(); } }, }; Please help

Online User count from a Discord Role

笑着哭i 提交于 2020-11-29 21:24:35
问题 I want my Discord Bot to display the Number of Online Users of a Role as an Activity. I can't seem to figure it out and i can't find anything on the Web. Can someone give me example code or explain it to me? 回答1: You can use Guild.members.forEach() to loop through every member of the guild, then if they have that role (you can use GuildMember.roles.has(Role.id) to check that) increase a counter. When you have finished your loop through the members, use the counter in your Client.user

Online User count from a Discord Role

梦想的初衷 提交于 2020-11-29 21:10:50
问题 I want my Discord Bot to display the Number of Online Users of a Role as an Activity. I can't seem to figure it out and i can't find anything on the Web. Can someone give me example code or explain it to me? 回答1: You can use Guild.members.forEach() to loop through every member of the guild, then if they have that role (you can use GuildMember.roles.has(Role.id) to check that) increase a counter. When you have finished your loop through the members, use the counter in your Client.user

Online User count from a Discord Role

半城伤御伤魂 提交于 2020-11-29 21:10:47
问题 I want my Discord Bot to display the Number of Online Users of a Role as an Activity. I can't seem to figure it out and i can't find anything on the Web. Can someone give me example code or explain it to me? 回答1: You can use Guild.members.forEach() to loop through every member of the guild, then if they have that role (you can use GuildMember.roles.has(Role.id) to check that) increase a counter. When you have finished your loop through the members, use the counter in your Client.user

Getting number of members and servers a bot is serving

若如初见. 提交于 2020-11-29 19:21:36
问题 So I went through the discord.js guide, and found that client.guilds.size and client.users.size is for finding no of users and servers a bot is on. But when I implement it I get "undefined". Any reason why? 回答1: Try client.guilds.cache.size and client.users.cache.size . This changed in discord.js v12. client.users has been changed from a Collection to a Manager. client.guilds has been changed from a Collection to a Manager. 回答2: You can use client.guilds.cache.size which will return the

Getting number of members and servers a bot is serving

。_饼干妹妹 提交于 2020-11-29 19:06:20
问题 So I went through the discord.js guide, and found that client.guilds.size and client.users.size is for finding no of users and servers a bot is on. But when I implement it I get "undefined". Any reason why? 回答1: Try client.guilds.cache.size and client.users.cache.size . This changed in discord.js v12. client.users has been changed from a Collection to a Manager. client.guilds has been changed from a Collection to a Manager. 回答2: You can use client.guilds.cache.size which will return the

I am getting an error Typerror Cannot read property 'execute' of undefined

折月煮酒 提交于 2020-11-29 18:57:18
问题 My main code I am trying to make a discord bot i was getting this error Typerror Cannot read property of 'execute' undefined i have literally every solution but it still has some errors would be grateful if someone solved it. I am trying to make a simple discor bot but the code does not only work please hlep . const client = new Discord.Client(); const prefix = '-'; const fs = require('fs'); client.commands = new Discord.Collection(); const commandFiles = fs.readdirSync('./commands/').filter

Discord.js sending a message to a specific channel

安稳与你 提交于 2020-11-25 02:16:18
问题 I'm failing to achieve something very simple. I can't send a message to a specific channel. I've browsed trough the documentation and similar threads on stack overflow. client.channels.get().send() does NOT work. It is not a function. I also do not see it as a method on the Channel class on the official documentation yet every thread I've found so far has told me to use that. I managed to have the bot reply to a message by listening for a message and then using message.reply() but I don't