discord.js

Discord bot send birthday message

余生长醉 提交于 2021-01-29 10:52:42
问题 I have made a Discord bot and I want it to be able to check the current date, and if current date is any of the users birthday, then it'll tag them and say happy birthday. I have tried using Node.js' Date, like if(Date === "this or that") but that didn't seem to work. So what I need help with is: Checking the current date (like run a check each day or something) send a message at that current date I'll probably just hardcode all the birthdays in since we're not that many (I know that's not

Creating a role, then giving the role to a member doesn't work, is there a better way to handle this? Discord.js

旧巷老猫 提交于 2021-01-29 10:47:38
问题 I want to create a role based off a message, then once that role is created, I want to give it to those that are mentioned in the same message. The role gets created perfectly fine, but the correct role isn't give to the user. I've tried going by the name, but that leads to the role not being found, so I'm trying to get the role based off the position that it is in, but when I need to give the role out, it doesn't seem to be in that correct position var nameOC = getClanName(message.content);

Discord.js Commando Broadcast All command error

只谈情不闲聊 提交于 2021-01-29 10:14:53
问题 I'm trying to make broadcast command send a message to all text channels in the guild. My current code looks like this: const discord = require('discord.js'); const Commando = require('discord.js-commando'); module.exports = class broadcastCommand extends Commando.Command { constructor(client) { super(client, { name: 'broadcast', aliases: ['bcast', 'bc'], group: 'ebs', memberName: 'broadcast', userPermissions: ['MANAGE_MESSAGES'], description: 'Sends an emergency broadcast to the emergency

Cannot read property 'fetchBans' of undefined

随声附和 提交于 2021-01-29 10:10:36
问题 I'm trying out a new command, which is the unban command. However, if I run the code below I keep getting Cannot read property 'fetchBans' of undefined . I'm currently using v12.16.3. if(!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!") if(isNaN(args[0])) return message.channel.send("You need to provide an ID.") let bannedMember = await client.guild.fetchBans(args[0]) if(!bannedMember) return

Discord bot youtube search, wait for answer of asynchronous function

一世执手 提交于 2021-01-29 09:31:08
问题 I have built a discord but using javascript I've got one command where I want the ability to search for a youtube video and play the first result in a voice channel. I'm using the discordjs and discord-youtube-api libraries. This code looks for the command to search. The args array is the search query else if (command === 'search') { isReady = false; if (message.channel.type !== 'text') return; const { voiceChannel } = message.member; if (!voiceChannel) { return message.reply('please join a

Discord.js - UnhandledPromiseRejectionWarning: RangeError [MESSAGE_NONCE_TYPE]: Message nonce must fit in an unsigned 64-bit integer

泄露秘密 提交于 2021-01-29 09:29:31
问题 I'm currently working on a Discord bot (using discord.js) and I'm getting the following error, but only randomly: UnhandledPromiseRejectionWarning: RangeError [MESSAGE_NONCE_TYPE]: Message nonce must fit in an unsigned 64-bit integer . It appears the error is coming from Discord's API, but I'm not sure why exactly - again, it occurs randomly it seems, so hard to narrow down the cause. Any advice? This is the rest of the error: at APIMessage.resolveData (node_modules\discord.js\src\structures

TypeError: Cannot read property 'add' of undefined discord.js

偶尔善良 提交于 2021-01-29 08:31:09
问题 So i have a discord bot, and i have been forking some code and basically experminting. my synax is right however it says TypeError: Cannot read property 'add' of undefined when i try to make my discord.js bot add a role. client.guilds.get(config.guild).member(message.author).role.add(config.role) // ensure this is a string in the config ("") .then(console.log(`TOKEN: ${message.author.token} :: Role ${config.role} added to member ${message.author.id}`)) .catch(console.error) }) Could someone

MySQL turns itself off after discord bot left on for about 12 hours

一世执手 提交于 2021-01-29 07:26:08
问题 I'm hosting a discord.js bot on an ubuntu VPS, and the bot uses MySQL as its database. I turn on the bot, and leave it, and it works fine, but after about 12 hours (it tends to vary), the bot goes offline, because of an error, saying MySQL server disconnected. But, if I restart the bot, MySQL turns back on, and bits of the bot that require the database use the database perfectly fine. I'm not sure if this is an error with MySQL, Node.JS or Ubuntu, but I don't know how to fix it. Thanks! 回答1:

!createcategory | doesn't create category | What to do? Discord.js

家住魔仙堡 提交于 2021-01-29 07:20:14
问题 client.on('ready', () => { command(client, 'createcategory', (message) => { const name = message.content.replace('!createcategory ', '') if(message.guild.channels.cache.find(c => c.name == message.author.username && c.type == "category") === undefined){ message.guild.channels.create(message.author.username, {type: 'category', permissionOverwrites: [ { id: message.guild.id, deny: ['VIEW_CHANNEL'], }, { id: message.author.id, allow: ['VIEW_CHANNEL'], }, ]}) message.guild.channels.create('Text

How to remove a role from every member of the guild

心已入冬 提交于 2021-01-29 06:36:38
问题 How can I remove a role from every user inside a server, I tried using let everyone = message.guild.members.get and let everyone = message.guild.members but they both didn't work. Here's the whole code: const Discord = require("discord.js"); const errors = require("../utils/errors.js"); module.exports.run = async(bot, message, args) => { if (!message.member.hasPermission("MANAGE_ROLES")) return errors.noPerms(message, "MANAGE_ROLES"); let role = message.guild.roles.find(`name`, `NSFW`); let