discord

How to reply to any DMs sent to the bot?

随声附和 提交于 2019-12-10 19:17:43
问题 I am trying to make my bot replying to any DM sent to it. So I currently have this: client.on('msg', () => { if (msg.channel.DMChannel) { msg.reply("You are DMing me now!"); } }); But unfortunately, it does not reply to any DM. I've tried to replace msg.channel.DMChannel with msg.channel.type == 'dm' but this didn't work. I also tried to replace msg.reply with msg.author.send and msg.channel.send but they all didn't work. Any help would be appreciated. Thanks! 回答1: On the official

Discord bot: Fix ‘FFMPEG not found’

只愿长相守 提交于 2019-12-10 15:25:00
问题 I want to make my Discord bot join voice chat but every time I make it I get a error into log(cmd) saying, FFMPEG not found , please help me. Picture of the error: This is the code: client.on('message', message => { // Voice only works in guilds, if the message does not come from a guild, // we ignore it if (!message.guild) return; if (message.content === '/join') { // Only try to join the sender's voice channel if they are in one themselves if (message.member.voiceChannel) { message.member

Is there a command to send private message to all members of a group?

梦想与她 提交于 2019-12-10 12:17:45
问题 Is there any way to make a command send a private message to all members of the discord group using discord.js? Exemple: /private TEST This message is sent to everyone in the group in private chat instead of channel chat. 回答1: You can iterate through Guild.members. When you receive a message that starts with /private , you take the rest and send it to every member of the guild by using Guild.members.forEach(). Here's a quick example: client.on('message', msg => { if (msg.guild && msg.content

Discord.py Reaction bot that gives a role

Deadly 提交于 2019-12-10 11:02:15
问题 How do I make a bot that would give people roles when they reacted to a specific thing? So far I have this but it does not work @client.event async def on_ready(): channel = client.get_channel('513546504481406979') role = discord.utils.get(user.server.roles, name="testrole") message = await bot.send_message(channel, "React to me!") while True: reaction = await bot.wait_for_reaction(emoji="👍", message=message) await bot.add_roles(reaction.message.author, role) 回答1: wait_for_reaction returns a

Discord.js message attachments picture

橙三吉。 提交于 2019-12-10 09:26:38
问题 message.channel.sendMessage(text).attachments ["",{url:"http://openweathermap.org/img/w/"+icon+".png" }]; I made some bot, with node-js ( discord.js ) . I want to send message with picture(without URL) so, I found fuction attachments, in documentation. But, when I put in message (text) and attachments some picture, in the console,I get: "Cannot read property '# < Object >' of undefined" What should I do fix this problem? 回答1: According to the docs, you will need to pass an object containing

Guild is not defined

爱⌒轻易说出口 提交于 2019-12-10 00:45:52
问题 I am currently making a discord.js bot for discord, but i'm getting the same issue all time : ReferenceError: guild is not defined at Client.client.on.message (C:\Users\Valentin\Documents\JsBot_dev\bot.js:27:30) at emitOne (events.js:101:20) at Client.emit (events.js:188:7) at MessageCreateHandler.handle (C:\Users\Valentin\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34) at WebSocketPacketManager.handle (C:\Users\Valentin\node_modules\discord.js\src\client

Why messageReactionAdd do nothing discord.js

我与影子孤独终老i 提交于 2019-12-10 00:19:49
问题 I want to say that I am French, and I apologize for the mistakes. I try to code a discord bot with node.js, but i have a problem with messageReactionAdd i don't now why he do nothing when i react with an emoji. My code : bot.on('messageReactionRemove', (reaction, user) => { console.log("that work 1"); if(reaction.emoji.name === "white_check_mark") { console.log("that work 2"); }}) However i see on this forum it will work for others thanks for read ! 回答1: Events messageReactionAdd and

Per server prefixs

折月煮酒 提交于 2019-12-09 00:53:35
问题 I was wondering how I would go about allowing every server my bot is connected to, to set their own prefix. I am using the async version of dpy with Commands ext. I would assume you would store the prefix's and server name in a .json file, but I don't know how you would write them or check the file for them. Thanks 回答1: You can do this with dynamic command prefixes. Write a function or coroutine that takes a Bot and a Message and outputs the appropriate prefix for that message. Assuming you

Load cog for multiple bots

核能气质少年 提交于 2019-12-08 17:40:04
问题 Using discord.py , I can run multiple bots from one piece of code, but I'm looking for a way to load a cog or extension into multiple bots. For a test case, I have bot.py , which handles loading the cog and starting the bot, and cog.py which is a simple cog that incrementally adds 1 to a counter bot.py from discord.ext import commands import asyncio client1 = commands.Bot(command_prefix='!') client2 = commands.Bot(command_prefix='~') client1.load_extension('cog') client2.load_extension('cog')

give role when a user add reaction Discord.py

给你一囗甜甜゛ 提交于 2019-12-08 11:09:31
问题 i'm working on a bot for my discord channel and i'm learning python while doing it and i want to give role when a user adds reaction the code i came up with is this @client.event async def on_reaction_add(reaction, user): ChID = '487165969903517696' if reaction.message != ChID: return; if user.reaction.emoji == "🏃": CSGO = discord.utils.get(user.server.roles, name="CSGO_P") await client.add_roles(user, CSGO) but it doesn't work what i basically want is there is a message that i sent in a