#discord-bots

1 messages · Page 1014 of 1

wary crystal
#

So you disagree because >"js has that advance async which lets you call promises in non promises"; even though python can do the same exact thing?

slate swan
#

what?

#

it is written there "interaction error"

chilly knot
#

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

slate swan
#

Yes, in 2.0

chilly knot
slate swan
#

You can use it right now

#
pip install git+https://github.com/Rapptz/discord.py
wary crystal
# slate swan what?

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.

slate swan
chilly knot
slate swan
wary crystal
#

?

wary crystal
slate swan
#

it seems like you have just changed my words?

wary crystal
slate swan
#

and literally curved my whole point?

wary crystal
slate swan
#

bro you are going besides my point

chilly knot
slate swan
#

There are some changes that need to be taken in consideration

wary crystal
#

Regardless I will drop this topic for now

slate swan
pliant gulch
#

👁️ 👁️

chilly knot
slate swan
#

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💀

pliant gulch
#

i++ makes a good argument

buoyant zodiac
#

no one's watching that shit

pliant gulch
slate swan
pliant gulch
slate swan
#

i dont really know any other lang that does the same thing

pliant gulch
#

Does what the same?

slate swan
#

bro

pliant gulch
#

Are you like, talking about tasks or futures

spring flax
#

what's the general intents that should be used for bots in a private server?

pliant gulch
slate swan
#

@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

pliant gulch
slate swan
#

and a ton of other errors

slate swan
slate swan
slate swan
pliant gulch
slate swan
slate swan
# pliant gulch kek

and still you can straight up call them without getting a tracemalloc error

slate swan
#

Try to reformat the code with its command palette

paper sluice
slate swan
#

what shud i do?

#

Ctrl+Shift+P or F1

#

Search for 'convert indentation'

pliant gulch
#

All my homies prefer i++ over ++i

paper sluice
#

i like ++i

slate swan
#

You choose

#

alr

slate swan
#

Either spaces or tabs

#

risky joke tbh

pliant gulch
slate swan
#

🤨

paper sluice
slate swan
pliant gulch
#

All my homies mutually like post and pre incrementing

slate swan
#

All my homies beat me up at school

slate swan
pliant gulch
#

No

slate swan
#

poor nova

paper sluice
#

i like ++i cuz it just feels fitting in a for loop, like for (..., ++i) in here ur ending with i instead of ++

slate swan
#

correct indentation before

#

when i changed it i get error

pliant gulch
#

For-loop 😩

slate swan
#

i set it to both

spring flax
#

what are the bad things about using mroe intents than you need?

slate swan
#

Python developers after there error changes into a different error

slate swan
#

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

slate swan
#

like error 400 bad req

#

i cant find it in their errors classes

pliant gulch
#

Inb4, GET /users/{Guild.owner_id} to bypass

slate swan
#

!d discord.Forbidden

unkempt canyonBOT
#

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")
slate swan
#

ahhh

#

Nah that's not it I belive

#

thx

#

Throws an error 400 and not 403

slate swan
#

!d discord.Member.send

unkempt canyonBOT
#
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...
pliant gulch
#

Why would it send 400

slate swan
#
discord.errors.HTTPException: 400 Bad Request (error code: 50007): Cannot send messages to this user
#

for this

pliant gulch
#

That's weird

slate swan
#

!d discord.HTTPException

unkempt canyonBOT
#

