discord.py-rewrite

Is there a way to find all the loaded and unloaded cogs in discord.py-rewrite

ⅰ亾dé卋堺 提交于 2021-01-29 06:58:28
问题 I have a lot of cogs for my bot, but i load and unload them using commands Still I get confused and load/unload a cog again-and-again I wonder is there a way to check all the loaded and unloaded cogs using commands.(Other than the default help command) 回答1: Looking at discord.py documentation, if you try to load a cog that is already loaded, it will raise a discord.ext.commands.ExtensionAlreadyLoaded exception. Using this error, you could do this: from discord import commands bot = commands

Disable discord.py command at certain times of day

南笙酒味 提交于 2021-01-29 06:44:52
问题 I have a tts bot that I want to either toggle on and off with a command, or be automatically turned of from 11pm - 7am when i'm sleeping. Is this possible? TTS Code: @client.command() async def tts(ctx, *, msg): print('{0} : {1}'.format(ctx.author, msg)) print('TTS started {}'.format(msg)) os.system('flite -t "{}"'.format(msg)) await ctx.send('TTS done.') 回答1: You can make a loop, that iterates every 24 hours that will change the enabled_tts variable to False, in the command, check if the

Python: Discord.py ERROR: Could not build wheels for multidict, yarl which use PEP 517 and cannot be installed directly

跟風遠走 提交于 2021-01-29 06:40:17
问题 So I recently have tried to install discord.py through cmd but its giving me an error no matter if I use pip3 py pip. It says i need to install visual studio 14 but i have visual studio 16 installed. I've uninstalled and reinstalled python 3.9.0 i've updated through 'pip install --upgrade pip" and it still gives me the same error. here is the error: Microsoft Windows [Version 10.0.18363.1139] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\rektb>pip Usage: pip <command> [options

(discord.py) How do I get my bot to read DM's that are sent to it and either print them or send them to a specific channel

和自甴很熟 提交于 2021-01-28 19:28:28
问题 So I recently created a discord bot with various meme commands and moderating commands. I am relatively new to python but I understand the gist of it. I have already created a command that lets me(only me) DM a user through the bot. I now want to try and make the bot be able to read the messages that are sent back to it and send them to me, whether its printed in shell or sent to a specific channel/me I don't care, I just want to be able to see what is sent to it. I did some reading around

Discord 'on_member_join' function not working

佐手、 提交于 2021-01-28 13:37:19
问题 My on_member_join doesnt seem to work. I wanted my bot to say out the names of the members that joined the sever but it doesnt detect if someone has joined or left. import discord from discord.ext import commands client = commands.Bot(command_prefix = '.') @client.event async def on_ready(): print("bot is ready ") @client.event async def on_member_join(member): print(f'{member.name} has joined this server') @client.event async def on_member_remove(member): print(f'{member}was removed') client

Discordpy Tasks not working as expected. No returning

こ雲淡風輕ζ 提交于 2021-01-28 12:30:28
问题 @tasks.loop(seconds = 5.0) async def remind420(self): print("YES") print(datetime.now().strftime("%H:%M")) if datetime.now().strftime("%H:%M") == "16:55" or datetime.now().strftime("%H:%M") == "04:20": await client.get_channel(499245707081940995).send("420!!") @remind420.before_loop async def remind420_before(): await client.wait_until_ready() remind420.start() There is no output. Absolutely no output. I expect the time to returned or atleast a yes. 回答1: Make sure to have all your imports and

Issue adding a role when reacting to a post

浪尽此生 提交于 2021-01-28 11:11:44
问题 I'm having an issue adding a role when a user reacts to a post. How I'm wanting it to function is that when a user joins the Discord server the bot will send send a message using the on_join event (for now I'm using the command test for testing purposes). The next step is the on_reaction_add event, when the user reacts to this message the bot will add the role to that user. Here is what I'm working with. I've tested this however, I'm not getting the desired result. (on discord.py rewrite)

How to get the message content/embed from the message id?

帅比萌擦擦* 提交于 2021-01-28 05:24:46
问题 I want to know how to get a message content (specifically the embeds) from the message id ? Just like you can get the member using a member id 回答1: on_raw_reaction_add() example: @bot.event async def on_raw_reaction_add(payload): channel = bot.get_channel(payload.channel_id) msg = await channel.fetch_message(payload.message_id) embed = msg.embeds[0] # do something you want to Command example: @bot.command() async def getmsg(ctx, channel: discord.TextChannel, msgID: int): msg = await channel

Discord.py: Trying to do an action depending on user reaction

不问归期 提交于 2021-01-28 05:21:48
问题 This is the code: import asyncio import discord from discord.ext import commands client = commands.Bot(command_prefix = ".") Token="" @client.command() async def react(ctx): message = await ctx.send("Test") await message.add_reaction("<💯>") await message.add_reaction("<👍>") user=ctx.message.author def check(reaction, user): user == ctx.message.author and str(message.emoji) == '💯' try: reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check) except asyncio.TimeoutError

Is it possible to put an async function as a callable argument?

老子叫甜甜 提交于 2021-01-28 05:10:08
问题 I'm coding a music bot for my server, and I need to disconnect (a coroutine) when the queue is exhausted. So I use a try: except block to handle that, however, when using VoiceClient.play , is it possible to put an asynchronous function as the after parameter? Just using after=function does not work and would raise function was not awaited, but using after=await function shows TypeError: object function can't be used in 'await' expression Is there any way to call an async function from play?