#discord-bots
1 messages · Page 221 of 1
No documentation found for the requested symbol.
!d discord.Member.timed_out_until
An aware datetime object that specifies the date and time in UTC that the member’s time out will expire. This will be set to None if the user is not timed out.
New in version 2.0.
bruh my internet connection is not working i cannot go to docs sadge
hiii
why we abandon pyweek
so sad maybe i will just quit team and submit a half-assed 1 hour pygame game to at least have something
I'm sorry it went that way, the team was made in a rush and the codebase isn't that great either
Rip
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
@client.hybrid_command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def dream(ctx,*,prompt):
url=os.getenv("sd")
msg = await ctx.send(f"Generating - {prompt} - **By {ctx.author.name}** \n ***Estimated*** <t:{int(time.time())+24}:R>")
res=requests.get(f"{url}/?dream={prompt.replace(' ','+')}")
print(res.content)
await msg.edit(content=f"Generated - {prompt} - **By {ctx.author.name}**",file=discord.File(res.content,filename='image.png'))```
why isnt it working , the res.content is in bytes and is an image,but i get this error raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: embedded null byte
when i add this line
with open("ok.png","wb") as f:
f.write(res.content)```
it saves the image successfuly
bro requests.get is a blocking call, you should use aiohttp
regarding your issue you don't need to save a file you can pass an io.BytesIO object to discord.File to send it
!d discord.File
class discord.File(fp, filename=None, *, spoiler=..., description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
!d io.BytesIO
class io.BytesIO(initial_bytes=b'')```
A binary stream using an in-memory bytes buffer. It inherits [`BufferedIOBase`](https://docs.python.org/3/library/io.html#io.BufferedIOBase "io.BufferedIOBase"). The buffer is discarded when the [`close()`](https://docs.python.org/3/library/io.html#io.IOBase.close "io.IOBase.close") method is called.
The optional argument *initial\_bytes* is a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object) that contains initial data.
[`BytesIO`](https://docs.python.org/3/library/io.html#io.BytesIO "io.BytesIO") provides or overrides these methods in addition to those from [`BufferedIOBase`](https://docs.python.org/3/library/io.html#io.BufferedIOBase "io.BufferedIOBase") and [`IOBase`](https://docs.python.org/3/library/io.html#io.IOBase "io.IOBase"):
do i do like this?
async with aiohttp.ClientSession as s:
res=await s.get(url)
await ctx.send(file=discord.File(io.BytesIO(res.content)))
Don't thank javascript it took my braincells away
Can someone help me
With?
Lol my bot has a .help command and I don’t know why. I never made the command and all of mine are slash commands, except for one built in configuration feature that uses the . prefix.
that comes free with commands.Bot for prefix-based commands, if you want to remove it just pass help_command=None to your bot's constructor
Ok
@blazing flint sent u in dms
@commands.has_permissions(administrator=True)
async def editgroup(self, ctx, group_name):
server_id = str(ctx.guild.id)
try:
group = self.database.getgroup(server_id, group_name)
if group is None:
await ctx.send(f"Group '{group_name}' does not exist.")
return
# Ask the user whether they want to add or remove members
await ctx.send(f"What do you want to do with the {group_name} group? Type 'add members' or 'remove members'.")
action = await self.bot.wait_for('message', check=lambda m: m.author == ctx.author)
action_str = action.content.strip().lower()
# Determine which member column to modify based on the action
if action_str == 'add members':
member_col = 'members'
elif action_str == 'remove members':
member_col = 'members2' # Change this to the appropriate column name if necessary
else:
await ctx.send(f"Invalid action. Please type 'add members' or 'remove members'.")
return
# Ask the user for the members to add or remove
await ctx.send(f"Who do you want to {action_str} from the {group_name} group? (Please separate each user with a space, or reply 'no' to cancel)")
members = await self.bot.wait_for('message', check=lambda m: m.author == ctx.author)
members_str = members.content.strip().lower()
if members_str == 'no':
await ctx.send("Operation cancelled.")
return
else:
# get the usernames from the mentioned users
if len(members.mentions) == 0:
members_str = ''
else:
members_str = ", ".join([member.name for member in members.mentions])
new_members = [member.id for member in members.mentions]
# Modify the appropriate member column in the database
if member_col in group:
old_members = [int(member_id) for member_id in group[member_col].split(',') if member_id != '']
else:
old_members = []
if action_str == 'add members':
updated_members = set(old_members).union(new_members)
else:
updated_members = set(old_members) - set(new_members)
updated_members_str = ','.join(str(member_id) for member_id in updated_members)
self.database.editgroup(server_id, group_name, member_col, updated_members_str)
await ctx.send(f"Group '{group_name}' has been updated with {action_str} '{members_str}'.")
except Exception as e:
print(e)
await ctx.send(f"An error occurred while updating the group.")
traceback.print_exc()```
Instead of adding members to the list, its replacing the whole list.
anyone knows how to fix that
No u didn’t
whats the story with discord.py now? Does it support slash commands and all of those new fancy features?
It has for a long time lol
alrighty
and what about forum channels anddddd
I can't really think of anything else right now, but I know it had a lot of holes in terms of what you could do in the library compared to what discord offered
@blazing flintwait can u tell are we only supposed to use slash commands in bot??
not sure if there's a list of missing features somewhere, but you can look through the changelog to see what they've recently added (forumchannels were added in 2.0)
https://discordpy.readthedocs.io/en/stable/whats_new.html
some missing features i can think of is oauth flow (out of scope for dpy), http-only interactions (though this can be done using internals), and voice receive (i think danny isnt willing to maintain this feature?)
i'm just having a read right now. If there's nothing major missing then that's all the better for me
and fwiw
<#dev-announcements message>
2022/3/05: We just migrated <@&270988689419665409> to disnake!
2022/3/13: We'll be reverting our migration on bot and our bot-core projects to use the latest revisions of Discord.py
No
But I prefer them
The reason Danny doesn't wanna add voice receive is because the endpoint isn't documented and he doesn't wanna add anything that is undocumented (which seems kinda lame ngl)
Http only interactions is also a highly requested feature but no idea why he ain't willing to add that (or maybe gonna add in future version(s)
canary discord?
its still a thing?
What will the value be when the member is timed out
a datetime object if they're timed out, or None if they're not timed out
Why it shouldn't be
You can click on the link, the docs will give you all that information
import discord
import random
TOKEN = 'Secret'
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_message} ({channel})')
if message.author == client.user:
return
if message.channel.name == 'python-projects':
if user_message.lower() == 'hello':
await message.channel.send(f'Hello {username}!')
return
elif user_message.lower() == 'bye':
await message.channel.send(f'Bye {username}!')
return
client.run(TOKEN)
Why wont this work
Wait you can make a discord bot in python????
is there like a basic code somewhere i can copy and build off of?
you can check the discord.py docs and github repo: https://discordpy.readthedocs.io/en/stable/intro.html
it's recommended you know atleast basic python before starting though
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
what is this? text o get voice support, you should use discord.py[voice] instead of discord.py is that just to allow it to connect to voice channels and speak? if so that is useful, i can create a music bot
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
great
just take note of this when making a music bot ^
yep
How would I put this into the code?
the same way it's done in the example except you would pass the intents to your discord.Client instead of commands.Bot
Well some people like to do something along the lines of
intents = discord.Intents.all()
and then pass it when you create your client/bot object
Uh explain, I'm very new when it comes to creating bots
I started learning python 2 weeks ago
O_o
You may want to consider learning a bit more python first, since discord.py will require you to use quite a few things which you may not have learnt about yet (such as classes, decorators and async)
Yes I know, but I really want to make a discord bot, and it also helps me understand general python
Once I've learned the language fully, I'm going to go into AI and stuff
question: is my bot supposed to stay online after i hit close on my script?
because it wont go offline
but the commands dont work
how do i take it offline its creepy
when you set the bots status in your code make it .offline
Try refreshing your client, it may take discord a bit to register the disconnect
(ctrl + R)
Yo can you help me with
depends what u need
this, I get intent errors
lemme go to my project for the prooper intents
pass intents object when creating Client
!d discord.Client
class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
async with x Asynchronously initialises the client and automatically cleans up.
New in version 2.0.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
how do i set up slash commands? i currently have a basic one: ```py
import discord
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
if message.content.startswith('$Who are you?'):
await message.channel.send('I am a bot, wirtten in python by Faulty! I am a basic bot.')
client.run('Token')```
it has intents argument
import discord
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
intents = discord.Intents.all()
TOKEN = 'pypypypypypypy'
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_message} ({channel})')
if message.author == client.user:
return
if message.channel.name == 'python-projects':
if user_message.lower() == 'hello':
await message.channel.send(f'Hello {username}!')
return
elif user_message.lower() == 'bye':
await message.channel.send(f'Bye {username}!')
return
client.run(TOKEN)
I put in the intents, but still doesnt work
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)```
just pasting code and dont understanding what it does does not solve the problem
I didn't paste it
I watched a toturial
I need to begin on bot developing somewhere
you need to create discord.Intents object then enable intents you need and then pass it when creating Client
does anyone know this?
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
thx
!paste
@stable current https://paste.pythondiscord.com/osinuxizoz
thats the code u need
lmk if theres any more errorz
Is there a way to make a more simplified bot without intents?
nope
discord requires intents
Any toturials on yt on how to use them?
also @stable current what type of bot are u coding? Moderation bot?
No just a starter bot that responds when you for example say !hello
i could send u my code for a moderation bot if u wanta look at it
also i recomend using bot.command not client.command
Could you send me a simple discord bot with the intents stuff fixed?
like, an example
class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").
New in version 1.5.
# we create intents varriable with the default intents enabled
intents = discord.Intents.default()
# we additionally enable message content so our bot can see messages
intents.message_content = True
# when creating a Client or Bot instance we pass in intents we created
client = discord.Client(intents=intents)
# use the client
...
explained as i could
import discord
from discord import Intents
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
client = discord.Client(intents=intents)(all)
client = commands.Bot(command_prefix= "#", intents= intents)
TOKEN = 'pypypyppypypyppypypy'
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_message} ({channel})')
if message.author == client.user:
return
if message.channel.name == 'python-projects':
if user_message.lower() == 'hello':
await message.channel.send(f'Hello {username}!')
return
elif user_message.lower() == 'bye':
await message.channel.send(f'Bye {username}!')
return
client.run(TOKEN)
Like this?
yes
It still doesnt work
use bot instead of client
No you define client 2 times
Yeah, I fixed the code and used pass
And it finally worked
Please have some Basic python knowledge before starting to create a discord bot
That's not good for first project
Yeah I know, but I'm very motivated to do it
I study python every day, I'm going to go back to the more general stuff now
Gotta walk before you can run
Anyways, I finally did it and I'm happy and even more motivated to learn the more general stuff, so yeah
@slate swan Do you know how I can use the slash commands with my bot?
^ dont forget about this tag
@stable current that being said, it will become easier to understand as you grasp the fundamentals like data types, functions, and object oriented programming
there's a list of things you should know here: https://gist.github.com/scragly/095b5278a354d46e86f02d643fc3d64b
try to understand a reasonable amount of what you're writing and develop a good reasoning about what your program does
str(message.author)gives me a string in the form "username#tag" and i want the username, so im using.split('#')to split the username/tag into two elements in a list, then indexing the first element with[0]to get the username
btw message.author.name / message.author.display_name serves the same purpose as above, and that's part of the documentation which will become a very important source of information for learning what the library provides
https://discordpy.readthedocs.io/en/stable/api.html#id1
generally official sources are preferable for learning since they tend to have more comprehensive and up-to-date information, including python's own documentation
(not that third-party guides are all bad, however many about discord.py are notorious for demonstrating bad practices)
Yes there was gist somewhere
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
Do you need slash commands do get the badge?
yes, you can see how to get it here
https://support-dev.discord.com/hc/en-us/articles/10113997751447-Active-Developer-Badge
I currently have my own commands, but is it required to have slash commands to get the badge
easyest way but cheatiest way to get it is make a bot ghost project and its got a feature to get the badge (very easy) but i done mine with coding my own bot so...
your choice if u want an easy way or a slightly harder way
I don't want to do it like that
I want to do this as a challenge
okay
you just gotta learn how to make / cmds and ur good
Exactly what I'm doing rn 👍
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!", intents= discord.Intents.all())
TOKEN = 'pypypyppypypypypypyp'
@bot.event
async def on_ready():
print("Bot is running!")
try:
synced = await bot.tree.sync()
print(f"Synced {len(synced)} command(s)")
except Exception as e:
print(e)
@bot.command()
async def hello(ctx):
await ctx.send(f"Hey {ctx.author.mention}! This is a slash command")
bot.run(TOKEN)
Why wont it detect synced commands
Anybody know hwo to timeout users in discord.py
!d discord.Member.timeout
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.11)").
You must have [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") to do this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
those are not even slash commands
did you read the link i gave you?
Hi
So I was using interaction.user.timeout(
How do I mute for 20s with that
class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.
Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
Alr lemme try
!e ```py
from datetime import timedelta
until = timedelta(seconds=20)
print(until)
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
0:00:20
now when you have the object
you need to pass it into timeout method
!d discord.Member.timeout
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.11)").
You must have [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") to do this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
until arg
An aware datetime object that specifies the date and time in UTC that the member’s time out will expire.
Thanks it worked
Hi
My discord button is not changing color
When it is clicked
Here's the code
how can i obtain message author user id?
Developer Mode
Settings > Advanced > Developer Mode
hello
no no
from bot
for example
i send this message and want from bot to take this message author id
oh
You're spelling button wrong you say "buttoon" unless you have to do that that's what I see
!d discord.Message.author
I forgot to send the changes lol
I am stupid
Workes now?
I don't really know I'm sorry
If you're looking for a specific message author id from a channel then use events and pass a channel id
thanks for your response ❤️
What did you have to do?
Send the new view
it's just a variable name, it can be called whatever
The user’s unique ID.
hello!
thanksss ❤️
and another question
if i want to obtain user display name from that user id , what should i write?
if it's a member and you want to fetch their nickname or username, use Member.display_name, otherwise use Member.name/User.name
if you ONLY have the user ID, then get or fetch the user first using Client.get_user
unfortunately , it not work
@bot.tree.command(name="getid",description="Get User Id!")
@app_commands.describe()
async def getid(interaction:discord.Interaction):
userid = interaction.user.id
username = discord.Member.display_name(userid)
print(str(username))
```@smoky sinew
no
just print(interaction.user.display_name)
and remove lines 4 and 5
you need an instance of discord.Member to use display_name
how can i run 2 files in my bot?
In what sense?
for example python3 requirements.txt && main.py it doesn’t work anymore
you're running your requirements.txt file?
it would be python3 requirements.txt && python3 main.py
does that even work in the first place though
holy shit im an idiot
ok
you can't really run text files with python lol
and I don't think you can run two files like that at the same time
you should run them separately if you want
cat /dev/urandom | python3
there is a potential chance that in a few million years this will remove all files on your computer
any tips for where should i start learning about discord bots made with python?
can someone send a like verification that i can run in it that lets me join servers for them
make sure to have a core fundamental on these before starting dpy
https://gist.github.com/scragly/095b5278a354d46e86f02d643fc3d64b#required-knowledge
then you can use a quick start example
https://discordpy.readthedocs.io/en/latest/quickstart.html
oh thanks
i open the app and it opens terminal
what do i do next
im not watching a 5 hour video for it to tell me
please help
oauth2
it's not really related to a discord bot so much as a webserver
how do you add cooldowns to discord ui buttons? i want to set it to once a minute with some indicator that the buttons are ready again. maybe change them to red? then revert back the colours?
or maybe a queue method so it doesn't error?
on_click -> disable button -> spawn asyncio task, sleep for 1 minute -> enable button
ty
now that i think about it you dont have to spawn a task at all, just do it inside the button callback 🤔
I am defining a message variable so I can edit it later. For some reason, I can only use message.edit if the message is not an interaction.response. How can I edit an interaction.response object?
true and just make a guard clause 😄
i suppose yea in the interaction_check
interaction.response.edit_message?
Ok so I don’t need the message variable for it to function?
no, the edit_message refers to the message that triggered the interaction
K
@golden portal I get an error when I do this saying the interaction has already been responded to before. I am trying to edit the response I already sent
Is it just not possible to add a view to a response?
i see, if thats the case you would need to use Interaction.edit_original_response, it will edit your response message
ok
I created a bot that created a channel and created several threads in the channel to automatically transmit certain data every month on a specified date. but, if the message is not updated for a certain period of time in the thread, the ID of the channel remains the same as before, but the message cannot be sent using the bot anymore. as shown below, the message that there is no channel id appears. so it says 'send' can't be done. is the only way to solve this is to send it to a channel rather than a thread?
'NoneType' object has no attribute 'send'
based on a quick test, threads are removed from the bot's cache as soon as they are closed/auto-archived (matching what the documentation says about get_thread)
if you just want to send a message to the channel and do nothing else, use Client.get_partial_messageable(thread_id) instead, or if you do need the actual Thread object, use Guild.fetch_channel(thread_id) as a fallback if get_thread doesn't work
wow... thank you so much i fixed with your solution. and now going to study with docs
problem is, if i try to get 'for t in tags' in jsk py, it works properly like it should
Can you make a bot that captures all the names in someone’s server
put them all in a list and then send/print that list
Yeah but it isn’t my server
the bot needs to be in whichever server you want to get the member list from
!d discord.Guild.members
property members```
A list of members that belong to this guild.
you can obtain the discord.Guild object via bot.get_guild or an event parameter depending on where you're trying to access it
Hello, do you know why all my commands open three times when I run them? https://paste.pythondiscord.com/isasikenok
you're calling
await bot.process_commands(message)
``` 3 times
Yes, because I have to, right? To have several messages?
await process_commands(message, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.
By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.
This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
Changed in version 2.0: `message` parameter is now positional-only.
see what it does ^
if you call it more than once, it'll process the commands more than once too
I edited it's fine thanks 😄😍
hi hoping to maybe get some help
working on getting this preview working for an embed command....code below
@commands.command()
async def embed(self, ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('Waiting for a title')
title = await self.bot.wait_for('message', check=check)
await ctx.send('Waiting for a description')
desc = await self.bot.wait_for('message', check=check)
await ctx.send('Please provide me with the image (directly paste or attach image, no need for link) for this post, if no image is needed just say none.')
news_image = await self.bot.wait_for("message", check=lambda m: all([
m.author == ctx.author,
m.channel == ctx.channel,
len(m.attachments) == 1 or "none" in m.content.lower()
]))
if news_image.attachments:
embed.set_image(url=news_image.attachments[0].url)
embed = discord.Embed(title=title.content, description=desc.content, color=0x1ABC9C)
embed.set_thumbnail(url="https://imgur.com/MJnM3LU.png")
await ctx.send('What channel should I send this in? Please provide me with the channel ID.\n- #news: 569635458183856149\n- #general: 803341100618219540\n- #patch-notes: 585952222853201941')
dest = await self.bot.wait_for('message', check=check)
await ctx.send('Who should I tag? Please provide me with the role ID.\n- news: 620025828079697920\n- gen: 803343410794594385\n- patch: 620025894559547412')
role_message = await self.bot.wait_for('message', check=check)
await ctx.send('What is the tag preview?')
tag_preview = await self.bot.wait_for('message', check=check)
channel = self.bot.get_channel(1065685023853920258)
class ConfirmationView(discord.ui.View):
@discord.ui.button(label="Confirm", style=discord.ButtonStyle.success)
async def confirm(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
await channel.send(1065685023853920258)
@discord.ui.button(label="Deny", style=discord.ButtonStyle.danger)
async def deny(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
await interaction.response.send_message("Cancelled.", ephemeral=True)
channel = self.bot.get_channel(int(dest.content))
await channel.send(embed=embed)
await channel.send(f"<@&{role_message.content}> - {tag_preview.content}")
goal is for it to send a preview into the command issued channel that can be approved or denied before being sent off
it just sends the embed to its final destination and skips the preview rn
guys how fix this error nextcord.errors.InteractionResponded: This interaction has already been responded to before
Oh
as the error says, you're trying to respond to an interaction that was already responded
e.g
await inter.response.send_message(...)
# some lines later
await inter.response.send_message(...)
!d nextcord.Interaction.send
await send(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, delete_after=None, allowed_mentions=..., flags=None, ephemeral=None, suppress_embeds=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This is a shorthand function for helping in sending messages in response to an interaction. If the interaction has not been responded to, [`InteractionResponse.send_message()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.send_message "nextcord.InteractionResponse.send_message") is used. If the response [`is_done()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.is_done "nextcord.InteractionResponse.is_done") then the message is sent via [`Interaction.followup`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Interaction.followup "nextcord.Interaction.followup") using [`Webhook.send`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Webhook.send "nextcord.Webhook.send") instead.
fax just find it in my code 💀
await inter.send(...)
ah i for modul
await interaction.response.send_modal(modal)
this will respond to the interaction if it wasn't responded before, otherwise it'll use the followup to send the message
so it will not work like that
you can send modal only on interaction responses
ik so i added response
yeah then it should be the first thing that you send
ah i can't do that
blame discord for this
there are any way to solve that?
mm let me check
no, but you could use a message with buttons and when a button is clicked you'll send the modal
ik ok then
@glad cradle you are helper now 😳
im trying to make my bot join a specific vc and play a specific file when a command is said, however it joins vc and doesnt play anything
i added the print debug message there, it seems like it gets stuck on vc = await channel.connect()
Do you have ffmpeg executable
oh
Yeh
i forgot about that, my bad
https://ffmpeg.org there
async def test(self, ctx):
t = randint(180, 300)
old_links = []
with open("old_links.txt", "r", encoding="utf-8") as file:
old_links = file.read().splitlines()
while True:
try:
channel = self.bot.get_channel(channel_id)
err_message = self.bot.get_channel(err_discord)
base_url = ''
async with aiohttp.ClientSession() as sess:
async with sess.get(base_url, headers={'user-agent': user_agent}) as res:
text = await res.text()
soup = bs(text, 'lxml')
title = soup.find
link = soup.find
if link not in old_links:
embed=discord.Embed(title=title, url=link)
embed.set_author(name="News")
await channel.send(embed=embed)
old_links.append(link)
with open("old_links.txt", "w", encoding="utf-8") as file:
file.write("\n".join(old_links))
else:
pass
except Exception as e:
await err_message.send("❗ News an error please check ❗", delete_after=60)
await asyncio.sleep(t)
I created a function that sends a message when a new post is uploaded. but as the number of sites increases, links are not saved in old_links.txt, so duplicate messages are sent every time when the bot is rebooted.
i tried to use the cached_messages function by referring to the docs to solve this but i can't figure it out as a beginner, it's too difficult for me to do alone. could please help me to give some advices. is discord.py a function that detects old messages in the channel?
Pretty sure wrong callback function signature
hm? await interaction.deferReply();
i dont think thats the issue though
the code/bot gets stuck before reaching the vc.play line
You should subclass the view instead of assigning callback function
And yeah one of your callbacks is sync for some reason
Add a print after .play
sorry what this error mean `nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction`
You can't clarify it gets stuck there cause code ends there 🧐
i will, but like- it doesnt even reach the print before the .play
Ah
Then print channel before connect
And you should be getting error actually
You might have improper error handler
Can be plenty of reasons, you tried sending followup to interaction that never was responded to, message was deleted before you answered etc
i see
then how to responded to a interaction btw here the code await message1.edit("**CrossServer Chat StartUp**", embed=embed) await interaction.deferReply() sleep(3) modal = Crosschat() await interaction.response.send_modal(modal)
Actually personally I hate callbacks so I did a neat thing that allows you to get which button was pressed without them, check this out https://github.com/Exenifix/disnake-bot-template-postgres/blob/master/utils/views.py it's for disnake but similar principle in dpy
You should await asyncio.sleep() instead of time.sleep()
And it's interaction.response.defer()
Not interaction.deferReply
import it
how it import it
by importing
import asyncio```
interaction.response.defer() not even working
it do nothing
it say nextcord.errors.InteractionResponded: This interaction has already been responded to before
in nextcord use this to send message:
await interaction.send()
and not
await interaction.response.send()
i sending a modal so it need response ig
Could you send full function code
Nah where you defer
it will say the interction aready call
async def buttom3_callback(self):
embed=discord.Embed(title=f"Fall Form",description=f"**You Doing Amazing!** You Did All The Steps Now Just Full The Page And the **Cross Chat** Will be **Done!**",color=0xff7d00)
await message1.edit("**CrossServer Chat StartUp**", embed=embed,view=None)
interaction.response.defer()
await asyncio.sleep(3)
modal = Crosschat()
await interaction.response.send_modal(modal)```
You probably already responded to interaction
You didn't even await defer 🧐
Yes that's first of all
does defe close the response right?
Deferring basically makes discord wait until you respond
Without deferring you have to respond within 3 seconds
well followup does not have send_modal
Who would even need to send modal in followup
does there any way to just close the call and recall make when i call the modal
🧐
Only way to send a modal with followup is to add a button to followup and then send modal in response to button interaction
Done now how make it "response to button interaction"
lmfao
When the user clicks the button, then send the modal
yes But still how.
how trigger it when i click the button.
interaction.response.send_modal(modal)
never use this before
How have you made your button?
this will say that it aready recall
i have button4_callback but the idea not here, the idea that how we gonna call modal without interaction
This is responding to the button, not the command
i need to respond before
still will face same error
Why
ah sending something
You should try it first lol
message1 = await interaction.send("**CrossServer Chat StartUp**", embed=embed, view=myview, ephemeral=True)
The interaction of the slash command and the button are different
try it before like 10 times
still give me same error
I see
no you not see
Send the code then
let em try again
this should be the call back async def buttom4_callback(self): await asyncio.sleep(3) modal = Crosschat() interaction.response.send_modal(modal)
^
Await the send_modal
like what is say
try before too
interaction.followup.send_modal(modal)?
That doesn't exist
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\view.py", line 396, in _scheduled_task
await interaction.response.defer()
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 699, in defer
await adapter.create_interaction_response(
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 204, in request
raise NotFound(response, data)
nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
... the problem is with defer()
? wait
where is defe
nvm
frist, i don't have defe, second it call interaction
Weird
ikr
Unknown interaction
werid
Can you show us the command?
all the command?
@bot.slash_command(name='crossserverschat', description="Chat Between Servers")
async def crosserverschat(interaction: discord.Interaction, option: Literal['add', 'remove']):
if option == "add":
buttom1 = Button(label="Let's Go!", style=ButtonStyle.blurple)
buttom2 = Button(label="Got It!", style=ButtonStyle.blurple)
buttom3 = Button(label="Got It!", style=ButtonStyle.blurple)
buttom4 = Button(label="Fall Form!", style=ButtonStyle.blurple)
embed=discord.Embed(title=f"Introduction",description=f"Hello And Welcome In **CrossServer Chat** Service! \u200bYou Could Chat Other Servers With This Server \u200bI Hope You Enjoy Our Service, **Let's Start!**",color=0xff7d00)
myview = View(timeout=500)
myview.add_item(buttom1)
message1 = await interaction.send("**CrossServer Chat StartUp**", embed=embed, view=myview, ephemeral=True)
async def buttom1_callback(self):
embed=discord.Embed(title=f"Step 1",description=f"You Frist Need Enable SomeThing Called **Developer Mode** \u200bBy Going **Settings\\Advanced\\Developer Mode**",color=0xff7d00)
embed.set_image(url='https://cdn.discordapp.com/attachments/1054074031642521681/1091603482013876245/image.png')
myview = View(timeout=500)
myview.add_item(buttom2)
await message1.edit("**CrossServer Chat StartUp**", embed=embed, view=myview)
async def buttom2_callback(self):
embed=discord.Embed(title=f"Step 2",description=f"**Great Job!**, Now You Need Right Click The Server that You Want **Cross Chat** With and Go Down Until You Find Something Called **Copy ID** Click at It!",color=0xff7d00)
embed.set_image(url='https://cdn.discordapp.com/attachments/1054074031642521681/1091616490576412713/image.png')
myview = View(timeout=500)
myview.add_item(buttom3)
await message1.edit("**CrossServer Chat StartUp**", embed=embed, view=myview)
async def buttom3_callback(self):
myview = View(timeout=500)
myview.add_item(buttom4)
embed=discord.Embed(title=f"Fall Form",description=f"**You Doing Amazing!** You Did All The Steps Now Just Full The Page And the **Cross Chat** Will be **Done!**",color=0xff7d00)
await message1.edit("**CrossServer Chat StartUp**", embed=embed,view=myview)
async def buttom4_callback(self):
await asyncio.sleep(3)
modal = Crosschat()
interaction.response.send_modal(modal)
buttom1.callback = buttom1_callback
buttom2.callback = buttom2_callback
buttom3.callback = buttom3_callback
buttom4.callback = buttom4_callback```
@tawdry karma got any idea how fix it?
reading
Don't make buttons like this 
And why is there a self argument in the button callbacks
Shouldn't it be interaction
i can't still rewrite all my code
That's what I am thinking
hm
waaaitt
i was got an error of something and i look at google and it say put "self" and i put it lol
Where is this located?
In your code
find it here
yep.
This is harrdd
but we need put interaction
i replace self with interaction
and wow nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
python werid 
fr
any way to solve this problem?
I know there is since I faced the same problem and did it
and what was the solve of this error?
I don't know 
Make sure you put await before your interaction response. Always
Fr
Check Code Files
I'm not on pc
check life files
alr
guys guess what
Elon musk died?
i don't even put await
bruh
Maybe 😭
ye just check rn
Ok then try code after putting await
You think it's a good idea to host discord bots for people for $2
it don't even show me any buttons 💀
@slate swan nice banner
nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
Thank You 
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Ibrah\Desktop\Code\Python\main.py", line 1493, in crosserverschat
message1 = await interaction.send("**CrossServer Chat StartUp**", embed=embed, view=myview, ephemeral=True)``` bruh
faxs
I want to send a keyboard smash gif but can't
Is that all?
`Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x00000120F3B61480>:
Traceback (most recent call last):
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Ibrah\Desktop\Code\Python\main.py", line 1493, in crosserverschat
message1 = await interaction.send("CrossServer Chat StartUp", embed=embed, view=myview, ephemeral=True)
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 564, in send
return await self.response.send_message(
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 893, in send_message
await adapter.create_interaction_response(
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 204, in request
raise NotFound(response, data)
nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:`
:0
I've seen hosting for cents
Or pennies
Everything fun and games until they os.system("sudo rm -rf /boot")
Unless you containerise
I think that I will remove it since they're spamming pings 😭😭
what
nvm
At first I thought it was legit
But then I remembered the date
Next.js affected my braincells a lot
js tends to have that effect
Depends how much profit you want and how much the hardware costs
I will containerise
hardware was like 200
async def cer(self, ctx):
while True:
try:
channel = self.bot.get_channel(channel_id)
err_message = self.bot.get_channel(err_channel)
title = "test title"
end = 'duplicate'
async for msg in channel.history(limit=1):
if title not in msg.content:
await channel.send(title, delete_after=5)
elif title in msg.content:
await channel.send(end, delete_after=5)
else:
pass
except Exception as e:
embed=discord.Embed(title="❗ error ❗", color=0xff0000)
embed.add_field(name=e, value="", inline=False)
await err_message.send(embed=embed, delete_after=1)
await asyncio.sleep(3)
i'm trying to implement a feature that doesn't send messages that are duplicates of the last message in the channel. the bot powers up with no error code, but nothing happens when i type a command. is there any mistakes i made?
Main mistake is that you have to use different method for background loops
!d discord.ext.tasks.loop
@discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
ohhh thank you i will check up
If you wanted to sell hosting at 50p and have a profit of 10 pound, you would have to have a lot of users
20000/50=4000
An year ago or so, I heard that discord is forcing slash commands
so why do some bots still work the same way as before
like, I can still use a bot like this
k!info
Why
what was that fuss about
I mean, normal commands were supposed to stop working werent they?
No
so what was that about discord forcing slash commands
They just make accessing messages' content a privileged intent
what does it mean
If i do
pip install discord.py will it automatically install discord.py 2 (I mean the version where slash commands are present)
You should prefer to use -U flag
!dashmpip
When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.
Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.
Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.
So py -m pip install -U discord.py
I dont really care about profit rn
I kinda wanna start a affordable hosting service
class Testings(commands.Cog):
def __init__(self, bot):
self.bot = bot
@tasks.loop(seconds=3)
async def cer(self, ctx):
try:
channel = self.bot.get_channel(channel_id)
err_message = self.bot.get_channel(err_channel)
title = "test title"
end = 'duplicate'
async for msg in ctx.channel.history(limit=1):
if title not in msg.content:
await channel.send(title, delete_after=10)
else:
pass
except Exception as e:
embed=discord.Embed(title="❗ error ❗", color=0xff0000)
embed.add_field(name=e, value="", inline=False)
await err_message.send(embed=embed, delete_after=1)
@commands.command()
async def test(self, ctx):
task1 = self.bot.loop.create_task(self.cer(ctx))
await task1
async def setup(bot):
await bot.add_cog(Testings(bot))
i tried to make the code with task.loop but its not working infinity loop. could you guys please check the code and advice for me?
thats not how you use tasks.loop
you should use .start() on you task
not with loop.create_task()
also task doesn't get ctx as an argument, it doesn't get any
in your command do self.cer.start()
and you can stop it using self.cer.cancel() or self.cer.stop()
hi
Hi needing some help with an embed command. I have made a ton of headway thanks to people (mudkip) here.
I am working on my final feature for this command which sends a preview of the embed into the channel that the command was issued in so the author can respond "yes" or "no" and if its yes it will post it to its destination channel, and if not it will stop the command entirely.
I am having an issue where it posts the preview embed but then based on yes or no responses it doesn't do anything....any ideas?
@commands.command()
async def embed(self, ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('Waiting for a title')
title = await self.bot.wait_for('message', check=check)
await ctx.send('Waiting for a description')
desc = await self.bot.wait_for('message', check=check)
await ctx.send('Please provide me with the image (directly paste or attach image, no need for link) for this post, if no image is needed just say none.')
news_image = await self.bot.wait_for("message", check=lambda m: all([
m.author == ctx.author,
m.channel == ctx.channel,
len(m.attachments) == 1 or "none" in m.content.lower()
]))
if news_image.attachments:
embed.set_image(url=news_image.attachments[0].url)
embed = discord.Embed(title=title.content, description=desc.content, color=0x1ABC9C)
embed.set_thumbnail(url="https://imgur.com/MJnM3LU.png")
await ctx.send('What channel should I send this in? Please provide me with the channel ID.\n- #news: 569635458183856149\n- #general-news: 803341100618219540\n- #patch-notes: 585952222853201941')
dest = await self.bot.wait_for('message', check=check)
await ctx.send('Who should I tag? Please provide me with the role ID.\n- news: 620025828079697920\n- gennews: 803343410794594385\n- patchnotes: 620025894559547412')
role_message = await self.bot.wait_for('message', check=check)
await ctx.send('What is the tag preview?')
tag_preview = await self.bot.wait_for('message', check=check)
await ctx.send('Does this look correct? Please say yes or no.')
channel = self.bot.get_channel(1065685023853920258)
await channel.send(embed=embed)
await self.bot.wait_for('message', check=check)
if "yes" in ctx.message.content.lower():
channel = self.bot.get_channel(int(dest.content))
await channel.send(embed=embed)
await channel.send(f"<@&{role_message.content}> - {tag_preview.content}")
if "no" in ctx.message.content.lower():
await channel.send('The embed has been cancelled, please try again.')
the issue code in question is the last bit which begins with "await ctx.send('Does this look correct?')"
20000/1000=20
If you charge them £10 then you need 20 users
But that is a bit expensive
I feel that it is hard to start a hosting service and be succesful with it
i dont wanna be successfull from the start
You could try get members to sign up first and then if you reach a certain member count then you launch
That is also a fair point
yeah but i think i found a bog?
This has moved from discord bot discussion to a different topic so we should change channels
import discord
import asyncio
from discord.ext.commands import Bot, has_permissions, MissingPermissions, Cog
from discord.ext import tasks, commands
class Testings(commands.Cog):
def __init__(self, bot: commands.bot):
self.bot = bot
self.cer.start()
@tasks.loop(seconds=5, count=None, reconnect=True)
async def cer(self):
await self.bot.wait_until_ready()
channel = self.bot.get_channel(channel_id)
try:
title = "test title"
end = 'duplicate'
async for msg in channel.history(limit=1):
if title not in msg.content:
await channel.send(title, delete_after=10)
else:
await channel.send(end, delete_after=10)
except Exception as e:
embed=discord.Embed(title="❗ error ❗", color=0xff0000)
embed.add_field(name=e, value="", inline=False)
await channel.send(embed=embed, delete_after=1)
async def setup(bot):
await bot.add_cog(Testings(bot))
when i use @tasks.loop and channel.history it's not working without any error codes. or it's just happening on my PC??
I haven't seen a bug in dpy in that so I don't think so

thats probably because of intents or something elsse
ohh
intents = discord.Intents.all()
intents.message_content = True
waiting until bot is ready in a task will dead lock
so your task won't go after that line
you should do this instead :
register a before_loop for your task using @name.before_loop (async function)
wait until ready in there
@tasks.loop(seconds=5, count=None, reconnect=True)
async def cer(self):
await self.bot.wait_until_ready()
channel = self.bot.get_channel(channel_id)
try:
title = "test title"
end = 'duplicate'
async for msg in channel.history(limit=1):
print('check')
if title not in msg.content:
await channel.send(title, delete_after=10)
else:
await channel.send(end, delete_after=10)
i tried to put print('check') before async for msg in channel.history(limit=1): and it's working but after async for msg in channel.history(limit=1): this line, it's not printing..
thats wierd
but consider this
yes ser
Whole VPS hosting or just dis bot hosting?
this is kind of off topic for this channel
Cause for VPS hosting you need a whole data center 😳
@cer.before_loop
async def check(self):
print('check')
await self.bot.wait_until_ready()
it's working good
What was your error again?
Personally I would avoid those @before_loops and just add await self.bot.wait_until_ready() line at the beginning of the task
yeah i tried but hmm.. i dunno what i did something wrong.
Your problem was that you were assigning callbacks to individual components instead of subclassing. You need to either subclass View and define callbacks as its methods or use my callbacks-free implementation
could you please check this code if you have free time. it's working before async for msg in channel.history(limit=1): when i check with print('check') . but after async for msg in channel.history(limit=1): this, it's not printing. trying to figure out but really hard 😦
It's as simple as
class YourCog(Cog):
def __init__(self, bot):
self.bot = bot
self.task.start()
@tasks.loop(seconds=3)
async def task(self):
await self.bot.wait_until_ready()
...
And I am pretty sure there's almost same example on docs
yeah thats why i made same as this code
Subclassing way
# command
view = YourView()
await inter.send(view=view)
# view class
class YourView(discord.ui.View):
@discord.ui.button(label="Cheese")
async def cheese(self, inter, btn): # signature might be different, I just don't know dpy
await inter.send("You picked cheese!")
@discord.ui.button(label="Pickle")
async def pickle(self, inter, btn):
await inter.send("You picked pickle!")
And with callbacks-free method
view = GenericView([
GenericButton(label="Cheese"),
GenericButton(label="Pickle")
])
await inter.send(view=view)
msg_inter, choice = await view.get_result()
await msg_inter.send(f"You picked {choice.lower()}!")
It's partially pseudocode
Alright, alright, now the non subclassing way
jesus i found a reason
i was trying to use history function to a thread not a channel
if i wanna use channel.history function, i should use while True:. if use @tasks.loop, it's not working with a thread
What 🧐
What is currently the best wrapper for Discord in Python?
I hear discord.py is revived, how is it compared to say Disnake? I am considering leaving Disnake because I was using WaveLink previously with Discord-Disnake but that is no longer maintained and Mafic seems a little limited at the present moment in terms of available functionality
NoneType: None
i am getting this error while creating a private category using my discord.py bot
try:
guild = ctx.guild
cat = await guild.create_category(name=category_name)
except:
await ctx.send('`ERROR: Unable to create category`')
return
everyone_role = discord.utils.get(guild.roles, id=1070556590505209897)
applicant_role = discord.utils.get(guild.roles, name="applicant")
admin_role = discord.utils.get(guild.roles, name='league admin')
admin_overwrite = rep_overwrite()
try:
await cat.set_permissions(applicant_role, read_messages=False)
await cat.set_permissions(admin_role, overwrite=admin_overwrite)
await cat.set_permissions(everyone_role, read_messages=False)
except Exception as e:
print(e)
await ctx.send('error')
return```
this is the code block which is generating this error
is there any ways to find the title text of embed with channel.history ??
The title of the embed. This can be set during initialisation. Can only be up to 256 characters.
i am trying to make a bot for detect old Embed message in text channel. but i think it's not possible to find text of title of old Embed message with channel.history function.
what makes you think that? you're getting an entire message object when using history, so retrieving the title should work the same as with any other message
async for message in channel.history(limit=50):
for embed in message.embeds:
print(embed.title)
or just do this
can anyone help
probably
perhaps
possibly
it depends
does anybody know why i get the error 'Embed' object has no attribute '_json'
i am trying to create an embed responding to a message, somehow all my other embeds work
has anybody experienced this error?
!code
what is your code
import discord
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_option
import aiohttp
bot = discord.Client(intents=discord.Intents.default())
slash = SlashCommand(bot, sync_commands=True)
async def fetch_image_url(session, url):
async with session.get(url) as response:
data = await response.json()
return data['data']['url']
@slash.slash(name="sadcat",
description="Generates a sad cat meme with the provided text.",
options=[
create_option(
name="text",
description="The text to include in the meme.",
option_type=3,
required=True
)
])
async def _sadcat(ctx: SlashContext, text: str):
url = f"https://api.popcat.xyz/sadcat?text={text}"
async with aiohttp.ClientSession() as session:
image_url = await fetch_image_url(session, url)
embed = discord.Embed()
embed.set_image(url=image_url)
await ctx.send(embed=embed)
bot.run('TOKEN')
there @slate swan
^ @slate swan ive linked an example, guide, and docs here, assuming you're using discord.py 2.0
discord_slash is really outdated
also don't just code someone's bot for them, that won't teach them anything
Someone knows how to solve this error?
what do your options look like
haha good look to find the command where this is happening
options of what? slash commands?
yes
they doesn't even have it xD
do you have function docstrings?
they have parameters in the command function, but not as CommandOption parameter
yup
ahah
Time to remove them xD
discord.py or whatever you're using is parsing function's docstrings and using them as descriptions
disnake
disnake my beloved
Hey @proven venture!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
read what the bot said
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
your issue is that you are doing embeds=embed1 though
yes......
TypeError: _Context.send() got an unexpected keyword argument 'embed'
embed was replaced by embeds I guess
no it was not
not in discord.py anyway
maybe in interactions
try embeds=[embed1]
AttributeError: 'Embed' object has no attribute '_json'
going through all possible errors
the same just withawait ctx.send(embeds=[embed1])
dc py 2.0?
yes
I will but since I wrote the whole code in interactions I have no motivation changing it to dc py 2.0
so no solution?
PS C:\Users\Madth\Documents\Projects\discord slash> & C:/Users/Madth/AppData/Local/Programs/Python/Python311/python.exe "c:/Users/Madth/Documents/Projects/discord slash/discord.py"
Traceback (most recent call last):
File "c:\Users\Madth\Documents\Projects\discord slash\discord.py", line 1, in <module>
import discord
File "c:\Users\Madth\Documents\Projects\discord slash\discord.py", line 5, in <module>
from discord.ext import commands, tasks
ModuleNotFoundError: No module named 'discord.ext'; 'discord' is not a package```
never got this error before, discord is fully installed, if I try to run pip install I get, Requirement already satisfied.
your file is named discord.py
oh, thanks
I have discord-py-slash-command installed but keep getting error,
Traceback (most recent call last):
File "c:\Users\Madth\Documents\Projects\discord slash\main.py", line 9, in <module>
from discord_slash import SlashCommand
ModuleNotFoundError: No module named 'discord_slash'```
see this
I think that is called interactions btw why you don't just use discord.py
i get my bots id with self.bot.user.id in a cog right?
i mean self.bot is just a variable name but yes
can someone help with jsons?
or("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I get this whenever im trying to load
try:
with open('allowed_users.json', 'r') as f:
allowed_users = json.load(f)
except FileNotFoundError:
allowed_users = []
``` (i guess?)
file only has []
You sure?
options = [discord.ui.SelectOption(label=channel.name, value=channel.id) for channel in channels]
select = Select(options=options, placeholder='Select channel(s)', min_values=1, max_values=len(channels))
Traceback (most recent call last):
File "C:\Users\**\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 842, in _do_call
return await self._callback(interaction, **params) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\**\Desktop\**\main.py", line 624, in end
await interaction.response.send_message(interaction.user.mention, embed=embed, view=select)
File "C:\Users\**\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\interactions.py", line 763, in send_message
params = interaction_message_response_params(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\**\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\webhook\async_.py", line 578, in interaction_message_response_params
data['components'] = view.to_components()
^^^^^^^^^^^^^^^^^^
AttributeError: 'Select' object has no attribute 'to_components'
any fix?
why not just use a ChannelSelect
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'end' raised an exception: AttributeError: 'ChannelSelect' object has no attribute 'to_components'```
```py
options = [discord.SelectOption(label=channel.name, value=channel.id) for channel in channels]
select = ChannelSelect(channel_types=options, placeholder='Select channel(s)', min_values=1, max_values=len(channels))```
view is supposed to be a View object, not a select
so view.add_item(select) if view = View()?
thought that was only for buttons
i mean, you tried passing the select to the view argument
but yeah
<@&831776746206265384>
In data.components.0.components.0.channel_types.0: Value "1090332444667949166" is not a valid enum value.
In data.components.0.components.0.channel_types.1: Value "1090333038459756647" is not a valid enum value.
In data.components.0.components.0.channel_types.2: Value "1090348367160295558" is not a valid enum value.
In data.components.0.components.0.channel_types.3: Value "1090377583880835172" is not a valid enum value.
In data.components.0.components.0.channel_types.4: Value "1090395131993149510" is not a valid enum value.
In data.components.0.components.0.channel_types.5: Value "1090419907075784754" is not a valid enum value.
In data.components.0.components.0.channel_types.6: Value "1090420244260069457" is not a valid enum value.
In data.components.0.components.0.channel_types.7: Value "1090420258180964413" is not a valid enum value.
In data.components.0.components.0.channel_types.8: Value "1090420275117559818" is not a valid enum value.
In data.components.0.components.0.channel_types.9: Value "1090420288623235154" is not a valid enum value.
In data.components.0.components.0.channel_types.10: Value "1090420302732865566" is not a valid enum value.
In data.components.0.components.0.channel_types.11: Value "1090420834763538603" is not a valid enum value.
In data.components.0.components.0.channel_types.12: Value "1090420894079385770" is not a valid enum value.
!pban 1091186253883506799 scam
:incoming_envelope: :ok_hand: applied ban to @young geode permanently.
thanks!
channel_types is not for the options
actually i'm not sure if you can select the options using ChannelSelect, you might only be able to select the types
e.g. text, voice, stage
so that might not be what you want
what I want is to list all textchannels (channel is an instance of discord.TextChannel) and iterate over them and put them in the select menu. The user can select as many as len(channels) but a min of 1
how to use the permission join server for you in a diacord bot?
you know the discord permission "join server for you"
how to use it to make people that accepted the permission join a server that i want
yeah just set channel_types to [ChannelType.text]
and remove your loop
you mean auth joining?
ye
idk if thats against rules here lmao
if it is against the rules why would discord allow it lol
you need a good understanding of python to do it
or just ask gpt
Anything but chatgpt
it gets the work done tho
okay
50/50 helps me organise code better
How did you come to the point where you need ChatGPT to organize your code
its faster to type code when you're not organising it. my brain just writes and then I use chatgpt to organise my code. its pretty productive and efficient
lmao bruh he just send me this
await member.send(f"Here's your invite link for {guild.name}: {invite.url}")
"ai's gonna rule the world" 💀
"your task is to allow users that click on an oauth link to give access to your discord bot to join servers for them"
okay wait
idk try that
same result lol
@grand hazel
once you've authenticated the user, send a PUT request to /guilds/<guild>/members/<member>
after submitting the text channels, it says "interaction failed" here's my code: https://paste.pythondiscord.com/usuhonicap
because you have no callback?
what did you expect to happen
there is no such event as "select_option"
how to fetch the <member> tho?
oh my...
it's just the member id
theres an event for that??
no such event
oohh
just create a new class extending View and use the select decorator
What package is currently the best for Discord in Python?
I hear discord.py is revived, how is it compared to say Disnake?
I am considering leaving Disnake because I was using WaveLink previously with Discord-Disnake but that is no longer maintained and Mafic seems a little limited at the present moment in terms of available functionality so I definitely want one that works well with some sort of LavaLink wrapper, preferably one that is full featured, any info/thoughts definitely appreciated 🙂
How is dpy after the restart? I have only just started hearing about Hikari, how is support and is there a good Lavalink wrapper for it?
aren't lavalink wrappers completely independent from the library you're using?
Yes, but not all are compatible with the given library
Wavelink for example is not compatible with Disnake
which is why I'm looking for potential alternatives to Disnake
dpy is quite complete 🤷
hmm, alright, I guess in the coming days I'll make the change over to dpy and see how it goes
any suggestions for oauth2 and flask? I just wanna get each users twitch connections, add it to a db and then send a req to decapi to get each usernames twitch_id. its for a sqlalchemy db ;.;
fastapi
Hello 👋 I am currently working on a Discord bot because I haven't worked on one in a while now and thought it would be fun. I am currently trying to implement cogs into my bot but whenever I try to use a command that is from a file inside the cogs folder it says that there is no such command...
Any help would be appreciated
Please ping me if you know how to assist me
Can you show how you're loading the cogs?
Yes
I opened up a new file and did the same thing and now its working
so idk whats up with that old file
import discord
from discord.ext import commands
from discord import app_commands
from colorama import Back, Fore, Style
import time
import platform
class Client(commands.Bot):
def __init__(self):
super().__init__(command_prefix=commands.when_mentioned_or('s!'), intents=discord.Intents().all())
self.cogslist = ["cogs.startup"]
async def setup_hook(self):
for ext in self.cogslist:
await self.load_extension(ext)
async def on_ready(self):
prfx = (Back.BLACK + Fore.GREEN + time.strftime("%H:%M:%S UTC", time.gmtime()) + Back.RESET + Fore.WHITE + Style.BRIGHT)
print(prfx + " Logged in as " + Fore.YELLOW + self.user.name)
print(prfx + " Bot ID " + Fore.YELLOW + str(self.user.id))
print(prfx + " Discord Version " + Fore.YELLOW + discord.__version__)
print(prfx + " Python Version " + Fore.YELLOW + str(platform.python_version()))
client = Client()
client.run('TOKEN')
import discord
from discord.ext import commands
import os
import asyncio
client = commands.Bot(command_prefix = "!", intents=discord.Intents.all())
client.remove_command('help')
async def load_extensions():
for f in os.listdir("./cogs"):
if f.endswith(".py"):
await client.load_extension("cogs." + f[:-3])
async def main():
async with client:
await load_extensions()
await client.start('TOKEN')
asyncio.run(main())
I also tried this way as well
both didn't work in that file and now I am in a new one and I am using the second version of the code
And can you show one of your cogs?
For sure
import discord
import os
from discord.ext import commands
class startupCog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print('Bot is up and running!')
@commands.command(name="Test", description="Sends a test response.")
async def test(self, ctx):
await ctx.send('Working!')
async def setup(client):
await client.add_cog(startupCog(client))
Are the normal prefix commands working?
And you aren't getting any errors?
Nope
only error I am getting is when I type a command
it says that the command doesn't exist
@supple cradle could you please show your files hierarchy
hierarchy?
The order?
Yeah you should open specifically Saturn-Bot folder in VSC, most likely your extensions path is just not resolved correctly due to wrong workdir
Okay, I usually do that anyway I just thought you wanted me to open it like that
Got it open
No I mean when running a script your project root folder should be Saturn-Bot
Now try running it
Could you show what command runs it
Here
I run s!test
oh ok
I am on mac so it's python3 main.py
let me send a ss
May look long but my mac name is the alphabet lol
I'll change it for better reading
/Users/zekepetherick/Desktop/Home/Projects/Python/Saturn-Bot/main.py
Screenshot
bros leaking bobux website 😳
😳
what are u using for front end vanilla or some framework?
Are you on mac or linux
Mac
Now please screenshot file hierarchy again
Next.js is based on react I think
this?
Yeah
Your root folder still isn't Saturn-Bot
still doesnt work that way
File -> Open Folder -> Saturn-Bot
I liked that yellow name 
he could also use absolute paths for the cogs, can't he?
sigh you're a booster at least
Forgot 
What am I doing wrong?
I have a button:
@discord.ui.button(label="Add note", style=discord.ButtonStyle.green, row=0)
async def add_note(self, interaction: discord.Interaction, button: discord.ui.Button):
note_ui = Note()
note_ui.bmid = self.original_ids.bmid
print(self.original_ids)
print(self.original_ids.bmid)
print(note_ui.bmid)
await interaction.response.send_modal(Note())
And that button calls a modal:
class Note(discord.ui.Modal, title='Gnomeslayers note maker.'):
def __init__(self):
super().__init__()
bmid = 0
note = discord.ui.TextInput(
label='Note for this users profile',
style=discord.TextStyle.long,
placeholder='Type the note here.',
required=True,
)
Why is the bmid not updating? It works for my buttons? D:
wrong indentation levels
no.
That's just how it pastes
nvm figured it out LOL
i think.
Yep.
I didn't realize I was submitting the base class and not the variable await interaction.response.send_modal(Note()) needed to be await interaction.response.send_modal(note_ui)
My bot's FFMPEG is not working for some reason, is there a bug right now?
youtube downloader/player?
nope, on my discord bot
bot was working perfectly but for some reason it doesnt play any ffmpeg file now. i havent touched anything
ffmpeg is a media downloader/player
yeah, it supposed be play a m4a file, thats it
oh ive never seen someone usd it in that way... always in a music bot that plays off youtube
but weird one is there is not any error or something, bot joins vc and just stands like that
Can you show your code?
I have a select menu where i have 46 options in 6 different categories. Is there any way to do this? I know the select menu has a limit of 25 and the rows have a limit of 5 so i cannot do that with the categories either
okay, i will send main one and config one
Hey @viral stump!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
https://paste.pythondiscord.com/asayeruhuh config one
bot is coming but not doing anything
where is audio_clip_filepath defined? on line 111
on config one
but you aren't importing it in your main code
check 264
oh i see
def after_play(e):
# We have to hook into asyncio here as voice_client.play
# runs the Callable it's given without await'ing it
# Basically this just calls `kick_member_and_disconnect`
asyncio.run_coroutine_threadsafe(kick_member_and_disconnect(), bot.loop)
you should handle the error in this callback instead of ignoring it
e parameter is Optional[Exception]
yo. could i possibly get some help with an error pls
i ll check it after game, ty for now
initially got this error - 'Bot' object has no attribute 'tree' so i made a tree with app_commands from discord.py but now this error occurred ImportError: cannot import name 'AppCommandOptionType' from 'discord.enums'
pls help i'm legit stuck with this for about 2 days now 😭
are you sure you don't have any other libraries installed like py-cord
also make sure discord.py is up to date; python -m pip install -U discord.py
its on the latest version so that most probably shouldn't be a problem
uninstalled pycord and nextcord too. still got the same error 😭
can you show the full traceback?
Do you have any files called discord.py?
c:/Users/DINESH/Downloads/ambarfinal/super/main.py
Traceback (most recent call last):
File "c:\Users\DINESH\Downloads\ambarfinal\super\main.py", line 5, in <module>
from discord import app_commands
File "C:\Users\DINESH\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands_init_.py", line 12, in <module>
from .commands import *
File "C:\Users\DINESH\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 51, in <module>
from ..enums import AppCommandOptionType, AppCommandType, ChannelType, Locale
ImportError: cannot import name 'AppCommandOptionType' from 'discord.enums' (C:\Users\DINESH\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\enums.py)
nope
are you sure you uninstalled py-cord and not pycord
one sec, will check 🤧
nope, still won't work
uninstalled py-cord too
would u suggesting downgrading to a lower version?
alright. one sec
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Hey guys, How to get ID of someone in discord.py I am trying to do ban command via ID
mb
looks like you have discord and discord.py installed which might be conflicting
you should uninstall the first one
anyone?
which should i uninstall?
Please elaborate, specifically whose ID are you trying to find?
Id of user
which user?
that I am going to ban
do you've a ban command? 👁️
?
and how will the code know which user that is?
Are you mentioning the user in a command?
No
Or accepting their ID as a parameter?
yeah
so are you asking how you can get a user id from the discord app?
yeah
.ban (user id)
Settings > Advanced > Developer Mode, then right click the user and Copy ID
try uninstalling discord.py too
and run your code
Not that
pretty sure u can just pass the id as an argument for the ban command
How to get that ID to work.
ah nvm
You need to be more specific with your question;
Are you trying to figure out how to add a user id parameter to the command? Or how to ban a user from their ID?
async def ban(ctx):
print(ctx.message.author.id)```
anyways getting back to my error
tthanks
nvm It didn't work
I have something like that:
async def ban(ctx, member_id: int, *, reason=None):
print(member_id)
member = member_id
if member_id is not None:
await member.ban(reason=reason)
embed = discord.Embed(title="Ban", description="Sucessful Ban")
embed.add_field(name="User", value=f"Member: {member} Id: {member_id}")
embed.add_field(name="Reason", value=reason)
await ctx.send(embed)
await client.get_channel(1073532895731400777).send(embed)
else:
await ctx.send("Something went wrong.")
I try using
.ban (user id) (reason)
and it didn't work
that's not how python works
then how it shall be
member = member_id doesn't automatically convert a user id to a Member object
that just prints the user id
you need to use ctx.guild.get_member / fetch_member to retrieve the corresponding Member object
generally you can just typehint the parameter to discord.Member
or discord.User
async def ban(ctx, member: discord.Member, *, reason: str | None = None):
...
So I want to ban members using ID, can you write me that code
that is the code
read this to see how converters work
😭
did you uninstall discord.py?
and does it give you an ImportError now?
are you sure? can you send the traceback?
one sec
if it's the same error even after uninstall the library then it looks like you have a misconfigured environment
Traceback (most recent call last):
File "c:\Users\DINESH\Downloads\ambarfinal\super\main.py", line 5, in <module>
from discord import app_commands
File "C:\Users\DINESH\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands_init_.py", line 12, in <module>
from .commands import *
File "C:\Users\DINESH\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 51, in <module>
from ..enums import AppCommandOptionType, AppCommandType, ChannelType, Locale
ImportError: cannot import name 'AppCommandOptionType' from 'discord.enums' (C:\Users\DINESH\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\enums.py)
maybe conda messed up my env
what does py -V give you?
Python 3.11.2
and py -m pip show discord.py?
didn't you uninstall it?
what does py -m pip list give you?
i did, yet it shows that
even after uninstalling pip show discord.py show's the version 😭
your pip command is bound to some different interpreter; make sure to use py -m pip from now on, or reconfigure your environment to use the correct interpreter
alright
oh damn, will check, just a sec
as well as py-cord
alright, I'll try re-configuring the environment
thanks a bunch,
you also might want to consider using venvs in the future
i should've done that fr
Yeah that's a lot of modules
funnily i set it up in a codespace and it worked 😭
tysm tho guys
at least got this issue fixed for once
will use conda in the future
Guys i want that my discord.py takes input from user for 20 seconds and stops after 20 seconds and if user send input , it should not stop taking input
How can I do that?
In what form do you want to send input
I want to take input
How
I mean text input
Wait for user to send message / send modal
Send message
!d discord.ext.commands.Bot.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.11)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.11)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.11)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
It will stop after taking input?
It stops after it gets an event that passed the check
I want to do like bot takes input for 20 seconds if user send hi then it will again take input and till user don't send hello it should take input, how to do that?
Or timing out
Is it possible to add check for it?
Ok I'll see
there is the timeout kwarg, it will wait until the timeout and if finds the message it stops else it raises asyncio.TimeoutError so you should wrap it in try/except
but as asher said using a modal is a better way to get input from user
Can someone please dm me? I'm having an issue with my bot where the unlock command overwrites private channels
agreed, since I feel like your "request / reply" is like some sort of form you have to fill in
more eyes see more bugs, it's preferred to show everything in help channels
Ive tried that but it got archived bc no one answered
then that's probably because of the way you ask your question
make sure everything the bot asks (first message in a thread) is answered
my question met all the requirements the bot had put in the thread
alright ill try again
guys how get ID of server owner not the server that i do a command a server that i enter there ID
any one know?
you have the guild object, right?
i have guild ID
so you just want the owner's user ID of the guild where a command was used?
if so, and you're using a "normal command"
it's ctx.guild.owner.id
where a commnand without used
rephrase your question and explain the use case
ik that code i like ex: i rn enter server Id that not the server that i In rn I want get the owner ID of this Server THat I enter it ID
yes 100% yes how run a bot command without a bot 💀
you first get the guild object by using get_guild()
then you just use .owner on that guild object to get the owner's member/user object
did that!
proof?


