discord.js

How to update existing object inside an array using mongoose

依然范特西╮ 提交于 2021-01-29 05:49:41
问题 I'm trying to make a currency system with my discord.js bot and mongoose. Here is an example MongoDB document format: { guild: "2095843098435435435", wallets: [ { id: "2323232335354", amount: 10, }, { id: "24344343234454", amount: "i want to update this", }, ], }; As far as I know, the Array.prototype.push() function is for making a new object inside an array. But how can I update an existing object inside an array? My code: const find = await Account.findOne({ guild: message.guild.id, }); if

TypeError: Class extends value Command is not a constructor or null - node.js

偶尔善良 提交于 2021-01-29 05:20:39
问题 I tried to make a !warn command, so that I can warn people in my server and if you have 2 warns you get a mute etc. When I was done there was only 1 error left. I tried many things, but I just can't figure it out, every help would be awesome. Full error: TypeError: Class extends value Command is not a constructor or null at Object.<anonymous> (/app/server.js:297:12) at Module._compile (internal/modules/cjs/loader.js:759:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:770

How to retrieve user without hardcoding ID in discord client.users.get function

自闭症网瘾萝莉.ら 提交于 2021-01-29 05:09:18
问题 I'd like my discord bot to send a user (captain) a message, when another user on the server wants to join their team. I have the DiscordID of the captain stored in my SQLite database and can retrieve it. The problem is that when I pass this variable as an argument to the client.users.get() method, it returns undefined. I've tried converting the DiscordID to a string, but it still returns undefined. When I hardcode the DiscordID it works fine. I'm not very experienced with discord.js so I'm

`TypeError: member.hasPermission() is not a function` when checking permissions in discord.js

£可爱£侵袭症+ 提交于 2021-01-28 19:48:50
问题 I am trying to make a has-permission command for my Discord bot, which takes two arguments: the user to check, and the permission to check for. You can see the code in the bot's GitHub repository (the config.json file is hidden due to it containing private information about my bot application). Discord Screenshot: The bot just replies there was an error trying to execute that command! . Console Screenshot: The console just says TypeError: member.hasPermission is not a function . Is there any

TypeError: message.member.roles.some is not a function

和自甴很熟 提交于 2021-01-28 19:10:59
问题 if (message.content.startsWith(`${prefix2}red`)){ if (message.member.roles.some(role => role.name === 'Red')) return message.channel.send(`You already has that role `) let role = message.guild.roles.find(r => r.name === "Red"); let member = message.member; message.delete(1) member.addRole(role).catch(console.error) } }) What do I need to change? for it to work? the error is if (message.member.roles.some(role => role.name === 'Red')) return message.channel.send(`You already has that role `)

Delete all channels in a specific category

点点圈 提交于 2021-01-28 13:39:58
问题 How to delete all channels in a specific category in Discord.JS? I tried that oldMember.guild.channels.cache.get(client.tr["Settings"].MainChannelID).parent.channels.cache.forEach(c => { if(c.members.size != 0){ c.delete(); } }) 回答1: You can get all the channels that belong to a category using CategoryChannel.children const category = await oldMember.guild.channels.cache.get(CATEGORY_ID); // You can use `find` instead of `get` to fetch the category using a name: `find(cat => cat.name ===

How often can I rename discord channel's name?

不打扰是莪最后的温柔 提交于 2021-01-28 10:54:07
问题 This is not a post about HOW to change channel's name (I know it). I have an international server using several bots. And we all depend on UTC time (to coordinate through the world). So there was borned a solution to make a time-bot which will show current UTC-time in the dedicated channel nobody can visit. And yes, precision is necessary, even seconds. I created a voice channel with permissions not to join for @everyone. Everything worked fine, it updated every 1000 ms. Then (after several

Making a bot delete its own message after a timeout

时光总嘲笑我的痴心妄想 提交于 2021-01-28 08:23:21
问题 I am looking to have my bot send a message, confirming that it executed the command, and then delete that confirmation message after a timeout; so as not to clutter the chat. Here is a code sample of my current command I would like to have it applied to: exports.auth = 1 exports.run = (client, message, args) => { let num = parseInt(args); message.channel.bulkDelete(num+1) .then(messages => console.log(`Bulk deleted ${num} messages`)) .catch(console.error); message.channel.send(`Deleted ${num}

Discord.js Move members to different voice channel

点点圈 提交于 2021-01-28 08:19:56
问题 So, I'm trying to make a command that, when said, provided with a mention and the name of a Voice Channel, moves the member you mentioned to that Voice Channel. I've done a bit of research on this but still can't get it work. const Discord = require('discord.js'); const client = new Discord.Client(); const config = require('../config.json'); exports.run = function(client, message) { const args = message.content.slice(config.prefix.length).trim().split(/ +/g); const command = args.shift()

make an autorole for discord.js v12

核能气质少年 提交于 2021-01-28 07:32:55
问题 I wanna make my bot give automatically role when my friends join for first time to my server: I have tried this one my VPS node version: 12.19.0v :? client.on('guildMemberAdd', member => { console.log('User @' + member.user.tag + ' has joined the server!'); var role = member.guild.roles.cache.find(role => role.name == "Newbie") let user = member.user user.roles.add(role); }); but nothing is working ! help me pls 回答1: Discord is now enforcing privileged intents. The GUILD_MEMBERS intent is