exception discord.HTTPException(response, message)```
Exception that’s raised when an HTTP request operation fails.
slate swan
pliant gulch
#

400 would be for an invalid payload

slate swan
#

403 would be forbidden

#

yes

#

how would it send a 400

pliant gulch
#

Yes, I know

slate swan
#

They are not forbidden to get access to the resources

slate swan
#

but how would the payload be a 400

#

403 - The Authorization token you passed did not have permission to the resource.

pliant gulch
#

If the payload is completely right then the API returns 400 omegakek

slate swan
#

The token has access to the resource

#

this convo is giving me a stroke

#

"No module named discord"

#

what i do ?

slate swan
#

in terminal

#

not work

#

pip install --upgrade discord maybe?

#

or u have to maunually install it

#

i try

pliant gulch
#

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."

slate swan
#

not work
Doesn't give information to help

slate swan
#

wait

slate swan
#

if u dm it does that but stilll sends msg

slate swan
slate swan
#

Those are completely different things

pliant gulch
slate swan
#

Nope it doesn't make any sense at all

slate swan
#

it still sent the msg

pliant gulch
#

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

slate swan
#

Again

slate swan
#

i did it using @bot.command

#

We're not talking about your code....

#

ik

spring flax
#

what intents would a bot that only has slash commands and a ping command need, just for one server?

slate swan
#

im saying that its same with oter pasrts of code

slate swan
#

Try to run the file to see if you've actually installed it

slate swan
slate swan
#

also is pycache required for running cogs?

#

no

#

cuz itss kinda annoying

#

it just makes your code a bit faster on startup

spring flax
#

what's the point of intents.none() when you can just skip that kwarg?

slate swan
slate swan
#

ig

slate swan
#

It's a Python standard

#

alr

#

!code

unkempt canyonBOT
#

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.

slate swan
#
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

slate swan
#

when i try to run

#

1 is literal to True so why not use bool

#

!indents

unkempt canyonBOT
#

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

slate swan
#

import disord

#

pip install discord

slate swan
slate swan
slate swan
#

also how do u use 'bot.event in a extension?

#

No where, they're talking about someone else's problem

slate swan
#

pip3 install discord?

#

do i just do py @bot.event

slate swan
unkempt canyonBOT
#

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").
slate swan
#

Fix it

slate swan
#

Yeah it is for cogs which are extensions

#

mmh it not work

#

alr thx

slate swan
#

3.9.12

#

python3 --version

#

3.9.12

#

python3.10 --version

silver wolf
#

Are u using VSC? @slate swan

slate swan
#

You run the file with 3.10 but you installed discord.py in 3.9.12 - just as side note

#

!indents

unkempt canyonBOT
#

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

slate swan
silver wolf
slate swan
slate swan
#

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

spring flax
#

okay so I'm doing a command and my bot isn't responding without throwing an error

slate swan
#

it work

#

thanks you ! @slate swan

#

No problem, just make sure to use the right version

spring flax
slate swan
#

Some libraries are still not compatible with 3.10

#

okay

maiden fable
spring flax
#

my error handler, my command code?

maiden fable
#

and yea, also the else block of yr error handler

spring flax
#

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")

maiden fable
#

And the error handler?

spring flax
#

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)
maiden fable
#

what if there is a check failure?

#

then it will simply return

spring flax
#

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

maiden fable
#

Can u remove the return and instead add smth to both the if statements?

#

Ah cool

slate swan
maiden fable
#

uh

slate swan
#

@commands.is_owner checks for owner of the bot, not guild

maiden fable
#

I mean, he is the one who is writing all the bot, sooo

slate swan
#

Doesn't prove anything

#

I often code on bots I do not own

spring flax
#

yes owner of the bot

#

okay so the print statements do nothing

maiden fable
maiden fable
#

Did u restart the bot?

spring flax
#

I assume I may be missing intents then. What intents do I need for that command to work?

maiden fable
#

u using disnake, right?

spring flax
#

yeah

slate swan
#

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 🙏

spring flax
slate swan
#

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

sick birch
spring flax
#

so I need message_content for it work?

slate swan
#

Yes

spring flax
#

but I thought I didn't have that intent

slate swan
#

You do?

#

Every bot that is not verified can have it enabled

spring flax
#

i need to enable it on the dev portal right?

slate swan
#

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

spring flax
#

what is it called for disnake?

slate swan
spring flax
#

message_content?

slate swan
#

Yep

#

!d disnake.Intents.message_content # Just making sure

unkempt canyonBOT
spring flax
#

weirddd i can't find it documented

slate swan
#

Then you also need messages as said above

spring flax
#

nevermind, monty lied to me

slate swan
#

Or just guild_messages if you don't need dm_messages

spring flax
#
  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?

slate swan
#

Probably yeah

maiden fable
slate swan
#

I would recommend to update either way due to gateway deprecation

maiden fable
#

it is postponed to end of august tho

spring flax
#

Requirement already satisfied: disnake in ./.local/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (2.4.0)

maiden fable
#

kalm

spring flax
#

i have v2.4

maiden fable
#

!pypi disnake

unkempt canyonBOT
spring flax
#

i think that's latest?

slate swan
#

Not a reason to keep on old version though

maiden fable
#

Hm that is the latest

spring flax
#

so how do I fix that?

maiden fable
#

@spring flax try asking from arl in disnake server

slate swan
#

Interesting as it seems to exist in the file? Not sure which flags are considered as being VALID_FLAGS.

spring flax
#

okay yeah so just to confirm that it was my issue i used intents.all() and it worked

ebon island
#

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?

gloomy meadow
#

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

maiden fable
#

!d discord.VoiceClient.play

unkempt canyonBOT
#

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.
ebon island
#

I would need an instance of VoiceClient to do that though I assume right?

#

so I would have to get it from some source

maiden fable
#

You get a voice client object via ctx.voice_client after joining a VC

ebon island
#

let me try it 🙂

maiden fable
#

@ebon island

gloomy meadow
#
user = discord.User('CatOw', 279606501101010944)```
#

