#discord-bots
1 messages · Page 1014 of 1
is there a way to create a thread (u know these small channels you can add on a message) with discord py? havent found anything in the docs nor with the danny bot
Yes, in 2.0
is 2.0 that will be there in the future or can i use it now?
I'm just confused as to why you say that's only an issue with python? Take for an example, a code base written in python. It'll have to refactor a decent chunk in order to have an asynchronous enviourment, or mostly just the entry point of the code. Other programming languages would also be affected by the same thing. You would have to refactor old synchronous functions into asynchronous ones. Your statement doesn't really make sense to me.
i did not say that.
Then you can migrate to 2.0 using https://discordpy.readthedocs.io/en/master/migrating.html and you have the documentation at the same place (https://discordpy.readthedocs.io/en/master/)
do i have to do this if a already have the "nomal" discord py installed or is this for 2.0?
For 2.0, I would uninstall the old one
?
You did
it seems like you have just changed my words?
Read back to this reply 😀
and literally curved my whole point?

bro you are going besides my point
ok, is 2.0 just 1.0 but with more features? can i keep all my old code?
^
There are some changes that need to be taken in consideration
🤨 Seems like you are just confused, or you have no clue what you are talking about?
Regardless I will drop this topic for now
i do, you just really dont know what youre talking about and changing my whole point?
👁️ 👁️
yeah im reading through that right now, but thank you! with uninstalling the old one, just uninstall like you uninstall a python libary, right?
like yes you can call coros in non async functions but you cant straight up called them like in other langs which my point was the async in python can morph your whole codebase compared to other langs
Yep
Spam in all channels, nice nice
even help channels💀
i++ makes a good argument
no one's watching that shit
Okimii didn't you say it was python specific though?
its not really python specific but it does happen in python which in some languages doesnt
Then why did you say, "it is tho" kek
i dont really know any other lang that does the same thing
Does what the same?
bro
^
Are you like, talking about tasks or futures
what's the general intents that should be used for bots in a private server?
Just slap a create_task? 👁️👄 👁️
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.reply(f"Slow down! You have got {round(error.retry_after, 3)} seconds left")
elif isinstance(error, commands.MissingPermissions):
pass
^
can anyone help me here
i keep getting inconsistence use of tabs and spaces
and unindent not expected
You can tho
and a ton of other errors
already been showed by master
What editor are you using
VSCode
kek
Is it a VSCode problem?
and still you can straight up call them without getting a tracemalloc error
No
Try to reformat the code with its command palette
oh i++ is the name of someone, i was searching how yall were talking about incrementing
wddym?
what shud i do?
Ctrl+Shift+P or F1
Search for 'convert indentation'
C 😳
All my homies prefer i++ over ++i
i like ++i
what shud i convert it to?
You choose
alr
Situational, so I would say half half then
🤨

error gone thx
One of these https://i.imgur.com/m1mt36J.png
All my homies mutually like post and pre incrementing
Now you can give the other error(s)
All my homies beat me up at school
whos your "homies" nova
No
yh now there is 11 more error
poor nova
i like ++i cuz it just feels fitting in a for loop, like for (..., ++i) in here ur ending with i instead of ++
contents = [embed_1, embed_2, embed_3, embed_4,embed_5,embed_6,embed_7, embed_8,embed_9]
``` got this in a async
correct indentation before
when i changed it i get error
Ong
For-loop 😩
what are the bad things about using mroe intents than you need?
Python developers after there error changes into a different error
useless dispatching of gateway events ig
And if you use privileged intents for things that are not needed and you verify your bot, you might not have access to them
For example Discord won't give the members intent for your userinfo command or for your serverinfo command to display the name of the server owner
also is there any ifinstance for could not dm member?
like error 400 bad req
i cant find it in their errors classes
Inb4, GET /users/{Guild.owner_id} to bypass
!d discord.Forbidden
exception discord.Forbidden(response, message)```
Exception that’s raised for when status code 403 occurs.
Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/master/api.html#discord.HTTPException "discord.HTTPException")
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`.
If the content is set to `None` (the default), then the `embed` parameter must
be provided...
Why would it send 400
discord.errors.HTTPException: 400 Bad Request (error code: 50007): Cannot send messages to this user
for this
That's weird
!d discord.HTTPException
exception discord.HTTPException(response, message)```
Exception that’s raised when an HTTP request operation fails.
Not at all
400 would be for an invalid payload
Yes, I know
They are not forbidden to get access to the resources
i have dms enabled but it gives that error
but how would the payload be a 400

