#discord-bots
1 messages · Page 914 of 1
how do I delete an embed
x on left or del the message ||basic discord things||
i dont know
say I sent an embed then I want to delete it
you can delete the message?
you can add delete_after to send() if you want it to be timebased n autoremoved
nono
I want after you sent a message
to delete the message and the embed
then make a new embed
Save the object
edit message?
I've only been coding this bot for about a couple months
I'm not used to all these terms
old_msg = await ctx.send('Hello!')
# Do your stuff
await asyncio.sleep(10)
await old_msg.delete()
uugh
I don't want it to wait tho
await ctx.send('Hello!', delete_after=10)
after the message is sent, it should automatically delete the message and embed
It was an example
i saw https://discordpy.readthedocs.io/en/stable/api.html#discord.on_member_join
but how to i get the guild which he joined?
is there any solutions?
Then use OOP
...
afaik not nextcord and dispy i haven't used.
!d discord.Member.guild
The guild that the member belongs to.
thanks
@delicate horneta hint: Member -> represent a user as a memberobject in that guild its being called in
Aka Member is a subclass of User
^
yeah remember that some methods from User object are not available for Member object
Then why send it in the first place
a classic example would be seen between those two events:
^ Member is a server member. User is a Discord account
because the message is saved as a variable and the variable is used in the new embed made
!d discord.on_member_update
discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.
This is called when one or more of the following things change:
• nickname
• roles
• pending...
!d discord.on_user_update
discord.on_user_update(before, after)```
Called when a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") updates their profile.
This is called when one or more of the following things change:
• avatar
• username
• discriminator...
@supple thorn
I’d wrap this into a small async closure and run it as a task
So it doesn’t wait 10 seconds AFTER doing the work
Which message
With what he want's to do i'd use a database.

Isn't he only using it as a variable to put in another embed in the command?
And if he restarts the bot he'd lose the variable.
Does he want to keep the data for longer?
coke you are confusing me
I'm confused of what you want
I'll make a timeline
Most likely since the embed can exist for a long time if he doesn't edit it.
Alright
I haven't read that far up
user sends command
bot sends embed
user sends message
user's message is saved as variable
bot deletes message and embed
bot sends new embed containing variable as description
Wait huh, shouldn't it be vice-versa since a member is a user too
5min+ == database
Shouldn't it be "User uses the command"
sure
user uses command
bot sends embed
user sends message
user's message is saved as variable
bot deletes message and embed
bot sends new embed containing variable as description
User invokes the command
the user sends a message that triggers the command
Using "used" since he said earlier he isn't used to all these terms
you can use the wait_for() method to handle listening for their response
Nvm
I know what invoked means
So applications.commands in scope when invite bot... but how i get this when i let bot create server? ^^,
Good job
Check the doc, dunno if number of method and parameters are the same but are different
but the bot I am not used to
Actually she's correct
class Member(User, ...):
. . .

Member is a subclass of User
yeah xD
what library are you using?
None
so I tried this
@client.command(name="idea")
async def Discord(context):
def check(message):
return message.author == ctx.message.author and message.channel == ctx.channel
questions = [
"What have ya got?",
"Hit me with it!",
"Oh, this should be good!",
"Ah! Well, spit it out man!",
"What have ya now?"
]
random_question = random.choice(questions)
embed4 = discord.Embed(title=random_question, description='Idea goes here', color=0xf5d087)
embed4.set_footer(text='Thanks for the idea!')
msg = client.wait_for('message',check=check)
await msg.delete()
await embed4.delete()
embed5 = discord.Embed(title=random_question, description=msg, color=0xf5d087)
await context.message.channel.send(embed=embed4)
and It doesn't work
User has all the methods that a Member has, since, common sense says that every client is a user
For how long would you want to keep the user's message?
what?
I guess for 1.5 seconds?
wdym none you cant reference the source of nothing
Then you probably don't need a database
no I want to save the variable and keep it in a file
Nope, you can't get the discriminator of a Member object lol
Use a database
wait_for should be awaited but otherwise that looks alright
but it didn't work
It was meant as an example, dpy does that
no it doesnt
in 2.0 this is the output ```py
issubclass(discord.Member, discord.User)
False```
they subclsss the same abstract class
was there an error?
yes
can u send it
Ignoring exception in command idea:
Traceback (most recent call last):
File "/home/aydan/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "Bot.py", line 199, in Discord
msg.delete()
AttributeError: 'generator' object has no attribute 'delete'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/aydan/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/aydan/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/aydan/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'generator' object has no attribute 'delete'
discord/member.py lines 252 to 255
class Member(discord.abc.Messageable, _UserTag):
"""Represents a Discord member to a :class:`Guild`.
This implements a lot of the functionality of :class:`User`.```
and my code is
@client.command(name="idea")
async def Discord(context):
def check(message):
return message.author == ctx.message.author and message.channel == ctx.channel
questions = [
"What have ya got?",
"Hit me with it!",
"Oh, this should be good!",
"Ah! Well, spit it out man!",
"What have ya now?"
]
random_question = random.choice(questions)
embed4 = discord.Embed(title=random_question, description='Idea goes here', color=0xf5d087)
embed4.set_footer(text='Thanks for the idea!')
msg = client.wait_for('message',check=check)
await msg.delete()
await embed4.delete()
embed5 = discord.Embed(title=random_question, description=msg, color=0xf5d087)
await context.message.channel.send(embed=embed4)
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
in 1.7 sure, in 2.0 they subclass _UserTag which isnt really an abstract class, and in both versions Member isnt a subclass of User, they just inherit from the same base
lmfao
You awaited it right
awaited what
Like that's just the old code
wait_for should be awaited
wait_for
i need something like on server boosted
At least no error
no
i believe you can listen for on_member_update(before, after) and check if .premium_since goes from None to a datetime
or at least check if they received the booster role
!d discord.Embed
the description field handles that
return message.author == context.message.author and message.channel == context.channel```
you passed context not ctx
um
can someone tell me how to wait and not pause the bot?
asyncio.sleep
u put context as an argument
did you send a second message? your embed4 wasnt initially sent so your command goes directly to listening
I'm an idiot
where does that came from? discordpy or builtin?
oh i didnt even notice you wrote embed4.delete()
It comes from asyncio
asyncio module
but I awaited it
you defined embed4 as a discord.Embed, not an actual message
to me?
on my part
Yea
hpw do i use that?
I got somewhere
it sends the embed
then I sent my message and it gets deleted!!
but agaion
wait
await asyncio.sleep(<no. of seconds u want to delay it>)
you call delete on the Message object given to you when you sent the first message
uhhh
does asyncio.sleep has some sort of timeout or i can likely add a year of time and it will runs anyway? xD
await something.delete()```
yknow, py message = await ctx.send('boo') ... await message.delete()
oops
ok and how do i run the function after he has waited?
ah alright
thats what i was trying to do lmao
thanks
print("e")
await asyncio.sleep(3)
print("f")
e comes first
does that just pause the bot?
yes
yes, pauses the whole bot
IT PARTIALLY WORKS
also dont forget to use the new embed you created when sending the second message, cause you still have the argument embed=embed4
it sends the message ID
realised that too
usrid = re.findall(r'<@!\d*>',tops)
usrxp = re.findall(r'`\d*`',tops)
print(usrid)
for item in usrid:
print(item)
if item != '<!701802881962999918>':
requests.post(domin + subdomin + '953662975401656400' + "/messages", data={"content": f"give {item} {usrxp[i]}"}, headers={"authorization": TOKEN})
break
how can I use i (indicator of for loop as usrxp index)?
this throwing me error
BUT IT ALMOST WORKS
i wanted to not do that and
import time
time.sleep(5)
works too i think
wait_for('message') returns a Message object, so you need to access the .content of it
now, I want the text. Not the id
ok
could you help me with this?
I can't compute what you said
hm
the msg variable you have is a Message object, which is not the actual string of text that you sent
ooohhh
You shouldn’t use time.sleep
the .content attribute is where that text is stored
could you supply an example
why? and why is that other better?
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
time.sleep is blocking so basically it means the bot won’t be able to respond or do anything else. asyncio.sleep only blocks the current command so the bot can respond and keep working
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else.
``` most important part, bot will not react for x amount of time.
message = await bot.wait_for('message')
length = len(message.content)
print('someone sent a message that is', length, 'characters long')```
ok
for a minute i thought they where the same
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
okay? nothing wrong with using multiple arguments for print
And extra vars?
how do i make that my acc sends an message to a channel
I tried everything
noting wkrkd
We don't allow that here, that is against ToS
aw dam i just wanted to test it on my testing server
so if I just wanted to do
msg = await client.wait_for('message',check=check)
message = msg.content
or
msg = await client.wait_for('message',check=check)
message = msg.content()
first one
alright thanks
not a function
if extracting a variable makes the code more readable than inline, why not
method/ functions/ classes can be callable, attributes are without call ()
IT WORKS
lmfao
THANK YOU GUYS SO MUCH
🎉
🎊
🧠
hi
in a bot
** hi**
I understand how to do it in normal messaging
It's the same
same for bot
even if it's a variable?
Yeah it's in a string, still text
yeah
yes
as long as it's a string, it's text
hm
bytecode
how would I add that
@client.command(name="idea")
async def Discord(context):
def check(message):
return message.author == context.message.author and message.channel == context.channel
questions = [
"What have ya got?",
"Hit me with it!",
"Oh, this should be good!",
"Ah! Well, spit it out man!",
"What have ya now?"
]
random_question = random.choice(questions)
embed4 = discord.Embed(title=random_question, description='Idea goes here', color=0xf5d087)
ideaEmbed = await context.message.channel.send(embed=embed4)
msg = await client.wait_for('message',check=check)
message = msg.content
await msg.delete()
await ideaEmbed.delete()
embed5 = discord.Embed(title=random_question, description=message, color=0xf5d087)
embed5.set_footer(text='Thanks for the idea!')
await context.message.channel.send(embed=embed5)
where to add
the description of embed5
ok
description=f"**{message}**"
yes
lol
IT WORKED
enjoy
alright
alr ima log off
.mention on a member
I'm gonna assume it's something simple
if u have the id of the member
u can ping someone like this
<@id>
nice
I'm gonna go play some minecraft now
how do i open a file for discord.File
have a wonderful day
lol
i have no idea abt that
!d discord.File
class discord.File(fp, filename=None, *, spoiler=False, description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/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/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
that doesnt help
what do u mean by open a file?
u mean like send it?
yes?
ive tryed
there was code!
can u send the error
Ignoring exception in on_ready
Traceback
Qin2007's test place
the guild doesnt have a channel set s default
This is not a Modmail thread.
wrong channel, also it's simple python tbh
now it does and
Traceback
same code
well, it isnt set
oh sorry, ik its simple but can u tell logic in #help-carrot ? 
on discord or in my code?
discord
if not interaction.guild.voice_client.voice: ```Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
return await self._callback(self.binding, interaction, **values) # type: ignore
File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 516, in _play
if not interaction.guild.voice_client.voice:
AttributeError: 'NoneType' object has no attribute 'voice'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'play' raised an exception: AttributeError: 'NoneType' object has no attribute 'voice'``` i am trying to swich to 2.0a but i can not figer this out can i get some help
when i go to the server settings i find that its set
The bot isn't inside a voice channel
uh, then it cant get the system_channel
Add an if statement to check if voice_client is None
i can not import the discord library...
this problem has arisen for me recently...
please help me...
if its None then the bot should join the author channel or something like that
install the library
!pypi discord.py
i have installed it!!
Then restart vsc?
yes
when using the join i get that tho
is the python discord bot open source?
Just check guild.voice_client
!src
@sly hamlet this
do not have a solution to my problem ??
Idk tbh, that should work 🫂
guys, the forbidden check. its work on normal word like: hi, bye but dont work on special word like: chào.
how to fix it?
Yes, but it does not work, it was ok until yesterday😭
@maiden fable
Add those words manually
Reinstall it?
wdym?
interaction.guild.voice_client.voice insted if this i need guild.voice_client????????
i did it but still not work
Show
wait, wdym? add on forbidden file or do like : if message.content == "":
I reinstalled both Python and VSC
Y
😭😭
@maiden fable
Well just install em again:)
I'm recently working with Python, i do not know what venv is
@slate swan mind helping @proper acorn?
!d venv
New in version 3.3.
Source code: Lib/venv/
The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.
See PEP 405 for more information about Python virtual environments.
I gtg rn
what about this??
Do i have to install this??
so i have interaction.guild.voice_client.voice insted of this i need just guild.voice_client?
New in version 3.3.
Source code: Lib/venv/
The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.
See PEP 405 for more information about Python virtual environments.
Ignoring exception in command 'join':
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
return await self._callback(self.binding, interaction, **values) # type: ignore
File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 323, in _join
if interaction.guild.voice_client.voice:
AttributeError: 'NoneType' object has no attribute 'voice'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'join' raised an exception: AttributeError: 'NoneType' object has no attribute 'voice'```
property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
join a vc
@app_commands.command(name='join')
async def _join(self, interaction: discord.Interaction):
"""Joins a voice channel."""
destination = interaction.user.voice.channel
if interaction.guild.voice_client.voice:
await interaction.guild.voice_client.voice.move_to(destination)
return
interaction.guild.voice_client.voice = await destination.connect()
await interaction.response.send_message(content=f"Joined :)")``` command
So do you have a solution for me??
join a vc
if not hasattr(interaction.guild, 'voice_client'):
...
i am just trying to move from 1.7.3 to 2.0a
but how do i fix this?
I did not get🥲
ok
still the same thing
Ignoring exception in command 'join':
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
return await self._callback(self.binding, interaction, **values) # type: ignore
File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 323, in _join
if interaction.guild.voice_client.voice:
AttributeError: 'NoneType' object has no attribute 'voice'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'join' raised an exception: AttributeError: 'NoneType' object has no attribute 'voice'```
All I'm trying to do is join a voice channel with that command
It's been close to 2 years since I touched this file
try this py if interaction.guild.voice_client is None: #join the channel?
I made a bot, but the generated invite link doesn't make it join my server. Any ideas?
it brings me to the authorization page, but when I click to add the bot the page closes and the bot doesn't join
broken ig
The page closes?
!d code for making a discord bot looolloloollool
Source code: Lib/code.py
The code module provides facilities to implement read-eval-print loops in Python. Two classes and convenience functions are included which can be used to build applications which provide an interactive interpreter prompt.
Huh?
it not really closes, but it brings me to the page I set as redirect url
but the bot doesn't join my server
nope
Mind giving me the link?
Does it give errors or something?
Ignoring exception in command 'join':
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 457, in _invoke_with_namespace
return await self._callback(self.binding, interaction, **values) # type: ignore
File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\testmusic.py", line 324, in _join
await interaction.guild.voice_client.voice.move_to(destination)
AttributeError: 'NoneType' object has no attribute 'voice'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 476, in _invoke_with_namespace
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'join' raised an exception: AttributeError: 'NoneType' object has no attribute 'voice'
how to import data and send from a .txt file using python
Have u tried this? @sly hamlet
yes this is what i have in rn ```py
@app_commands.command(name='join')
async def _join(self, interaction: discord.Interaction):
"""Joins a voice channel."""
destination = interaction.user.voice.channel
if interaction.guild.voice_client is None:
await interaction.guild.voice_client.voice.move_to(destination)
return
await destination.connect()
await interaction.send(content=f"Joined :)")```
i really dont know how to connect to a voice channel but ig move_to moves the client to another channel but if its none then it will raise an error?
idk tbh🫠
how to import data and send from a .txt file using python
@sly hamlet instead of move_to try join_voice_channel?
It will raise an error ?
Bc there is move_to? 
Hey, I have this issue for a while now and it's really annoying. Basically I use the pillow library to do image manipulation. But when I set an anchor (let's say to the right) nothing happens. The weird thing about this issue is that the anchor works on repl.it, but somehow not on my computer. I am on linux, Python: 3.8.10 and the most recent version of pillow. ```py
draw.text((1200, 200), f"{xp}/{goal}", anchor="ra", fill=c, font=font2)
await move_to(channel, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Moves a member to a new voice channel (they must be connected first).
You must have the [`move_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.move_members "discord.Permissions.move_members") permission to use this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.edit "discord.Member.edit").
Changed in version 1.1: Can now pass `None` to kick a member from voice.
it woked what did u do?
He used move_to...?
allredy had that
!d discord.Guild.voice_client
property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
So applications.commands in scope when invite bot... but how i get this when i let bot create server? ^^,
?
yeah how i make so my bot is able to create slash cmmands in a server he made create_server()
!d discord.ext.commands.Bot.create_guild
await create_guild(*, name, icon=..., code=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
Bot accounts in more than 10 guilds are not allowed to create guilds.
Changed in version 2.0: `name` and `icon` parameters are now keyword-only. The region` parameter has been removed.
Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
theres no way to add applications.commands scope to bot once already in server? (Bot.create_guild)
Why do bot needs servers
cause i want bot to be above all
well it already is i just wish it could register slashcommands
I mean that exists but i believe that if the voice_client.voice is None then it wont work? Idk tbh
voice_client has a voice attribute?
Look at that
what
its okay
nothing wrong
oh wait
nah i mean there is voice_client.voice
yeah
didnt see that, Im blind
Hunter 😔
Tucking Fypos


!d discord.Guild.voice_client
property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
Well 👀
!d discord.Member.voice
....
property voice```
Returns the member’s current voice state.
I'm old 
Oh i see🫂
it did?
how many roles can a server have?
No way
Just spam the API until u get an HTTPException or smth
😄
250
damn thats alot
Indeed
Yep
i was more expecting like 50-100 max
Anyone know how to do by example 10000 = 10k?
No
divide?
Or that
would w = await create_webhook(*, name, avatar=None, reason=None) create a webhook to use await w.send("Hello")
yea
well how to delete it then
!d discord.Webhook.delete
await delete(*, reason=None, prefer_auth=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes this Webhook.
alright
Command raised an exception: NameError: name 'create_webhook' is not defined mm
Can i see ur code?
https://stackoverflow.com/questions/579310/formatting-long-numbers-as-strings-in-python take a look here basicly divide with 1000....
@slate swan
!e
a=1000000
b=str(a/1000)
print(b+'k')
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1000.0k
Try ctx.channel or add a channel param in ur command
yes
you need to specify wich channel the webhook is gonna be posting in (belongs to)
ohk
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: startswith first arg must be str or a tuple of str, not bytes
w = await ctx.channel.create_webhook(name="Webhook", avatar=ctx.author.avatar.url)
!e
oof = ["guy1":10,"guy2":20,"guy3":30]
for el in enum(oof):
print(el)
@gaunt ice :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | oof = ["guy1":10,"guy2":20,"guy3":30]
003 | ^
004 | SyntaxError: invalid syntax
@gaunt iceyou need {} instead of [] when its a dict
dict = {}
list = []
!e
oof = {"guy1":10,"guy2":20,"guy3":30}
for el in enum(oof):
print(el)
@gaunt ice :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | NameError: name 'enum' is not defined
!e
oof = ["guy1":10,"guy2":20,"guy3":30]
for el in enumerate(oof):
print(el)
@gaunt ice :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | oof = ["guy1":10,"guy2":20,"guy3":30]
003 | ^
004 | SyntaxError: invalid syntax
Bro
!e
oof = {"guy1":10,"guy2":20,"guy3":30}
for el in enumerate(oof):
print(el)
@gaunt ice :white_check_mark: Your eval job has completed with return code 0.
001 | (0, 'guy1')
002 | (1, 'guy2')
003 | (2, 'guy3')
#bot-commands exists
IM SRY

@gaunt iceor u can do this too
oof = {"guy1":10,"guy2":20,"guy3":30}
for o in oof:
print(o)
print(oof[o])
.items() too
can you guys help me with dictionaries too please?
wish i could help
but i cant cause idk
things = {
'key1': 'value1',
'key2': 'value2'
}
for key, value in things.items():
print(key, value)
I have a bit of a problem with this if statement, it does nothing no error nothing
can u help me in one thing
oh ok so it returns false
but idk why the items are in there
mb do I need to specify somehow that they are variables?
@slim ibex
up above
..
What's in the dict
Can you print it
If i don't respond i might have fallen asleep cause it's 12 am
whats the dict look like
^
sorry im distracted rn lol'
its defined in the code db['dict] = {user:uuid}
no
you are setting the key dict to the value { user: uuid }
what does the db dict look like? it seems like that it might be a replit db or key value db
its a replit db
so what are you trying to do again
is there any way to see what the replit db looks like inside?
yeah so I am just trying to see if the key and value are in the the dict and if so print some thing and if not just add them to the dict
keys()```
Return a new view of the dictionary’s keys. See the [documentation of view objects](https://docs.python.org/3/library/stdtypes.html#dict-views).
!d dict.values
values()```
Return a new view of the dictionary’s values. See the [documentation of view objects](https://docs.python.org/3/library/stdtypes.html#dict-views).
An equality comparison between one `dict.values()` view and another will always return `False`. This also applies when comparing `dict.values()` to itself:
```py
>>> d = {'a': 1}
>>> d.values() == d.values()
False
it should be possible with dict.items() but the problem is that it probably thinks its a string and its a variable
!d dict
!d dict.items
items()```
Return a new view of the dictionary’s items (`(key, value)` pairs). See the [documentation of view objects](https://docs.python.org/3/library/stdtypes.html#dict-views).
Is this channel the right place to ask for help to solve a problem I have with coding a discord bot ?
How to set avatar for a webhook
yes
Great
So, I am a very beginner in coding in general, I am currently coding a discord bot with a friend who has more experience than me. The bot we are coding will be used (if we actually complete it KEKW) for a game-server, it's a game played exclusively and entirely on 1 discord server through text and commands.
In this bot, there is a >move command, usef by players to go from an area to another.
The movement time must be 1 hour, the player must be able to turn back at all times, and must know his progression on the road.
One of my ideas was to do some sort of loop, adding 1 to the timer every second, to keep a high precision on timers (timing precision is VERY VERY important for our game)
--> Problem is, I think a 1 second loop is very not optimized, may take alot of ressources from our bot, may cause crashes and stuff, I don't know stuff about bots but I think it isn't a great idea.
Help I need: Is a 1 second loop safe to use (Potentially 60 of these loops will be active at a time since there may be 60 players moving at once))
If the 1 second loop isn't safe, what other thing could I use please ?
May I ask a question?
If you are a major beginner, I wouldn't do a Discord bot. I would learn the language before doing so. But, I guess your friend can help you
alright, I really appreciate your comment but I would like some help with my problem please
if there is a loop, that updates one time per second, your bot might eventually get rate limited
i really have to agree with him/her if you want to drive a car you can't start with races you have to learn the basics first
do cogs work if you are using client?
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
for logs system, webhooks are better than normal bot msgs?
why would webhooks be better?
hello. who knows how to use LeoCAD
not really sure on that sorry
wuts that
hmm k
I love legos. I know. it sounds weird.
probably

since webhooks aren't connected to your bot

contact_sent = await ctx.respond(f"Hey **{ctx.author}**, Thanks for contacting us! Type: `{type}`. We will do everything possible to improve our bot\n**The dev team will contact you shortly thru the bot!**", ephemeral=True)
try:
await contact_sent.add_reaction(settings.emojis.proceed)
await contact_sent.add_reaction(settings.emojis.error)
await self.spooky.wait_for("raw_reaction_add", timeout=86400)
await ctx.author.send("test")
except asyncio.TimeoutError:
await ctx.author.send("Nobody replied")
i have a question about this
why is this not working?
like is not even adding the reactions
What does mapping means here?
It's a dictionary
Basically the same thing as cogs: dict[str, Cog], meaning cogs is a dictionary with str keys, and Cog values
Ohk thanks
!d typing.Mapping
class typing.Mapping(Sized, Collection[KT], Generic[VT_co])```
A generic version of [`collections.abc.Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping "collections.abc.Mapping"). This type can be used as follows:
```py
def get_position_in_index(word_list: Mapping[str, int], word: str) -> int:
return word_list[word]
``` Deprecated since version 3.9: [`collections.abc.Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping "collections.abc.Mapping") now supports `[]`. See [**PEP 585**](https://www.python.org/dev/peps/pep-0585) and [Generic Alias Type](https://docs.python.org/3/library/stdtypes.html#types-genericalias).
How to set a avatar with url for Webhook
webhook = TextChannel.create_webhook (name="uwu", avatar=byte_format_of_url_image)```
bytes?
How to covert to byte
!d discord.TextChannel.create_webhook
await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a webhook for this channel.
Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
Changed in version 1.1: Added the `reason` keyword-only parameter.
!d discord.Webhook.send
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using the webhook.
The content must be a type that can convert to a string through `str(content)`.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects to send.
Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
ah, the url is in the send method
O
Uh....use bytesIO
Vice versa
Damn just found a easier way
Ash gonna explain u since she is well versed with the same
Nvm I'm dumb
And I am sleepy
Sleep
Gotta find it first
Wish you the best
Thanks
you can just import utils and do utils.something for example utils.defalt or utils.HelpFormat
pov u are just starting to learn py
i can send u the src ?
i have a code of 5000 or more characters, how do i get help
discord creates a text file
and python (bot) doesnt what that
py is ez
depends
python was made with C and is used for anything like its a genersl language, C is kinda old but the father of most lans, C++ is hard syntax wise but is a good language
!paste
Pasting large amounts of code
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.
i saw that too
how does that work
explain that first
and how do i delete it?
you dont?
@slate swan are u good at py ?
i dont want my code on the internet forEver
1year of experience so idk
it probably gets delete
what did I just read
and why bruh your code can always be better
which message😳
'I don't want it on the internet'
oh
It literally gets wiped after some time
and it can always be done better lmao
And I don't think a random dude will type in that link😅
frrr
Its coding night
2pm
8 pm
oof
what does the just text button?
Wdym?
im going to another channel for that
I don't get your question
best nights are its just you, its raining youre eating your favorite snacks and soda, and you had a good day and youre listening to music chilling and programming and you never get a bug
Exactly! And after you have a really good dream
My dream of last night pushed me through today
!ot impossible
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
but then you wake up and its all a dream because life sucks
Exactly... I dreamed of having a girlfriend
. Lets move to an off topic channel
i had a nightmare that i started coding in replit scariest nightmare ive had😳

🏃
async def status_task1():
while True:
guild = client.get_guild(798003352108793886)
member = guild.get_member(919286280406331502)
nick1 = "x"
nick2 = "y"
await member.edit(nick=nick1)
await asyncio.sleep(2)
await member.edit(nick=nick2)
await asyncio.sleep(2)```
Why won't it work?
Error `Traceback (most recent call last):
File "c:\Users\Mini\Documents\bot.py", line 27, in status_task1
await member.edit(nick=nick1)`
replit isnt bad
shit posting rn🗿

Send full traceback please
where are you getting member from and that code is just screaming (ratelimits)
replit is bad as a hosting server for discord bots
its not bad if seen from an online ide pov
im getting it by id
Hello guys, Im testing discordpy v2 and I have a problem
I want to add slash commands to my bot but I don't know how to do that
This is my test (cog) file ```py
class Test(commands.Cog):
def init(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print('connected')
@commands.command(aliases=['test-call'])
async def _test(self, ctx):
view = MyView()
await ctx.send('fuck you', view=view)
@app_commands.command(name="test2")
async def my_top_command(self, interaction: discord.Interaction) -> None:
await interaction.response.send_message("teeeeeest")
async def setup(client):
await client.add_cog(Test(client))
and there is my main file```py
intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix='/', intents=intents)
async def load():
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await client.load_extension(f'cogs.{filename[:-3]}')
async def main():
await load()
await client.start('')
asyncio.run(main())
Traceback (most recent call last):
File "c:\Users\Mini\Documents\bot.py", line 27, in status_task1
await member.edit(nick=nick1)
AttributeError: 'NoneType' object has no attribute 'edit'
true, using 3.8 in 2022 is so awesome
Member can't be found
ah yeah just saw that
!intents and make sure the id is correct
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot 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
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
the member is none lol
worst prefix possible
?
/ prefix
I mean, its not bad, most people who are advanced at python, probably wont use replit as their ideal ide ofc
I used !, so what?
stop childish
but the id is correct

slash commands :)
how is that childish
Bot.get_member ig
/prefix > slash commands imho
=D
get_user(id, /)```
Returns a user with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
@void wyvern
shit posting rn hunter😔
I am half asleep
ah my fault hun😳
why is this leading my to a dangerous site suddendly?
What?💀
bro what
I dunno what kind of virusses you got if that leads you to a dangerous site
my virus scanner says that
Meh
that free virus cleaner is on something

Sad
I was like why doesn't this chocolate melt, take it out of my mouth, was shiny and gray😕
Hehehe
this man just said melted toblerone
Anyways, take this to an ot before I do the ot command 😔
who eats melted chocolate 🗿
My mum left it in the sun 
I don't wanna bother mina and the warn command
get another one
Still got a fresh one
keep it in the fridge, and that is my cue to end this convo
freezed chocolate > melted chocolate
😔 #ot2-never-nester’s-nightmare please
async def status_task1():
while True:
id = 919286280406331502
member = Bot.get_member(id)
nick1 = "x"
nick2 = "y"
await member.edit(nick=nick1)
await asyncio.sleep(2)
await member.edit(nick=nick2)
await asyncio.sleep(2)```
is it now right?
while true 👀
Do you use bot
RATELIMIT OOF
yes and its also blocking
what else
i know i change it later
What's ur commands.Bot variable
client = discord.Client()
Bot = commands.Bot(command_prefix="!")
Only use 1. Remove discord.Client stuff
okay
And you use Bot
POG
Bertie u from USA?
dont name your bot instance with UpperWord
Sorry, I am half alseep
😂
usa😔
Are all Americans stupid?
you calling me stupid
I asked
idk im not all americans
Well, if each Indian is a genius and every American is stupid, then I am an American and, in no way, related to India or Indians
hunters indian accent 😩
When I hear Indian there is a vocal in the back of my head singing scammer scammer scammer
whats wrong?
thats racist 
Stop with the stereotype 😔
Not meant racist :(
Let’s stay on topic please
hunter don't you act like a scammer and try to scam me?
whoops
🗿
Lets listen to Robin guys
Yeah guys listen to me 🗿
No
Anyway anyone need help?
i dont listen to people whos name starts with an R its not like my real name starts with an R
👀 Explains why u don't listen to me
Anyways #ot2-never-nester’s-nightmare
https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120#interaction-with-aiohttp think we should all consider this
when do i
sometimes
let me see
please dont use that language
Very interesting. Maybe setup hook can be used as an actual on ready
good thing im not in bot dev anymore
okay make me a discord bot feature challenge
rule: no database needed
or if I've done it already, I won't do it again
Same
lol
I dunno what that is
bot dev is boring now
that too
.help
same old same old
god sir thingy doesn't have many stuff

.topic
Suggest more topics here!
it's always the same question bro
oh this is it
do NOT force slash commands onto us
now who does this help, really
can I aska git question? I am having trouble pushing my python code to my git repo (I am making a discord bot and pushing it to heroku but git is the problem)
my toaster is broken, do I ask a carpenter how to fix it
you can always use discord.utils.get
channel = discord.utils.get(guild.channels, name=...)
probably member.guild.channels
Though its probably best to use IDs unless using name is required
if str(message.author.id) in db:```
anybody know why it gave me "TypeError: argument of type 'NoneType' is not iterable"
or maybe you make an event for guild updates and check if your channel's name got updated to change it back
that's a real chad solution right there
did you get this error on this line?
yes
Idk if this helps but
db is probably none
wait I have to try this out
Try storing the string version into another variable
oh so it's not the authorid that's the problem it's the db
And using that one,don't know if it's gonna help.
!e
if "hello" in None:
print("hello indeed")
@cold sonnet :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: argument of type 'NoneType' is not iterable
yeah, db is None
damn probably because I'm trying to use replit's database in VSC
Use a db that isn’t replit’s
repl 😿
know what that acts exactly like replit's?
Just don’t use replit in general
What does “acts” mean
yeah that's why I'm swapping to VScode
love u
like it works the exact same code wise
just switch to an RDBMS
For all we know replit db is just a thin wrapper around the json library
what
like
from replit import db```
what could I replace the word "replit
what's that
you will have to learn SQL, unless you do NoSQL
with
That’s not how a db works…
worked when I used replit
Relational database management system
what da
Because it’s builtin to replit. An actual database requires setup on some website and creation of the database
you mean postgres asyncpg go boom
ey it's storing 12 birthdays now
it's functioning 😄
bro I'm the youngest there....
!d discord.Client.latency
property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
Can someone please tell me for what I could use the Guild Presences Intent? Like for what command it would be use full?
Sorry for this question!
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
minutes, seconds = divmod(error.retry_after, 60)
await ctx.send(f"**Nem használhatod ezt a parancsot még {minutes} percig és {int(seconds)} másodpercig!**")
elif isinstance(error, commands.errors.MissingRequiredArgument):
await ctx.send(f"**A <{error.param.name}> paraméter hiányzik. A típusa {error.param.annotation} kell legyen.**")
elif isinstance(error, commands.errors.BadArgument):
await ctx.send(f"**{error}\nAzt jelenti rossz az egyik paraméter típusa. Rossz vagy.**")
else:
await ctx.send(f"**``{error}``\nA felső hiba le lett mentve az adatbázisba és átnézésre vár.**")
print(
f"""
{error}
a felső hiba a következő soron történt: {error.__traceback__.tb_lineno}
a következő fájlban: {__file__}
"""
)
__file__ is of course being Bot.py here, but I want to get the file where the exception happened (cogdefault.py)
so if anyone knows an attribute that stores the file of a dpy or just a general exception, lemme know
I'd also need the command's name
is it allowed to create a public bot called find Bertie's girlfriend?
ask people to send submissions with age and name and genus and get a list of people looking for a bf
idea from @slate swan

and you need a db
no

make it send into a channel in my dc
maybe disnake has better exceptions
ok
never fucking mind
k but I need one that contains the command that raised it
lemme look at what the decorator does
of a command
a command would probably raise a custom one and not base
base is for all exceptions so they can subclass them
you could use Command.callback.__module__ to get the dot-qualified path to your command, or inspect.getmodule(Command.callback) for the module object itself
let me check
wait a damn minute though
we all ignored
ctx
and I just realised this after not knowing what command should be in your example
oh yeah i didnt mention you'd get command from ctx
hello, how can i do to delete the message's of the bot (example = the bot @jaunty folio and this message is deleted)
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
do you want the message to be deleted with a certain delay after it was sent? if so there's the delete_after= kwarg in the .send() method
thanks
just do await ctx.message.delete() after the declaration of the function
difference between command.callback.module and command.module
The callback is your user defined function, the module would be your file you created
command.module would be discord.py's module
yeah what they said
its just delete the message of the user
nah I don't need that
I need the cog file
but command has a _callback too Danny has to stop
is it allowed to create a public bot called find Bertie's girlfriend?
ask people to send submissions with age and name and genus and get a list of people looking for a bf
not sure what you want can you explain it again?
you would need a db or just have a global chat
!d inspect.getfile
inspect.getfile(object)```
Return the name of the (text or binary) file in which an object was defined. This will fail with a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") if the object is a built-in module, class, or function.
Just pass your Cog to this
send it into my server
is it allowed to create a public bot called find Bertie's girlfriend?
ask people to send submissions with age and name and genus and get a list of people looking for a bf
Genus lmao
i want the bot message's is deleting when i type a command
heh?
pardon?
Either way, perhaps it is fine. But if you take user data you must secure it properly, otherwise depending on country etc you'd be in violation of privacy laws
There are some dating bots that alredy exist
Please use a translator Patapouf
I want the bot message deleted
tu veux quoi?
^
do you want the message to be deleted with a certain delay after it was sent? if so there's the
delete_after=kwarg in the .send() method
this deleting the message of the user not the bot
await ctx.send('qfsqfqs', delete_after = time)
yeah the message that invoked the command you want the users message to be deleted?
thanks i test this
they said they wanted the bot's message deleted
I dont get anything of that
srry for my bad english but here is la france
🗿
so bot feature challenge
'Attempt to decode JSON with unexpected mimetype: ', url=URL('https://i.some-random-api.ml/IdojZs5m1v.gif')
can anyone help with this traceback
Where is the bot token on the developer portal? I knew where it was but it seems to have been changed and now I can't find it
probably bot.msg if wanting to transfer the message between two commands
this is a global solution so it's not gonna be able to work with two messages
You only can view the token once so you may have to regenerate.
ah okay
json is the best db
haha....
imagine using sqlite or bad stuff like this damn
y'all keep forgetting what this channel's for
.
.
.
is that true?
It’s new
Ah i see
code:
@nextcord.slash_command(name = "help", description= "U can see the commands of the bot", guild_ids=[testserverid])
async def help(self, interaction: nextcord.Interaction):
em = nextcord.Embed(title = "**Help**", description="**Use ``e![Command]`` to use a command**", colour=0xa62019)
em.set_thumbnail(url="https")
em.add_field(name = "**Commands**", value = "``Eth`` ``Matic`` ``Meme``", inline=False)
em.set_footer(text=f'Requested by - {ctx.author}', icon_url=ctx.author.avatar.url)
await interaction.response.send_message(embed = em)`
what can i replase ctx with in the slash commands in the ctx.author
interaction.author
Looks like there's no author attribute https://nextcord.readthedocs.io/en/latest/api.html?highlight=nextcord interaction#interaction
interaction.message.author?
.
are you gucci?
send 'em along
gucci?
error: discord bot\cogs\help.py", line 26, in help
em.set_footer(text=f'Requested by - {interaction.author}', icon_url=interaction.author.avatar.url)
AttributeError: 'Interaction' object has no attribute 'author'
interaction.user is how dpy originally implemented it, and it seems nextcord has kept that attribute
^
log_channel seems to be undefined
ty its working now
😳
I wonder if if not self.bot.is_ready(): is False, so it's never defined
do the other events work?
async def on_member_update(self, before, after): define it there?
I mean i guess you could but that's not practical
well there are no errors for the events so i would assume it works
Wdym not practical?
a bad approach
ok so what should i do?
i would suggest a property that gets the channel for you
e.g. py @property def discord_bots(self): return self.bot.get_channel(343944376055103488)
oh that'd be handy
Am confused is this error coming from line 83 from on_member_update
await self.log_channel.send(embed=embed)
AttributeError: 'Log' object has no attribute 'log_channel'```
if your cog gets reloaded after the bot already started, then on_ready won't fire until your bot reconnects, so an on_ready listener isnt the best place to assign log_channel
So remove the on_ready listener?
yea, and use a property for log_channel
async def on_ready(self):
self.log_channel = self.client.get_channel(886063553122021417)
print("Working!")
``` Is this alright?
what did you change there?
Ohh you want to remove the whole on_ready listener?
if you need an explanation on what a property is, its basically a method that's used as if it were an attribute ```py
class Employee:
def init(self, first, last):
self.first = first
self.last = last
@property
def full_name(self):
return f'{self.first} {self.last}'
e = Employee('John', 'Doe')
e.full_name
'John Doe'``` in your case you could use a property to get the channel dynamically, that way you don't have to worry about making sure the bot's connected beforehand or having to copy-paste the get_channel in each event
So?
this code works ig but it gives me an error
you should make sure those events only work in the guild(s) you want it to in case you add the bot to a server that doesnt have a #general channel
yea but how should i know the server names? like how should i do that
ideally you'd just compare the guild's ID instead of name
if you have developer mode enabled in Settings > Advanced, you can right click the server icon and Copy ID, then use that in your if-statement
e.g. py if member.guild.id == 267624335836053506: # member is in the python discord
is it fine to do something like dis yml disnake asyncio tornado motor pymongo==3.12.3 dnspython









