[Solved] How can I add Embed message from an array discord.js?

[ad_1] Well You just need to use embeds like in the help command. Here the code: if (command === “t”) { // Truth const truth = t[Math.floor(Math.random() * t.length)]; message.channel.send(new Discord.MessageEmbed() .setTitle(“Truth”) .setDescription(truth)); } else if (command === “d”) { // Dare const dare = d[Math.floor(Math.random() * d.length)]; message.channel.send(new Discord.MessageEmbed() .setTitle(“Dare”) .setDescription(dare)); } [ad_2] solved … Read more

[Solved] How to get the sum and the names of all the users from all voice channels Disocrd?

[ad_1] You need to access the voice channel object. I recommend you use the voice channel’s id. The command could look as follows: @client.command(pass_context = True) async def vcmembers(ctx, voice_channel_id): #First getting the voice channel object voice_channel = discord.utils.get(ctx.message.server.channels, id = voice_channel_id) if not voice_channel: return await client.say(“That is not a valid voice channel.”) members … Read more

[Solved] How to format HTTP request to discord API?

[ad_1] t=”POST / HTTP/1.0\r\nAuthentication: Bot {token}\r\nHost: discord.com/api/guilds/{702627382091186318}/channels\r\n\r\n” This is not a valid HTTP request. You essentially send (line breaks added for clarity): POST / HTTP/1.0\r\n Authentication: Bot {token}\r\n Host: discord.com/api/guilds/{702627382091186318}/channels\r\n \r\n But a correct POST request would look like this instead: POST /api/guilds/{702627382091186318}/channels HTTP/1.0\r\n Authentication: Bot {token}\r\n Host: discord.com\r\n Content-length: … \r\n <body, where size … Read more

[Solved] How do you give a user a role by role ID in Discord.JS V13 (latest)

[ad_1] You can do this something like same thing with getting member.id. const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) You can create the code similar to this. const role = message.mentions.roles.first() || message.guild.roles.cache.get(args[0]) Now you can adjust your code file: const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) const role = message.mentions.roles.first() || message.guild.roles.cache.get(args[1]) member.roles.add(role) //To add the … Read more

[Solved] Coin flip command

[ad_1] if(command == “ht”) { function doRandHT() { var rand = [‘HEADS!’,’TAILS!’]; return rand[Math.floor(Math.random()*rand.length)]; } const embed = { “title”: `Here is the winner!`, “description”: doRandHT(), “color”: 7584788, }; message.channel.send({ embed }); }; You can use this plain command for every random command in Discord.js I also integrated this with embed design so it will … Read more

[Solved] SyntaxError: Unexpected token ‘const’ [closed]

[ad_1] You are saying if(!Events.includes(event.name)) const L = file.split(“/”); Which doesn’t make sense because const is block scoped. You forgot {} if (event.name) { if(!Events.includes(event.name)) { const L = file.split(“/”); return Table.addRow(`${event.name || “MISSING”}`, `⛔ Event name is either invalid or missing ${L[6] + `/` + L[7]}`); } } [ad_2] solved SyntaxError: Unexpected token ‘const’ … Read more

[Solved] How can i use discordpy cooldown command for client = discord.Client() [closed]

[ad_1] Also client = discord.Client() will not work. Use client = commands.Bot(command_prefix=prefix, intents=intents) Cooldowns are only for commands. Put this under a command – @commands.command() or @client.command: @commands.cooldown(uses, cooldown_time, commands.BucketType.user) e.g. @commands.cooldown(1, 30, commands.BucketType.user) Source: Cooldown For Command On Discord Bot Python 1 use per user and cooldown time is 30s If you don’t want … Read more

[Solved] Display all Guild Names of a Bot in discord.js

[ad_1] guilds.json { Placeholder: null } The above is the file with the guild IDs const fs = require(‘fs’); const Discord = require(‘discord.js’); const client = new Discord.Client(); client.on(‘ready’, () => { let guilds = client.guilds.cache const json = {} guilds.forEach(g => { json[g.name] = g.id }); fs.writeFileSync(‘./guilds.json’, JSON.stringify(json)) }); client.on(‘guildCreate’, guild => { const … Read more

[Solved] Check if people in a voice channel have turned on video (discord.py) [closed]

[ad_1] Try looking at this https://discordpy.readthedocs.io/en/latest/api.html?highlight=voicestate#discord.VoiceState.self_mute This is documentation for Voice State. It will tell you whether they are muted(by them not server) or not. I’m guessing video is fairly similar. [ad_2] solved Check if people in a voice channel have turned on video (discord.py) [closed]