403 - The Authorization token you passed did not have permission to the resource.
If the payload is completely right then the API returns 400 omegakek
The token has access to the resource
this convo is giving me a stroke
"No module named discord"
what i do ?
pip install discord
in terminal
not work
pip install --upgrade discord maybe?
or u have to maunually install it
i try
But if you take a look at the documentation for 400 it makes even less sense for it to send 400,
"The request was improperly formatted, or the server couldn't understand it."
not work
Doesn't give information to help
this only happens if its outside a gild
wait
fr some reason whil using on_message
if u dm it does that but stilll sends msg
yeah a 400 would be raised if the payload was wrong and so the request is invalid but a 403 makes more sense because it doesnt have access to that endpoint
So you would raise 403 for both, no permissions to send the message and DMs closed/blocked
Those are completely different things
Regardless though, both means the user cannot be DM'd so yes 403 makes sense for me
but the dms werent blocked...
Nope it doesn't make any sense at all
the dms were open and only got that error while using on_message
it still sent the msg
And you think it makes sense to send an invalid payload response code when the payload is CORRECT but the user cannot be DM'd
Again
that cant be right because the user can be dm'd
i did it using @bot.command
We're not talking about your code....
ik
what intents would a bot that only has slash commands and a ping command need, just for one server?
im saying that its same with oter pasrts of code
Restart VSC after installing
Try to run the file to see if you've actually installed it
None
I had tried
^
also is pycache required for running cogs?
no
cuz itss kinda annoying
it just makes your code a bit faster on startup
what's the point of intents.none() when you can just skip that kwarg?
You mean __pycache_ folder?
basically pointless than
ig
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.
It throws an error without it in 2.0
client = discord.Client()
@client.event
async def on_message(message):
channel = message.channel
if message.content.startswith('!ooga'):
while 1:
await message.channel.send("a")
await message.channel.send("a")
if message.content.startswith('!aw'):
while 1:
await message.channel.send("mmmm")
client.run("im not showing you my token")
there
Indentation is wrong
and why use 1
It's basically spam
just use straight up bool
aslo use py @client.command()
when i try to run
1 is literal to True so why not use bool
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
done
You have multiple Python installations?
yes
also how do u use 'bot.event in a extension?
No where, they're talking about someone else's problem
Try with pip3 instead
pip3 install discord?
do i just do py @bot.event
!d discord.ext.commands.Cog.listener
classmethod listener(name=...)```
A decorator that marks a function as a listener.
This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
is that for cogs only cuz mine is jus an extension?
Yeah it is for cogs which are extensions
mmh it not work
alr thx
When you run python --version in the cmd, what gets shown?
3.9.12
python3 --version
3.9.12
python3.10 --version
Are u using VSC? @slate swan
yes
You run the file with 3.10 but you installed discord.py in 3.9.12 - just as side note
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
3.10.4
^^^
I’m guessing that’s what they did as well
python3.10 -m pip install discord.py
done
Now run the file
or run your bot with python <file_name>.py manually which uses Python 3.9.12 and not 3.10, where you've already installed discord.py in
okay so I'm doing a command and my bot isn't responding without throwing an error
it work
thanks you ! @slate swan
No problem, just make sure to use the right version
Code
not sure what code I should send
The command code?
my error handler, my command code?
and yea, also the else block of yr error handler
it's just a ```py
@bot.command()
@commands.check_any(commands.has_role(620417313455210507), commands.is_owner())
async def ping(ctx):
bot_ping = round(bot.latency * 1000)
await ctx.send(f"Pong! {bot_ping}ms")
And the error handler?
and my eh is ```py
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
original_error = getattr(error, 'original', error)
if isinstance(original_error, commands.CommandNotFound):
return
elif isinstance(original_error, commands.CheckAnyFailure):
return
else:
print(error)
but i'm owner and I have the role
but I will still make it print something there to see if it is that one second
Owner of the bot right? Just to make sure
uh
@commands.is_owner checks for owner of the bot, not guild
I mean, he is the one who is writing all the bot, sooo
Ah okay mb
what the
Did u restart the bot?
I assume I may be missing intents then. What intents do I need for that command to work?
u using disnake, right?
yeah
Well considering you don't make slash commands like you've said
You need messages intent and message_content privileged intent, make sure to enable the last one also in the developer portal
Some send me 8 pound of eth fr 🙏
i need message_content even if the bot isn't in 75+ guilds?
That doesn't matter
Intents applies for all bots
When your bot is in 75+ guilds it will need to be verified, then you might not be given access to that intent and your commands will stop working
If your bot is in 75+ guilds you have to ask Discord to give you message_content intents
so I need message_content for it work?
Yes
but I thought I didn't have that intent
i need to enable it on the dev portal right?
Once you need to verify it you need to give more insight on why you actually need it, based on that Discord will give you access to it or not
Yep as it's a privileged intent
what is it called for disnake?
Just like discord.py
message_content?
Whether messages will have access to message content.
This applies to the following fields on Message instances...
weirddd i can't find it documented
Then you also need messages as said above
nevermind, monty lied to me
Or just guild_messages if you don't need dm_messages
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/flags.py", line 524, in __init__
raise TypeError(f"{key!r} is not a valid flag name.")
TypeError: 'message_content' is not a valid flag name.```
I think i need to update disnake?
Probably yeah
That means disnake still connects to the old gateway and u don't need to specify it
wdym?
I would recommend to update either way due to gateway deprecation
it is postponed to end of august tho
Requirement already satisfied: disnake in ./.local/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (2.4.0)
kalm
i have v2.4
!pypi disnake
i think that's latest?
Not a reason to keep on old version though
Hm that is the latest
so how do I fix that?
@spring flax try asking from arl in disnake server
Interesting as it seems to exist in the file? Not sure which flags are considered as being VALID_FLAGS.
okay yeah so just to confirm that it was my issue i used intents.all() and it worked
If I want my bot to play an mp3 sound effect when an event happens, what is the easiest way to accomplish that?
say if a person gives a command it could play a honk or something in voice
honk.mp3 in my file directory as an example
I see you can do VoiceClient.play() but how do I get a VoiceClient object, what returns thaT?
how can I do user.send to a specific user? and I mean literally a specific user object that I create and is kept in the code of the bot, not something that is given as input
for example I tell the bot to send a DM to me, CatOw#5012
You will need to connect to a Voice Channel and then play
!d discord.VoiceClient.play
play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource").
The finalizer, `after` is called after the source has been exhausted
or an error occurred.
If an error happens while the audio player is running, the exception is
caught and the audio player is then stopped. If no after callback is
passed, any caught exception will be displayed as if it were raised.
I would need an instance of VoiceClient to do that though I assume right?
so I would have to get it from some source
You get a voice client object via ctx.voice_client after joining a VC
let me try it 🙂
user = discord.User('CatOw', 279606501101010944)```
how do I do something like this? This example doesn't work
I saw that line in the docs hence why I was asking about it haha, thanks 🙂
Cool
No don't
u need to do bot.get_user(id_here)
I tried it didn't work
It returns None?
yeah
Either the ID is wrong or u don't have intents
what can i do if 2 libary go to 1? discord_slash i dont know why but try create button but i have lib (discord_components)
await ctx.send(embed=m, components=[[
TypeError: SlashContext.send() got an unexpected keyword argument 'components'
how to send downloaded videos
upgrade to discord.py 2.0 it has both
try send as file
dump question but how
file=discord.File(filename)?
python -m pip install git+https://github.com/rapptz/discord.py
@tacit token
await ctx.send(file=discord.File(r'c:\location\of\the_file_to\send.png'))
thank you
ur welcome, but if dont work say it
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
or the user isnt cached
(pabblehost)
it should work fine?
it says pycord does not exist
this is a script inside of propbot folder
ModuleNotFoundError: No module named 'pycord'
running in init.py
you dont run the init file
its for namespaces and did you mutated it because it should be using relative imports
Did you downloaded pycord and copied in your folder to import it?
ya because I was having lots of issues installing with pip
That's a first one, well you will need to pip install it
Why?
Because that's how Python libraries work
You're telling me I can't just import modules in local environment
I have to download them to global?
Just try
python3 -m pip install -U .
once you're in the pycord folder with your cmd
It will install from the local files
And just give your pip errors if you have any, it might be something really easy to fix
python was not found
This always happens when I do python3
I think on my computer it's just python
Then just do python
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
Do I need to have those files?
ok but i have a new problem.
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook
ya all initialization stuff is now async, check out this gist it explains what all you need to change https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120
It supports asyncio.run
i so dumb, but what is the asyncio.run
!d asyncio.run
asyncio.run(coro, *, debug=False)```
Execute the [coroutine](https://docs.python.org/3/glossary.html#term-coroutine) *coro* and return the result.
This function runs the passed coroutine, taking care of managing the asyncio event loop, *finalizing asynchronous generators*, and closing the threadpool.
This function cannot be called when another asyncio event loop is running in the same thread.
If *debug* is `True`, the event loop will be run in debug mode.
This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once.
Example...
alot of things
you now have async init where u can make a lot of modifications
buttons
views
modals
slash command
and many more
what do you refer to an async init?
python is telling me it can't find the discord library (Import "discord" could not be resolved), even though my program works fine (actually it doesnt work right now, but it used to work yesterday even though the warning was there yesterday)and i have installed it and then reinstalled it just to check.
how do i fix this so the error doesnt show up?
async initialisation
of what
of the bot? like before u could just do bot.run or bot.load_extension now its all async
background_task isnt defined
bot.run still works fine
start is asynchronous
i meant start lol
thats what i read in the gist 🤷♂️ (https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120)
seems like a good way to make asyncio.run take owner ship of the AbstractEventLoop
smh a spamming command
and its basic python
ya its pretty cool
yes sir
None gonna help u
How does the after param of VoiceClient.play() work? It says it can take a callable, does that mean I can arbitrarily pass a python function and it will execute that when the track finishes?
Its a spam bot, so idgaf if I am rude or not, I just told the truth
yup
......okay......sorry
sigma hunter
Just saying. That thing breaks ToS 🤷
That doesn't matter
You don't have to be a staff member to follow the server rules
really judging by roles
I just love it when people say that one is not a helper 👀
they left the convo
Staff team can't be in every channel at once, so there's nothing wrong with having members keep each other in check
yup
Anyways, happy Saturday everyone. I've been busy with yard work and making / having brunch
Happy saturday to yourself! I do love doing yard work on lazy saturday afternoons myself 😄
how can i see who someone replied too in a on_message
Happy saturday, ive been busy with cleaning my house and you didnt invited me to your brunch😡 😔
trying to see who ran a command
!d discord.ext.commands.Context.author
Union[User, Member]:
Returns the author associated with this context’s command. Shorthand for Message.author
!d discord.Message.author | if its in on_message
but the author would be the bots response?
it would be the author who triggered the condition of the if statement if you have one
oh you mean slash commands?
nah its fine, what library are you using?
uh
so you want it to not listen to messages of the bot
im not sure what you want sorry
!d discord.Member.bot
property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
you can just do
if message.author.bot:
return
and i want to be able to tell from the embeded response
You should do that through the API
IIRC they notify you when someone bumps your bot
im now confused too
im bumping a server not a bot
if someone bumps my server
i want to be able to see who bumped
Right, they still have an API to notify you of that
(At least I think they do. It might've been top.gg)
That's unfortunate. You'd think they'd have one
Then yeah, scraping embeds is your best bet
You do need message content for that so keep that in mind
thats what i have so far
i have a on_message
and it checks to see if its a bump embed
but from that i want to be able to see who ran the command
and thats where i am stuck
you sounded aggressive

it wont be hard though
how can i do it?
What is the best discord bot library that supports slash commands?
its all personal preference
i mostly use disnake as its quite easy
!pypi disnake
Does disnake have slash commands and all the latest features?
Any chance someone can offer some clarity on VoiceClient.play()'s after attribute? I'm writing a method callable but want to make sure I'm doing it correctly
Is there any YouTube tutorials for Disnake?
"The finalizer that is called after the stream is exhausted. This function must have a single parameter, error, that denotes an optional exception that was raised during playing."
I mean, it wont be as ideal, but,
first you could check if the message wsd sent by the disboard bot, and check the embed content if it matches to being bumped or not, then if the server was bumped successfully, you could get the last 20 messages of the channel and check which of them wrote the command (otherwise the bot mentions the person who bumped the server in the embed content, if there's a way you could do that)
this only works for message commands not slashes
So for example, if I want to chain play as long as a condition is true, how would I do that? I'm assuming it'd be like a callback pattern for play so file finishes then callback calls another file to play? The issue is passing context since I'm only passing one arg and not sure how it'd be easiest to make that happen if that makes sense
while condition:
await vc.play(...)
yea thats the issue i could do it fine for message command
but i am doing it for slash commands
thats the issue
you got no luck for slashes, or as Robin said if there's an api for disboard
well ive seen a bot do it before
so it is possible
how can i check a message and see if it is a reply to someone and who it is?
I don't like that implementation, it seems like the after method is supposed to be used when a file finishes playing to call some action to happen, there must be some simple way to make that action calling another file from the same VoiceClient instance
the only thing I'm having trouble with is that the after callback only receives error if there is an error, it doesn't seem to pass ctx or any identifier from the original voiceclient
the after is used to do stuff after the sound is finished, yes
what is the issue u r facing?
so say for example I want the following functionality:
user sends command =play_sound
hits play_sound in voice cog
sound plays, then calls the after
the after should trigger another sound to play as well as log the error if error, but in order to play another sound I'd need ctx or at least the initial VoiceClient instance that .play() was called on
Ah
well for this case, what people do is, define another function inside the command function itself to get access to the ctx param
!d discord.ext.commands.Bot.voice_clients also exists btw
property voice_clients```
Represents a list of voice connections.
These are usually [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") instances.
Why do I get this message when I try and run my bot
rerun the script
Windows issue
Just did. Same thing.
Eh
I can send the code if you want
the voice_clients is useful as a hacky solution but even with a separate function I'm still not seeing how to pass ctx args given that I think the after is the one sending them, unless you can do something like after=my_func(ctx_args) as an example?
yea sure @gentle sphinx
oooh I could use partial probably!
Ah, well no. What I am saying is
and pass in partial ctx as args that way
since partial is still considered a callable iirc
async def cmd(ctx, ...):
def after(e):
# u have access to e and ctx both
print(e)
ahh I see, I will try that solution 🙂 thank you btw
if that doesn't work I'll try partial next
Never heard about that haha. Thanks for telling me that smth like that exists
@maiden fablehttps://pastebin.com/h4wsh7fr
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Partial is awesome
Yea seems like it haha
you can load a callable with default arguments
Yea haha
weirdddd
very
Okay so, weird and noob question, but did u input the correct token?
sorry for the question
and it is also useful because a partial always has the same dunder name for where it is called, I actually used that because I was calling a method in a cog and from an object instance of a server so the dunder name was different and "self" had a different value, so I used partial because it keeps it consistent 🙂
Cool!
Thanks for telling me bout that btw. its gonna fix the issue of me using nested functions haha
Yes.
did u try asking in the disnake server?
Nope
@gentle sphinx what is yr disnake version?
haha awesome, that is great to hear 🙂 I'm going to test it out, appreciate the assistance hunter!
hey does anyone know of how to help me?
@uncut comet u cannot do that anymore
anymore?
from discord.ext import tasks
import discord
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@tasks.loop(seconds=1)
async def DM():
user = client.get_user(279606501101010944)
await user.send('Hello')
DM.start()```
await user.send('Hello')
AttributeError: 'NoneType' object has no attribute 'send'```
there is no way of me being able to tell?
Since its a slash command now
And I don't think u can access the slash command invoker
but i had a bot which could tell
the user ID is correct, why doesn't it work?
im just trying to recreate that bot
user is none and that is probably against tos
but it is possble somehow
what are you talking about?
that's my user, that's me
Spamming DMs
no forget the spamming DMs it's a test, not a single message was sent
Is it? Uh, sorry bruv, I don't really know then 😔
you can
ah okay no woreries
it doesnt really matter its still spamming requests
I'm just trying to make the bot send me a message okay forget the tasks.loop I just put it there because I had no idea what else to put in order to make it work
How?
interaction.user
oh how can i use interaction.user? im still new to coding bots haha
But u cannot get Interaction from a message
He wants to get the slash command invoker via another bot
you could just make a task with the AbstractEventLoop and fetch the user and dm you if you want it to dm you on each startup
oh ok
okay I guess thanks
lol why you keep saying AbstractEventLoop
message.content.replace("AbstractEventLoop", "asyncio.loop") = Love
i love the word guys
this is what i meant when i said there is a bot doing it
been many months since I have developed in python, what is the asyncio function that takes a coroutine and generates a callable object and adds it to the executor? I remember there was something that did this but it's escaping me atm
Ah, time to skim through the docs then :D
!d asyncio.loop.run_in_executor ?
awaitable loop.run_in_executor(executor, func, *args)```
Arrange for *func* to be called in the specified executor.
The *executor* argument should be an [`concurrent.futures.Executor`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor "concurrent.futures.Executor")
instance. The default executor is used if *executor* is `None`.
Example:
This is used to run a blocking function tho, like PIL or requests
similar but that docs link will be very useful ❤️
cant you make a task which stops it from blocking or something?
!d asyncio.to_thread
coroutine asyncio.to_thread(func, /, *args, **kwargs)```
Asynchronously run function *func* in a separate thread.
Any *args and **kwargs supplied for this function are directly passed to *func*. Also, the current [`contextvars.Context`](https://docs.python.org/3/library/contextvars.html#contextvars.Context "contextvars.Context") is propagated, allowing context variables from the event loop thread to be accessed in the separate thread.
Return a coroutine that can be awaited to get the eventual result of *func*.
This coroutine function is primarily intended to be used for executing IO-bound functions/methods that would otherwise block the event loop if they were ran in the main thread. For example:
This is also pretty useful
???
Hm never used and heard about this
answer me😡
no
It will stop block even if u use PIL inside of an async function
okay could it count as a reply? how can i see if a message is a reply to someone?
the wording
Prolly. Lemme see the docs
create_task is for running coroutines in the background
yeah ik
!d discord.Message.reference
The message that this message references. This is only applicable to messages of
type MessageType.pins_add, crossposted messages created by a
followed channel integration, or message replies.
New in version 1.5.
He wants the slash command author
Like someone bumps using disboard bot and the bot sends the author of the bump command
Ok
Is there a matter really
Every interaction message is basically a reply cause it can only be sent in response to interaction
Ah
Thought so
!e ```py
import asyncio, time
async def foo() -> None:
time.sleep(100)
async def main() -> None:
asyncio.create_task(foo())
print("bar")
asyncio.run(main())
@pliant gulch :x: Your eval job timed out or ran out of memory.
bar
Lmao
I meant directly doing await foo() instead of creating a task
so i was right

@uncut comet
yea
"cant you make a task which stops it from blocking or something?" was what you were replying to
can u print the type of that message? print(message.type)
Although for PIL I recommend just running this in a whole different thread
Ah, misunderstood the question
Today I started hosting bots on intel celeron d
What VPS
btw how is it possible that it doesnt block? does it run the tasks in another event loop or another thread or?
Imagine using VPS when you can build a server yourself
Internet goes brrrrrr
😏
MessageType.application_command
Hm
Ikr I had a lot of headache trying to setup network
!d disnake.MessageType.application_command
The system message denoting that an application (or “slash”) command was executed.
New in version 2.0.
Lemme see
@uncut comet I don't quite understand what you are trying to do
I bumped the server, he wants my username
Every interaction message is response to "abstract" slash command message
!d disnake.ApplicationCommandInteraction.author ?
The user or member that sent the interaction.
He doesn't have access to interaction object bro
How
Cz its not his command
Oh he wants to do it other way
he is using an on_message and seeing the type of the message
the command is to a different bot
Ok weird thing
and im trying to pick it up from my bot
Lemme resolve this
create_task schedules the coroutine, it should be all on the same event loop & it doesn't do it in another thread unless you do to_thread or run_in_executor
!d disnake.Message.interaction there ya go @uncut comet
The interaction that this message references. This exists only when the message is a response to an interaction without an existing message.
New in version 2.1.
okay i have a dumb question
No question is dumb lol but okay
Ayo gg!
🎉
this is disnake im not using disnake so do i need to try to switch to disnake to do that??
What are you using rn
#web-development or smth
Idk
What version
Imagine having an SSD and still slow speeds
i got em for free
imagine
Heck that amount of files
And yea, my SSD supports read write speeds of upto 600 MB or smth
sus
LMAO XD
I am moving Python and VSCode in the below one
😩 gl
how? alot people uses proxies
good question i have no clue it says discord.py @ git+https://github.com/Rapptz/discord.py@4dc24a005a5f78c1fc004667dd5241c8fc3eb253
The above is my folder of all the coding projects
Ok it's 2.0
just do pip install -U git+https://github.com/Rapptz/discord.py
!d discord.Message.interaction same thing should exist
The interaction that this message is a response to.
New in version 2.0.
It will update to the latest
!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.
some people use proxies to avoid ip bans but im just messing with you
What is an ip ban
Zeffo, stop acting like udk how to make a discord bot
fr
U r better than any of us here
fr
Ban of ip
smh
Lmao
i broke my pip trying to do that hahaha
o
lolll
Hahaha what did u do to it
Smh why don't websites just HWID ban 👿
What is that now
Nullptr 😱
Imagine mac address ban
Random MAC ftw!
😡
C:\Users\Adam>py -m pip install pip install -U git+https://github.com/Rapptz/discord.py hahaha
hahaha
just use a mac address spoofer
jesus
thanks
even phones have those in built nowadays lmao
imagine
Zeffo 😱
My phone does
Identity documents ban 😀
Might as well ban the hardware of the device
epic games bans hardware lol
Me when I was dumping ubuntu iso into the flash drive
Except speed was like 200kbps
💀
I feel u
Idk mine works like 200gbps normally, it might greatly slow down if it copies huge amount of small files tho
Wait really?
You are copying many files as well
That is the issue then. Its copying files which are like 1 KB in size rn
Yk small config, xml and ini files
Understandable
Not the actual data transfer speed
THANK YOU
Works?
hahaha i got it working
Gg
Ay gg!
good going
no
thanks guys been trying to do that for a while
All thanks to Evenifix
whos that
Great Guy
GG may refer to:
green guacamole
bro
goodness gracious
Lmaooo

😄
I got like 5 name aliases today
do you guys have any project ideas?
Bruh anyone here who is willing to help me with partition stuff in #ot2-never-nester’s-nightmare?
how do i print my bot's status, ex: online, dnd, idle and invisible
project ideas meaning what?
I mean yesterday cause it's 0:06
!d discord.Member.status
property status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
bot status
oh that
this actually works????
Mhm
Gonna say more they are users
tasks.loop + bot.user.status
if the bot status is anything except invisible
it will run a program
else it will stop
BASICALLY make it only work when the bot is not on invisible mode
discord py
It's gonna be like 3 strings minimum
@vale wing do u know bout partitions and stuff?
k bet
Well I wanted some help regarding those, if u can
One sec if I can find it
Thanks
It's about extending them
Procedures for extending Linux file systems to fill space made available on expanded EBS volumes.
Linux 😔
You needed windows?
Mhm
I am using W11
Imagine not using ubuntu server

@maiden fable so you need help with partitions in w11?
yea
You just need disk manager / partition wizard / device manager whatever it is called and everything is pretty easy to figure out there
Ik it is easy haha
If you wanted to change the filesystem like gpt and mbr it's cringe
No
I just want to allocate that unallocated space to C drive without deleting D
I think there's extend button
discord py = how to print bot status, like: online, idle, dnd and invisible
Doesn't work lol
It automatically consumes unallocated space
@slate swan I told u
on the plus side you didnt just spend ages manually fdisk-ing 12 disks 
bot.user.status????
Stop it, help me pls 😔
bot didn't even start properly
bot.connect
bot.run()
Still not getting satisfactory results, I've tried a few different solutions and as yet have not gotten one sound to play triggering the next sound ad nauseam
still doesnt work
Huh? partial didn't work?
Not yet, I'm trying things but I guess I must be misunderstanding what after is intended to be doing
hmm let me try this idea
I told u
ctx.me.status
YOU TOLD ME
bot.user.status
OH OK wrong person
@maiden fable HOW CAN I USE IT ON_MESSAGE
Calm down
OK I WILL CALM DOEWN
message.guild.me.status
inb4 message is in DM and it errors
Lmao
AttributeError: 'NoneType' object has no attribute 'me'
and andy called it
Then the best way @pliant gulch
Access bot.guilds, select a random guild (I would choose 0 always), and then get the me.status attr on it
Oh, well
Andy correct as usual 😔
😭
Do u mind helping him pls?
I have to go sleep, it's already 3
!d discord.Member.status
property status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
done
every tutorial I follow for pycord its like I have a different version or something. They use decorators that I don't have access too and also index attributes and methods that I can't see as well.
I have the latest version of Pycord
You can't just do bot.status?!
Wait, that's a thing....?
!d discord.ext.commands.Bot.status
property status```
[`Status`](https://discordpy.readthedocs.io/en/master/api.html#discord.Status "discord.Status"):
The status being used upon logging on to Discord.
what
Bruh, now I feel..... shit
theres no way
Since bot.user.status isn't a thing, I thought Bot.status won't also be one
Oh woops I meant bot.user.status
Lmaooo
Wait bot.user.status isn't a thing?
no
No dude, that's the issue
andy, Mission Failed Successfully
bro i swear youre so lucky
i swear that wasnt a thing
yeah
i forgor
ok i tried this
await bot.change_presence(status=discord.Status.offline)
it didnt work
bro just use the constructor
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result
anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with
this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality
to manage commands...
every time I use pycord it's like all the information about pycord is outdated. The discord object itself is much different on my computer than others. Do the devs not give a shit about backwards compatibility? Do they just change the API frequently.
Here is example: The picture is a picture of someones code from youtube. Here is what it looks like in VSC when I replicate it
https://gyazo.com/5b35791c83f6dd4c88cb1ea72b5b82f2
as you can see my object does not offer the same auto-complete as theres
most pycord tutorials are bad like the lib, i would just use main
I had many issues with discord.py as well
just use disnake then?
to be honest I've never seen such disorganized information about a library before
yeah its very overrated
disnake?
!pypi disnake
and how come you like this one?
i mostly like its implementations on endpoints i.e slash commands its well done, its quite easy, its server is quite helpful, its source of new endpoints is quite clean and the lib is good with types
if message.content == 'online':
await bot.change_presence(status=discord.Status.online)
not working
@slate swan
😿
does import discord nolonger work?
why wouldnt it?
wtf do i do
Define not working
basically when i say online i dont get online
Here is another example. Straight out of the box after installing discord.py and literally copy pasting the introductory boilerplate code I get an error:
Introductory code:
import config
import discord
bot = discord.Bot()
@bot.slash_command(guild_ids=config.applicationTestingGuilds)
async def hello(ctx):
await ctx.respond("Hello!")
bot.run(config.token)
AttributeError: module 'discord' has no attribute 'Bot'
Does the API need update or something?
you aren't using py-cord
that is some old code
bro
It's discord.ext.commands.Bot
that's some py-cord shit
not in pycord
i even tryied do not disturb status

I'm not in Pycord
but he isnt using it so lol
it is in py-cord
;((((((((((((((((((((((((((((((((((((((((((((
so then do the docs need to be updated?
bro check what i referred to
🗿
if message.content == 'dnd':
await bot.change_presence(status=discord.Status.dnd)
and follow up question: are there any wrappers for discord API that have accurate docs it's been a mess trying to learn these libraries because there's so much outdated information
disnake
alright then
some examples that will work ~~ mostly~~
youre welcome!
pls help
if message.content == 'dnd':
await bot.change_presence(status=discord.Status.dnd)
Working with Discord, specifically the FFmpeg player, having some unexpected results when accessing path, it works as expected when defining the path but for whatever reason I am getting a file not found without the complete path:
def play_handler(voice_client, error=None):
if error:
print('oh no')
play_handler(voice_client)
os.chdir('files/test/')
curr_path = os.getcwd()
print(curr_path)
file_list = [file for file in os.listdir(curr_path) if file.endswith('.mp3')]
print(file_list)
file_name = f'{random.choice(file_list)}'
test_path = f'{curr_path}\{file_name}'
audio_source = discord.FFmpegPCMAudio(f'{test_path}')
print(audio_source)
curr_loop = asyncio.get_running_loop()
print(test_path)
curr_loop.create_task(voice_client.play(audio_source, after=partial(play_handler(voice_client))))
LOTS of print statements as I'm trying to narrow down what is happening here -
Readout when run:
C:\Users\Baron X\Desktop\Reality\BarHub Base\BarBot Development\Feature Testing\BarBotRebuild\files\test
['test1.mp3', 'test2.mp3', 'test3.mp3', 'test4.mp3']
<disnake.player.FFmpegPCMAudio object at 0x000001C44636AB00>
C:\Users\Baron X\Desktop\Reality\BarHub Base\BarBot Development\Feature Testing\BarBotRebuild\files\test\test2.mp3
Oof! Looks like we encountered an error: Command raised an exception: FileNotFoundError: [WinError 3] The system cannot find the path specified: 'files/test/'
as you can see, the path printed is what is intended but for some reason it only shows the files/test in the error despite the full path working in the test_path variable
functionality desired is that it will play a sound, and when finished play another sound until stopped
atm there are no stops but I'm testing methods and encountering the above error
@slate swan already ran into issues with the lib. Copying the code from the example it does not work.
I found the fix but this is a not looking good
whats wrong here? 🤔
it's discord.Client
not really issues with the library youre probably doing something wrong because internal errors are very rare
what error
remind me how to install I will show the error
git isnt installed lol
all python discord bots are set to stop working in a couple of hours unless on version 2.0 of discord.py correct?
how do i know youve already been here lol
no i see no reason why
because the api changes are setback to 2023
iirc
when did this happen 🤔
check in #697138785317814292
👌
bot.load_extension(f'cogs.{filename[:-3]}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
