discord.js

Discord.js | Cannot read property 'setParent' of undefined | category create

£可爱£侵袭症+ 提交于 2020-12-15 01:41:51
问题 client.on('message', async (message, user) => { if(message.content == "!createcategory"){ //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']}, ] }).then(parent => { //

download file to local computer sent attatched to message discord

六月ゝ 毕业季﹏ 提交于 2020-12-13 07:23:45
问题 after looking on the Discord.js docs i can find an answer for the question, does someone know how to do it? theres already a question the page but has no answers or comments. imagine that someone on the chat sentí an image, is there a way of the bot downloading the image or get the url of the image? thanks! 回答1: For starters... You'd need the code to access the attachment. client.on(`message`,function(msg){ if(msg.attachments.first()){//checks if an attachment is sent if(msg.attachments.first

Capture strings in quotes as single command argument

亡梦爱人 提交于 2020-12-12 12:06:12
问题 I'm attempting to make a Discord bot that does some interactions with a server. I've written some code that sort of works, but there is a big problem with it. Here is my code: if (command === "file") { var accusor = message.author.id; var username = args[0]; var reason = args[1]; var punishment = args[2]; var duration = args[3]; if(!duration) duration = "N/A"; console.log("Returning last " + amount + " for " + username); request.post({url:'http://grumpycrouton.com/kismet/api/post_complaint

Capture strings in quotes as single command argument

梦想与她 提交于 2020-12-12 12:03:28
问题 I'm attempting to make a Discord bot that does some interactions with a server. I've written some code that sort of works, but there is a big problem with it. Here is my code: if (command === "file") { var accusor = message.author.id; var username = args[0]; var reason = args[1]; var punishment = args[2]; var duration = args[3]; if(!duration) duration = "N/A"; console.log("Returning last " + amount + " for " + username); request.post({url:'http://grumpycrouton.com/kismet/api/post_complaint

Discord Bot can't find channel by name or id

风格不统一 提交于 2020-12-10 02:54:28
问题 I'm trying to make a discord bot with node.js I want to post message only in specific channel I tried to do that to save a channel in a variable but that doesn't work : const Discord = require('discord.js'); const fs = require("fs"); var bot = new Discord.Client(); var myToken = 'NDQ2OTQ1...................................................'; //client.msg = require ("./char.json"); var prefix = ("/"); //let preset = JSON.parse(fs.readFileSync('preset.json', 'utf8')); // This calls the JSON file

Discord Bot can't find channel by name or id

混江龙づ霸主 提交于 2020-12-10 02:54:04
问题 I'm trying to make a discord bot with node.js I want to post message only in specific channel I tried to do that to save a channel in a variable but that doesn't work : const Discord = require('discord.js'); const fs = require("fs"); var bot = new Discord.Client(); var myToken = 'NDQ2OTQ1...................................................'; //client.msg = require ("./char.json"); var prefix = ("/"); //let preset = JSON.parse(fs.readFileSync('preset.json', 'utf8')); // This calls the JSON file

addRole is not a function

断了今生、忘了曾经 提交于 2020-12-06 04:36:00
问题 I am creating a Discord Bot. I am trying create a Mute command, but I always get the same error. What went wrong? Background information: Discord.js version: 12.0.0-dev Klasa with version 0.5.0-dev is used Code: const { Command } = require('klasa'); const { MessageEmbed } = require('discord.js'); module.exports = class extends Command { constructor(...args) { super(...args, { description: 'Mute an user.' }) } async run(msg, args) { if(!msg.member.hasPermission("MANAGE_MEMBERS")) return msg

addRole is not a function

跟風遠走 提交于 2020-12-06 04:35:52
问题 I am creating a Discord Bot. I am trying create a Mute command, but I always get the same error. What went wrong? Background information: Discord.js version: 12.0.0-dev Klasa with version 0.5.0-dev is used Code: const { Command } = require('klasa'); const { MessageEmbed } = require('discord.js'); module.exports = class extends Command { constructor(...args) { super(...args, { description: 'Mute an user.' }) } async run(msg, args) { if(!msg.member.hasPermission("MANAGE_MEMBERS")) return msg

Cannot read property 'send' of underfined

天涯浪子 提交于 2020-11-30 00:23:01
问题 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:22:20
问题 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