discord.js

How to get the creator of a channel on event channelCreate in discord.js

断了今生、忘了曾经 提交于 2021-01-29 19:55:40
问题 Would it be possible to find the creator of a channel when the channelCreate event triggers? I've tried looking at the documentation of channels & channelCreate and to log the channel object to my console but there doesn't seem to be a parameter that clearly states "This ID created the channel". I know it has to be somewhere since Discord uses it in the audit logs. 回答1: You can try listening to the channelCreate event and then fetch the GuildAuditLogs with Guild.fetchAuditLogs(). Then you can

Count content inside quotes as one argument

随声附和 提交于 2021-01-29 19:55:22
问题 I'm making a discord bot with node.js's discord.js module, I have a basic arguments detection system that uses the whitespace as the separator and puts the different arguments in an array, here's the important part of my code. (I'm using separate command modules using module.exports ). const args = message.content.slice(prefix.length).split(/ +/); const commandName = args.shift().toLowerCase(); const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.alias && cmd

Discord.js currency to command handler

非 Y 不嫁゛ 提交于 2021-01-29 17:39:54
问题 I am trying to move all of my currency/shop commands/ Sequelize database into the command handler from index.js (works perfectly in index.js file) but I am running into issues transferring data from the index.js file into the individual command files. Any help on how to properly integrate the index.js commands into the command handler would be greatly appreciated. I realize this is a lot to go through but it would really mean a lot to me if anyone was able to help me out index.js: Reflect

Discord.js meme command with meme subreddit returns image as 403 forbidden

吃可爱长大的小学妹 提交于 2021-01-29 16:13:47
问题 I'm making a meme command that sends a random meme from the meme subreddit and after discovering everything except the actual image in embed was working I logged the image to console and it returned a 403 error. If anyone is able to help it would be greatly appreciated. Code: const https = require('https'); const Discord = require('discord.js'); const url = 'https://www.reddit.com/r/meme/hot/.json?limit=100' module.exports = { name: 'meme', description: 'sends meme', execute(message, args) {

DiscordAPIError: Unknown role

半世苍凉 提交于 2021-01-29 15:18:21
问题 I was trying to make a command in discord.js in which the bot finds the highest role it can give to a person and gives it to the person. const myrole = message.guild.me.roles.highest.rawPosition const therole = message.guild.roles.cache.find(r => r.rawPosition = myrole-1) const person = message.guild.member(client.users.cache.get("the id")) person.roles.add(therole.id); And I get the following error: (node:18926) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Role at

discord.js presence status offline problem [duplicate]

夙愿已清 提交于 2021-01-29 15:01:08
问题 This question already has an answer here : None of my discord.js guildmember events are emitting, my user caches are basically empty, and my functions are timing out? (1 answer) Closed 3 months ago . client.on('message', message => { let onlineCount = 0; const guild = client.guilds.cache.get("538745138047090708"); guild.members.cache.find(member => { if (member.presence.status == "online"){ onlineCount += 1 } }) message.channel.send(`Online Players In Server: ${onlineCount}`)}; As you see in

Discord client object is undefined after being exported

六眼飞鱼酱① 提交于 2021-01-29 13:44:48
问题 I've recently run into a problem. For the past several weeks I have been working on some discord bots I have made and am having trouble with exporting the client object. I've been trying to export it to other files so I can hook event listeners in other files using the same object. Below's what I attempted doing. main.js const client = new Discord.Client(); //Defining the client exports.squidly = client; //Attempting to export the client test.js const client = require('../squidly').squidly;

Discord bot: Respond “Unknown command” when using an incorrectly spelled command

試著忘記壹切 提交于 2021-01-29 12:02:05
问题 I want to have my discord.js bot respond Unknown command, use c!help for available commands" when doing something like, c!hep (misspelled), or a different type of command not implemented, like, c!youtube, or just flat out random letters like c!rgoiw. Basically just a response if their message doesn't match any commands available. I don't have any specific code, I'm just using the const PREFIX = 'c!'; with let args = message.content.substring(PREFIX.length).split(" ") and setting all the

Discord.js: message.guild.channels.forEach is not a function

落花浮王杯 提交于 2021-01-29 10:58:40
问题 I'm creating a Discord Bot using Discord.js I'm creating a mute command but when I want to disable speaking permission for the Mute role for each channel, I get this error: TypeError: message.guild.channels.forEach is not a function I have V12. And I looked at some other options but I couldn't find any working options. if(!toMute) return message.reply('It looks like you didnt specify the user!'); if(toMute.hasPermission('MANAGE_MESSAGES')) return message.reply("can't mute them"); let muterole

Trying to implement Patreon-only commands/functions on my discord bot, how would I accomplish this?

試著忘記壹切 提交于 2021-01-29 10:57:09
问题 My discord bot gives the role of 'Patreon' to my patreon supporters. This role is given on my main discord bot server. So right now I'm trying to write some commands that would be only available to users who have the role 'Patreon' in the BOTS discord server, how can I accomplish this? Like is there a way I can be like - message.member.has('Patreon Role').in('My Discord Server)? 回答1: Let's go over the tasks you need to accomplish this. Get the "home guild" with your users and corresponding