discord.js

Set channel id for DiscordBot for multiple servers

丶灬走出姿态 提交于 2021-02-20 04:56:51
问题 Could someone help me set command to set channel for specific server so that it does not interfere with each other? Actually I have this: var testChannel = bot.channels.find(channel => channel.id === "hereMyChannelID"); I want to set command which Owner can use to set channel id for his server. 回答1: You can accomplish this task by creating a JSON file to hold the specified channels of each guild. Then, in your command, simply define the channel in the JSON. After that, anywhere else in your

Set channel id for DiscordBot for multiple servers

心已入冬 提交于 2021-02-20 04:54:45
问题 Could someone help me set command to set channel for specific server so that it does not interfere with each other? Actually I have this: var testChannel = bot.channels.find(channel => channel.id === "hereMyChannelID"); I want to set command which Owner can use to set channel id for his server. 回答1: You can accomplish this task by creating a JSON file to hold the specified channels of each guild. Then, in your command, simply define the channel in the JSON. After that, anywhere else in your

How to remove all roles and add one role on discord bot, and then remove the added role and restore previous roles

丶灬走出姿态 提交于 2021-02-20 02:57:47
问题 I have a line of code for a discord bot to remove a specific named role and add a role named "muted" for a specific amount of time. Basically, the server can only have 3 roles, one that can issue the command, a "normal" rank with normal permissions, and then a "muted" role. and my code specifically removed the normal role and adds the muted role so they don't have any permissions. Well I added my bot onto another server with more than 3 roles, I decided to give everyone the normal role and

Guilds Highest Role Command?

南笙酒味 提交于 2021-02-19 23:47:22
问题 I want to get the highest role in the guild with discord.js message.guild.roles.highestRole This doesn't work. Any help would be appreciated. Thanks from now :) 回答1: For discord.js v12 / master use message.guild.roles.highest.name For discord.js v11.4.x / stable use message.guild.roles.sort((b, a) => a.position - b.position || a.id - b.id).first().name, this will sort the roles Collection by their position and then get the highest one, and return the name of it. 来源: https://stackoverflow.com

Guilds Highest Role Command?

点点圈 提交于 2021-02-19 23:41:06
问题 I want to get the highest role in the guild with discord.js message.guild.roles.highestRole This doesn't work. Any help would be appreciated. Thanks from now :) 回答1: For discord.js v12 / master use message.guild.roles.highest.name For discord.js v11.4.x / stable use message.guild.roles.sort((b, a) => a.position - b.position || a.id - b.id).first().name, this will sort the roles Collection by their position and then get the highest one, and return the name of it. 来源: https://stackoverflow.com

Guilds Highest Role Command?

丶灬走出姿态 提交于 2021-02-19 23:40:33
问题 I want to get the highest role in the guild with discord.js message.guild.roles.highestRole This doesn't work. Any help would be appreciated. Thanks from now :) 回答1: For discord.js v12 / master use message.guild.roles.highest.name For discord.js v11.4.x / stable use message.guild.roles.sort((b, a) => a.position - b.position || a.id - b.id).first().name, this will sort the roles Collection by their position and then get the highest one, and return the name of it. 来源: https://stackoverflow.com

Save JSON file to grab other data from it later

若如初见. 提交于 2021-02-19 06:04:27
问题 I want to be able to save my json file with new data and then call upon that data so that I can save new data again. Right now all it is doing is it is, when I call upon any part of the JSON file's data, staying the same the last time I manually saved it. (I did edit some code and a better description of my problem) Thank you in advance! Here is my code there is no error log: const Discord = require('discord.js'); const botconfig = require("./botconfig.json"); const fs = require("fs"); const

“await is only valid in async function” discord.js

為{幸葍}努か 提交于 2021-02-17 05:28:13
问题 I'm writing this code and I'm getting a "await is only valid in async function" on the line with an arrow below. I've done a bit of searching around but I'm not entirely sure what's wrong. if (message.attachments.first()) { console.log("cool file.") if (verifyFile(message.attachments.first())) { console.log("epic file!!") ---> await request.get(message.attachments.first().url).then(async (data) => { fs.writeFileSync(`${directory}/${message.author.id}_unobfuscated.lua`, data) var options = {

role overwrites when creating a role discord.js

痞子三分冷 提交于 2021-02-17 05:10:14
问题 When my bot joins a new guild it creates a role & sets overwrites. client.on("guildCreate", async guild => { guild.roles.create({ data: { name: "Billy 🤩", //sets the role name color: "#e5f7b2", //sets the color of the role permissions: 8 //sets the roles permissions to administrator } }).then(role => guild.member(client.user).roles.add(role)).catch(console.error); }); I have 2 questions: Is it possible to move this role to the top of the list or at least somewhere close? How would I go on

Discord.js, cannot read property “user” of null

拥有回忆 提交于 2021-02-17 04:50:11
问题 I have a trouble, that I can't understand at all. The function working on my server, and not working on another one. Here's my code: const user = message.author; let servericon = message.guild.iconURL; let serverembed = new Discord.MessageEmbed() .setAuthor(message.author.username, auser.displayAvatarURL({ format: 'png' })) .setTitle("Информация о сервере") .setColor("RANDOM") .setThumbnail(servericon) .addField("Название сервера :", message.guild.name) .addField("Владелец :", `${message