how do I do something like this? This example doesn't work

ebon island
#

I saw that line in the docs hence why I was asking about it haha, thanks 🙂

maiden fable
#

Cool

maiden fable
#

u need to do bot.get_user(id_here)

gloomy meadow
#

I tried it didn't work

maiden fable
#

It returns None?

gloomy meadow
#

yeah

maiden fable
#

Either the ID is wrong or u don't have intents

gloomy meadow
#

oh it's intents then

#

alright thanks

tacit token
#

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'
velvet haven
#

how to send downloaded videos

tacit token
tacit token
velvet haven
paper sluice
#
python -m pip install git+https://github.com/rapptz/discord.py

@tacit token

tacit token
velvet haven
#

thank you

tacit token
#

ur welcome, but if dont work say it

tacit token
paper sluice
#

ya u need to install git

tacit token
#

and what happend if i upload my files to my host

slate swan
tacit token
paper sluice
#

it should work fine?

sinful wind
#

it says pycord does not exist

#

this is a script inside of propbot folder

#

ModuleNotFoundError: No module named 'pycord'

#

running in init.py

slate swan
#

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?

sinful wind
#

ya because I was having lots of issues installing with pip

slate swan
#

That's a first one, well you will need to pip install it

sinful wind
#

Why?

slate swan
#

Because that's how Python libraries work

sinful wind
#

You're telling me I can't just import modules in local environment

#

I have to download them to global?

slate swan
#

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

sinful wind
#

python was not found

#

This always happens when I do python3

#

I think on my computer it's just python

slate swan
#

Then just do python

sinful wind
#
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
#

Do I need to have those files?

tacit token
paper sluice
tacit token
#

and this better then 1.7.3?

#

and if yes, why?

torn sail
#

It supports asyncio.run

tacit token
#

i so dumb, but what is the asyncio.run

slate swan
#

!d asyncio.run

unkempt canyonBOT
#

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...
paper sluice
# tacit token and if yes, why?

alot of things
you now have async init where u can make a lot of modifications
buttons
views
modals
slash command
and many more

slate swan
outer bramble
#

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?

paper sluice
#

async initialisation

slate swan
#

of what

tacit token
paper sluice
#

of the bot? like before u could just do bot.run or bot.load_extension now its all async

slate swan
slate swan
paper sluice
#

i meant start lol

slate swan
#

smh a spamming command

#

and its basic python

slate swan
maiden fable
#

None gonna help u

ebon island
#

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?

slate swan
#

by abusing the api?

#

youre spamming requests to the api bro

#

it doesnt matter

slate swan
#

no

#

no one is gonna help you

maiden fable
slate swan
#

yup

slate swan
#

sigma hunter

maiden fable
slate swan
#

yup

#

bro and?

sick birch
#

That doesn't matter

velvet compass
#

You don't have to be a staff member to follow the server rules

slate swan
#

really judging by roles

maiden fable
#

I just love it when people say that one is not a helper 👀

slate swan
#

2 helpers now

#

checkmate

paper sluice
#

they left the convo

sick birch
#

Staff team can't be in every channel at once, so there's nothing wrong with having members keep each other in check

slate swan
#

yup

velvet compass
#

Anyways, happy Saturday everyone. I've been busy with yard work and making / having brunch

sick birch
uncut comet
#

how can i see who someone replied too in a on_message

slate swan
uncut comet
#

trying to see who ran a command

slate swan
unkempt canyonBOT
slate swan
#

!d discord.Message.author | if its in on_message

unkempt canyonBOT
uncut comet
#

but the author would be the bots response?

