discord

discord.js v12: How do I await for messages in a DM channel?

江枫思渺然 提交于 2021-02-09 09:13:14
问题 This is the code that I've tried: message.author.dmChannel.awaitMessages(msg => { console.log(msg.content) }); But it returns this error message: TypeError: Cannot read property 'awaitMessages' of null Updated Code: message.author.send("What is your name?") const filter = m => m.author.id === message.author.id message.author.dmChannel.awaitMessages(filter) .then((collected) => console.log(collected.first().content)) 回答1: You're not using awaitMessages() properly, you need to pass a filter

Discord.py: How to fix “event loop is closed”

流过昼夜 提交于 2021-02-09 00:38:14
问题 I am new to programming. I am trying to have my discord bot open up command prompt to confirm it can run, but I am getting this error: File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib

Discord.py: How to fix “event loop is closed”

怎甘沉沦 提交于 2021-02-09 00:38:14
问题 I am new to programming. I am trying to have my discord bot open up command prompt to confirm it can run, but I am getting this error: File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib

I get a syntax error when I import discord in the cmd but not in vs code

◇◆丶佛笑我妖孽 提交于 2021-02-08 11:44:16
问题 I get a syntax error when I try to import discord, everything works in vscode but not in cmd C:\Users\anselm_lothar\Documents\Python\pythonProject\Event bot>main.py Traceback (most recent call last): File "C:\Users\anselm_lothar\Documents\Python\pythonProject\Event bot\main.py", line 4, in import discord File "C:\Users\anselm_lothar\AppData\Local\Programs\Python\Python38\lib\site-packages\discord_ init _.py", line 25, in from .client import Client File "C:\Users\anselm_lothar\AppData\Local

User connected to voice channel?

本小妞迷上赌 提交于 2021-02-08 11:19:31
问题 I want to know is it possible to know if any member is connected to a specific voice channel in discord.js v12.2.0. I've been sticking in this question in recent days. Please tell me if you have any clues on it. 回答1: I am not sure if you want to know if the member is connected to a VoiceChannel or listen to the voiceStateUpdate event so I'll cover both cases. Checking if the member is connected to a VoiceChannel const Guild = client.guilds.cache.get("GuildID"); // Getting the guild. const

discord.js trying to create a random outcome command with 2 arrays

佐手、 提交于 2021-02-08 09:55:46
问题 I've been working on my discord bot for a while now and it has a mine command feature but only has one outcome gives the user 20 silver and a simple message but I want multiple answers the bot can give and different amounts of silver. I've tried to use the 'dl.AddXp' and the message in one array but it just gives off a error. if (command === "mine") { var rando_choice = [ dl.AddXp(message.author.id, -20), dl.AddXp(message.author.id, 50), dl.AddXp(message.author.id, -10) ] var rando_choice2 =

discord.js trying to create a random outcome command with 2 arrays

試著忘記壹切 提交于 2021-02-08 09:55:13
问题 I've been working on my discord bot for a while now and it has a mine command feature but only has one outcome gives the user 20 silver and a simple message but I want multiple answers the bot can give and different amounts of silver. I've tried to use the 'dl.AddXp' and the message in one array but it just gives off a error. if (command === "mine") { var rando_choice = [ dl.AddXp(message.author.id, -20), dl.AddXp(message.author.id, 50), dl.AddXp(message.author.id, -10) ] var rando_choice2 =

Discord.py-Rewrite Taking a list of blacklisted terms and checks if arguments after command contains one of the blacklisted terms

允我心安 提交于 2021-02-08 08:38:20
问题 MY GOAL I am working on a discord bot similar to "Discord Delivers" and "Pizza Byte". And I am trying to take a list of terms/keywords and check if the arguments after the command (The code for the command is at the end of this post); So if they do >order BadWord then it checks if it contains one of the previously specified blacklisted terms, and if so, does like await ctx.send("Due to your order containing one of the blacklisted terms, your order will not be placed.") Or something like that.

Discord.py welcome message for multiple servers

冷暖自知 提交于 2021-02-08 06:45:36
问题 I am making a discord bot that I plan on being in multiple servers. Each server will have a different welcome channel name and all that. I made the welcome message and I tried making the bot post the message in a channel called "welcome" which would solve this problem but didn't work. I thought about making a database that saves the channel id that the server owner sends to the bot under the server name/ID. The bot when triggered would match the server ID to one in the database then grab the

How to save command cooldown?

折月煮酒 提交于 2021-02-08 05:44:25
问题 The code below adds a cooldown for command, but when bot restarts, the cooldown resets. So how can I make the bot remember from previous usage? If the cooldown limit is 5 times per day and if the member used 3 times and if bot restarts it should start from where it was left for all members. import discord from discord.ext import commands import random from utils import Bot from utils import CommandWithCooldown class Members(): def __init__(self, bot): self.bot = bot @commands.command(pass