discord.py

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

Receiving a runtime error at client.run('token') when running my discord.py bot

自古美人都是妖i 提交于 2021-02-08 11:27:35
问题 I am attempting to make a Discord bot in Python that gives you a role on a Discord server based upon what class you are in (at my school). I have just started, but I am receiving an error whenever I attempt to run it (I run it in Google Colab in a Python 3 Notebook). Here is my code: from datetime import date import time import discord client = discord.Client() @client.event async def on_ready(): print('We have logged in as {0.user}'.format(client)) client.run('my token (not shown for obvious

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.

How do I allow for multiple possible responses in a discord.py command?

做~自己de王妃 提交于 2021-02-08 07:01:33
问题 I'm attempting to set up a Discord bot while being relatively new to discord.py (and in reality, Python 3). I want to add the command "greet", which will prompt the user to say "hello" to it. It only responds to "hello", however, when I want it to respond to both "hello" and "Hello". The only things I could think about fixing it was placing them in an or statement, which in theory should've made Python 3 and the bot choose between the two responses (as shown below). @client.event async def on

How do I allow for multiple possible responses in a discord.py command?

做~自己de王妃 提交于 2021-02-08 07:01:20
问题 I'm attempting to set up a Discord bot while being relatively new to discord.py (and in reality, Python 3). I want to add the command "greet", which will prompt the user to say "hello" to it. It only responds to "hello", however, when I want it to respond to both "hello" and "Hello". The only things I could think about fixing it was placing them in an or statement, which in theory should've made Python 3 and the bot choose between the two responses (as shown below). @client.event async def on

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 send a message with discord.py from outside the event loop (i.e. from python-telegram-bot thread)?

∥☆過路亽.° 提交于 2021-02-08 06:13:24
问题 I want to use make a bot that communicates between discord and telegram by using the libraries python-telegram-bot and discord.py (version 1.0.0). However the problem is that discord.py uses async functions and python-telegram-bot threading. With the code below, everything works fine for messages being posted in discord (the bot sends them correctly to telegram), however the other way around does not work (bot gets messages from telegram and sends it to discord). I previously had issues with

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

Deleting a bot's message in discord.py

一世执手 提交于 2021-02-07 14:35:31
问题 I have already made all of the proper imports and I have tried looking for answers from other posts but it seems to not quite fit my issue. I am trying to randomly send a message, which I can do. However I can not seem to delete the messages after a certain cool down time. The cool down time is not the issue however. It is deleting the bots message. I know how to delete a user's message but I have very little idea on how I would delete the bots message. Any help would be nice. Here is my code