slate swan
#

it would be the author who triggered the condition of the if statement if you have one

uncut comet
slate swan
#

oh you mean slash commands?

uncut comet
#

yea my bad for bad explaining

#

my bot will pickup that embeded response

slate swan
#

nah its fine, what library are you using?

uncut comet
#

uh

slate swan
#

im not sure what you want sorry

uncut comet
#

basically

#

a user will run a slash command to another bot

slate swan
#

!d discord.Member.bot

unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
uncut comet
#

(bumping)

#

but i want to see who bumped the bot

slate swan
#

you can just do

if message.author.bot:
    return
uncut comet
#

and i want to be able to tell from the embeded response

sick birch
#

IIRC they notify you when someone bumps your bot

slate swan
#

im so confused rn

#

😭

uncut comet
#

im now confused too

uncut comet
#

if someone bumps my server

#

i want to be able to see who bumped

sick birch
#

Right, they still have an API to notify you of that

#

(At least I think they do. It might've been top.gg)

uncut comet
#

im looking on the page now

#

i dont see any sort of api

sick birch
#

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

uncut comet
#

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

slate swan
paper sluice
slate swan
uncut comet
#

how can i do it?

gentle sphinx
#

What is the best discord bot library that supports slash commands?

slate swan
#

i mostly use disnake as its quite easy

#

!pypi disnake

unkempt canyonBOT
gentle sphinx
ebon island
#

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

gentle sphinx
torn sail
slate swan
slate swan
# uncut comet how can i do it?

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

ebon island
#

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

torn sail
uncut comet
#

but i am doing it for slash commands

#

thats the issue

slate swan
uncut comet
#

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?

ebon island
#

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

maiden fable
#

the after is used to do stuff after the sound is finished, yes

maiden fable
ebon island
#

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

maiden fable
#

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

unkempt canyonBOT
#

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.
gentle sphinx
#

Why do I get this message when I try and run my bot

maiden fable
#

Windows issue

gentle sphinx
maiden fable
#

Eh

gentle sphinx
#

I can send the code if you want

ebon island
#

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?

maiden fable
#

yea sure @gentle sphinx

ebon island
#

oooh I could use partial probably!

maiden fable
ebon island
#

and pass in partial ctx as args that way

#

since partial is still considered a callable iirc

maiden fable
#
async def cmd(ctx, ...):
    def after(e):
        # u have access to e and ctx both
        print(e)
ebon island
#

ahh I see, I will try that solution 🙂 thank you btw

#

if that doesn't work I'll try partial next

maiden fable
gentle sphinx
ebon island
#

Partial is awesome

maiden fable
#

Yea seems like it haha

ebon island
#

you can load a callable with default arguments

maiden fable
#

Yea haha

maiden fable
gentle sphinx
#

very

maiden fable
#

Okay so, weird and noob question, but did u input the correct token?

#

sorry for the question

ebon island
#

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 🙂

maiden fable
#

Cool!

#

Thanks for telling me bout that btw. its gonna fix the issue of me using nested functions haha

maiden fable
gentle sphinx
maiden fable
#

@gentle sphinx what is yr disnake version?

ebon island
#

haha awesome, that is great to hear 🙂 I'm going to test it out, appreciate the assistance hunter!

maiden fable
#

If it is 2.4.0, then try asking in disnake

#

Cool! Best of luck

uncut comet
maiden fable
#

@uncut comet u cannot do that anymore

uncut comet
#

anymore?

gloomy meadow
#
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'```

uncut comet
#

there is no way of me being able to tell?

maiden fable
#

Since its a slash command now

#

And I don't think u can access the slash command invoker

uncut comet
#

but i had a bot which could tell

gloomy meadow
uncut comet
#

im just trying to recreate that bot

slate swan
uncut comet
#

but it is possble somehow

gloomy meadow
#

that's my user, that's me

maiden fable
gloomy meadow
#

no forget the spamming DMs it's a test, not a single message was sent

maiden fable
uncut comet
slate swan
gloomy meadow
#

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

maiden fable
gloomy meadow
#

I'd make it a bot.command then

#

it still doesn't work

torn sail
uncut comet
#

oh how can i use interaction.user? im still new to coding bots haha

maiden fable
#

He wants to get the slash command invoker via another bot

slate swan
torn sail
#

oh ok

torn sail
maiden fable
slate swan
#

i love the word guys

uncut comet
#

this is what i meant when i said there is a bot doing it

slate swan
#

im sorry its just a lovely class name

ebon island
#

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

maiden fable
maiden fable
unkempt canyonBOT
#

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:
maiden fable
#

This is used to run a blocking function tho, like PIL or requests

ebon island
#

similar but that docs link will be very useful ❤️

slate swan
pliant gulch
unkempt canyonBOT
#

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:
pliant gulch
#

This is also pretty useful

maiden fable
#

???

maiden fable
torn sail
#

no

slate swan
#

mhm

#

i thought it did

maiden fable
uncut comet
#

okay could it count as a reply? how can i see if a message is a reply to someone?

torn sail
slate swan
#

yeah ik

unkempt canyonBOT
#

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.

maiden fable
#

Like someone bumps using disboard bot and the bot sends the author of the bump command

vale wing
#

Ok

maiden fable
#

Is it counted as a reply?

#

Idk

vale wing
#

Is there a matter really

#

Every interaction message is basically a reply cause it can only be sent in response to interaction

maiden fable
#

Ah

uncut comet
#

nevermind i get None

#

doesnt count as reply

maiden fable
#

Thought so

pliant gulch
unkempt canyonBOT
#

@pliant gulch :x: Your eval job timed out or ran out of memory.

bar
vale wing
#

Lmao

maiden fable
maiden fable
#

@uncut comet

uncut comet
#

yea

pliant gulch
maiden fable
#

can u print the type of that message? print(message.type)

pliant gulch
#

Although for PIL I recommend just running this in a whole different thread

uncut comet
#

yes

#

give me a sec

maiden fable
vale wing
#

Today I started hosting bots on intel celeron d

maiden fable
#

What VPS

slate swan
vale wing
maiden fable
vale wing
#

😏

uncut comet
maiden fable
vale wing
maiden fable
#

!d disnake.MessageType.application_command

unkempt canyonBOT
maiden fable
#

Lemme see

vale wing
#

@uncut comet I don't quite understand what you are trying to do

maiden fable
uncut comet
#

yea that

#

hahahaha

vale wing
#

Every interaction message is response to "abstract" slash command message

#

!d disnake.ApplicationCommandInteraction.author ?

unkempt canyonBOT
maiden fable
vale wing
#

How

maiden fable
#

Cz its not his command

vale wing
#

Oh he wants to do it other way

maiden fable
#

he is using an on_message and seeing the type of the message

uncut comet
#

the command is to a different bot

vale wing
#

Ok weird thing

uncut comet
#

and im trying to pick it up from my bot

vale wing
#

Lemme resolve this

pliant gulch
vale wing
#

!d disnake.Message.interaction there ya go @uncut comet

unkempt canyonBOT
#

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.

uncut comet
#

okay i have a dumb question

maiden fable
#

No question is dumb lol but okay

vale wing
#

🎉

uncut comet
#

this is disnake im not using disnake so do i need to try to switch to disnake to do that??

slate swan
#

how would i use proxies when sending req to website

#

like there in txt

uncut comet
vale wing
slate swan
#

why would you use proxies

maiden fable
#

Imagine having an SSD and still slow speeds

slate swan
slate swan
vale wing
maiden fable
#

And yea, my SSD supports read write speeds of upto 600 MB or smth

slate swan
slate swan
maiden fable
vale wing
#

😩 gl

slate swan
uncut comet
# vale wing What version

good question i have no clue it says discord.py @ git+https://github.com/Rapptz/discord.py@4dc24a005a5f78c1fc004667dd5241c8fc3eb253

maiden fable
#

The above is my folder of all the coding projects

maiden fable
vale wing
#

!d discord.Message.interaction same thing should exist

unkempt canyonBOT
maiden fable
junior verge
#

!code

unkempt canyonBOT
#

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.

slate swan
vocal snow
#

What is an ip ban

maiden fable
#

Zeffo, stop acting like udk how to make a discord bot

slate swan
#

fr

maiden fable
#

U r better than any of us here

slate swan
#

fr

vale wing
slate swan
#

smh

maiden fable
#

Lmao

uncut comet
maiden fable
pliant gulch
#

Smh why don't websites just HWID ban 👿

maiden fable
#

What is that now

vocal snow
#

Nullptr 😱

vale wing
#

Imagine mac address ban

maiden fable
vale wing
#

😡

uncut comet
maiden fable
#

hahaha

slate swan
uncut comet
#

jesus

maiden fable
slate swan
#

imagine

pliant gulch
maiden fable
#

My phone does

vale wing
#

Identity documents ban 😀

maiden fable
#

Might as well ban the hardware of the device

slate swan
#

epic games bans hardware lol

maiden fable
#

Damn the speeds went upto 200 all of a sudden

#

Lmao what is even wrong with W11

vale wing
#

Me when I was dumping ubuntu iso into the flash drive

maiden fable
#

Haha

#

For some reason Windows doesn't utilize the full SSD speeds

vale wing
#

Except speed was like 200kbps

slate swan
#

💀

maiden fable
#

I feel u

vale wing
maiden fable
#

Wait really?

vale wing
#

You are copying many files as well

maiden fable
#

That is the issue then. Its copying files which are like 1 KB in size rn

#

Yk small config, xml and ini files

vale wing
#

Yes cause it gotta manage space for them, some metadata etc

#

That's what slows it down

maiden fable
#

Understandable

vale wing
#

Not the actual data transfer speed

uncut comet
#

THANK YOU

maiden fable
#

Works?

uncut comet
#

hahaha i got it working

vale wing
#

Gg

maiden fable
#

Ay gg!

slate swan
#

bro

#

why do you guys say gg

#

this is not a gamelemon_glass

maiden fable
#

good going

slate swan
#

no

uncut comet
#

thanks guys been trying to do that for a while

slate swan
#

it means good game

maiden fable
slate swan
#

whos that

vale wing
slate swan
#

bro

vale wing
slate swan
#

THE LINK SAID IT ALL

#

🙀

ebon island
#

green guacamole

slate swan
#

bro

ebon island
#

goodness gracious

maiden fable
#

Lmaooo

slate swan
ebon island
#

😄

vale wing
slate swan
#

do you guys have any project ideas?

maiden fable
slate swan
#

how do i print my bot's status, ex: online, dnd, idle and invisible

ebon island
#

project ideas meaning what?

vale wing
#

I mean yesterday cause it's 0:06

maiden fable
unkempt canyonBOT
#

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.
slate swan
slate swan
#

not member status\

maiden fable
#

ctx.me.status

#

ctx.me returns the Member object of the bot

slate swan
#

oh that

slate swan
maiden fable
#

Mhm

vale wing
#

Member can be a bot

#

😀

slate swan
#

ok then help me make a function

#

where every like 5 minutes

vale wing
#

Gonna say more they are users

slate swan
#

itll try

#

to run the function

#

and the function is checking the bot status

vale wing
#

tasks.loop + bot.user.status

slate swan
#

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

vale wing
#

All you need

slate swan
vale wing
#

It's gonna be like 3 strings minimum

maiden fable
#

@vale wing do u know bout partitions and stuff?

vale wing
#

I know good article about them if you want that

#

Extending them or smth

slate swan
maiden fable
#

Well I wanted some help regarding those, if u can

vale wing
#

One sec if I can find it

maiden fable
#

Thanks

vale wing
#

It's about extending them

maiden fable
#

That is what I want help with lol

#

Its a pretty complex problem

vale wing
maiden fable
#

Linux 😔

vale wing
#

You needed windows?

maiden fable
#

Mhm

slate swan
#

💀

maiden fable
#

I am using W11

vale wing
slate swan
slate swan
#

pop os

vale wing
#

@maiden fable so you need help with partitions in w11?

maiden fable
#

yea

vale wing
#

You just need disk manager / partition wizard / device manager whatever it is called and everything is pretty easy to figure out there

maiden fable
#

Ik it is easy haha

vale wing
#

If you wanted to change the filesystem like gpt and mbr it's cringe

slate swan
#

😈

maiden fable
#

I just want to allocate that unallocated space to C drive without deleting D

vale wing
#

I think there's extend button

slate swan
#

discord py = how to print bot status, like: online, idle, dnd and invisible

maiden fable
vale wing
#

It automatically consumes unallocated space

maiden fable
#

@slate swan I told u

vocal plover
slate swan
maiden fable
#

Should I instead use AOMEI

slate swan
#

nonetype has no attr status

#

.............................

maiden fable
#

bot didn't even start properly

slate swan
maiden fable
#

bot.run()

slate swan
#

?

#

so i put it after\

ebon island
#

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

slate swan
#

still doesnt work

ebon island
#

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

slate swan
#

AttributeError: 'ClientUser' object has no attribute 'status'

#

@maiden fable

maiden fable
#

ctx.me.status

slate swan
#

YOU TOLD ME

#

bot.user.status

#

OH OK wrong person

#

@maiden fable HOW CAN I USE IT ON_MESSAGE

maiden fable
slate swan
maiden fable
#

message.guild.me.status

pliant gulch
#

inb4 message is in DM and it errors

maiden fable
#

Lmao

slate swan
#

and andy called it

maiden fable
#

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

maiden fable
#

Andy correct as usual 😔

slate swan
maiden fable
#

I have to go sleep, it's already 3

slate swan
#

!d discord.Message.author

unkempt canyonBOT
slate swan
#

!d discord.Member.status

unkempt canyonBOT
#

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.
slate swan
#

done

sinful wind
#

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

maiden fable
#

Uh

#

He wants the bot status @slate swan

pliant gulch
maiden fable
slate swan
unkempt canyonBOT
#

property status```
[`Status`](https://discordpy.readthedocs.io/en/master/api.html#discord.Status "discord.Status"):
The status being used upon logging on to Discord.
slate swan
#

what

maiden fable
#

Bruh, now I feel..... shit

slate swan
#

theres no way

maiden fable
#

Since bot.user.status isn't a thing, I thought Bot.status won't also be one

pliant gulch
#

Oh woops I meant bot.user.status

maiden fable
#

Lmaooo

pliant gulch
#

Wait bot.user.status isn't a thing?

slate swan
#

uh\

#

no

slate swan
maiden fable
pliant gulch
#

I'll take it. Pure luck

maiden fable
#

andy, Mission Failed Successfully

slate swan
#

i swear that wasnt a thing

maiden fable
#

Wait, I remember

#

status is a kwarg in the constructor

slate swan
#

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

unkempt canyonBOT
#

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...
sinful wind
#

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

slate swan
#

most pycord tutorials are bad like the lib, i would just use main

slate swan
#

just show me

#

bro

sinful wind
slate swan
sinful wind
#

to be honest I've never seen such disorganized information about a library before

slate swan
#

yeah its very overrated

sinful wind
#

disnake?

slate swan
#

!pypi disnake

unkempt canyonBOT
slate swan
sinful wind
#

and how come you like this one?

slate swan
#

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?

slate swan
slate swan
#

uh\

#

google\\\\

slate swan
sinful wind
#

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?

sinful wind
#

I was earlier

boreal ravine
#

I mean port your code to d.py

slate swan
#

bro

boreal ravine
#

that's some py-cord shit

slate swan
#

i even tryied do not disturb status

cloud dawn
sinful wind
#

I'm not in Pycord

slate swan
#

but he isnt using it so lol

boreal ravine
slate swan
#

;((((((((((((((((((((((((((((((((((((((((((((

sinful wind
#

so then do the docs need to be updated?

slate swan
#

🗿

#

if message.content == 'dnd':
await bot.change_presence(status=discord.Status.dnd)

sinful wind
#

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

slate swan
#

disnake

sinful wind
#

alright then

slate swan
#

some examples that will work ~~ mostly~~

sinful wind
#

Nice I was looking for something like that!

#

thank you

slate swan
#

youre welcome!

slate swan
#

if message.content == 'dnd':
await bot.change_presence(status=discord.Status.dnd)

ebon island
#

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

sinful wind
#

@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

slate swan
#

whats wrong here? 🤔

winged bone
slate swan
#

.

#

didnt even notice i did that

#

How can you turn the messages into an embed?

slate swan
#

what error

brave forge
slate swan
#

git isnt installed lol

reef dock
#

all python discord bots are set to stop working in a couple of hours unless on version 2.0 of discord.py correct?

slate swan
#

how do i know youve already been here lol

slate swan
#

because the api changes are setback to 2023

#

iirc

reef dock
#

when did this happen 🤔

slate swan
#

rip

#

weird

#

or what?

#

🙀

slate swan
reef dock
#

👌

brave forge
#
  bot.load_extension(f'cogs.{filename[:-3]}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
slate swan
#

await it

#

its a coro in 2.0

#

bro what