#discord-bots

1 messages · Page 506 of 1

hasty iron
#

cant you just try-except the import?

maiden fable
hasty iron
#

can you explain your question

maiden fable
#

so, in this code, I want my bot to automatically check if time is in the list of modules and if it is, then add a line import time into the code

hasty iron
#

how are you going to get the list of imports

#

and how are you going to know whats imported

#

and whats not

maiden fable
#

I can use sys.modules and sys.builin_module_names to get the list of modules and check if the module name is in any of them

#

And I can use an except with NameError, and do all this in that block

grim oar
#

Why not do it how jishaku does itpithink

maiden fable
#

I have my own working eval

#

wait nvm

grim oar
#

Jus see how they do it lol

maiden fable
#

I misread understood your question

#

Ah, well I didn't know jsk can do that. I'mma see how they do it. Thanks for the headsup!

hasty iron
fallow mauve
#

can someone help me im wanting to learn how to use embeds for my bots help menu

maiden fable
hasty iron
#

you have code a string

hasty iron
#

and you say you want to check sys.modules

fallow mauve
hasty iron
#

that means you'll have to parse the code

maiden fable
#

Yea

#

Well, I won't be checking the code in the start itself

grim oar
maiden fable
#

I would just catch NameError exception

#

and get the name which raised the error

#

if the name is a module, then add an import line in the code, else just send the error

hasty iron
#

what if the NameError was raised on something thats not a module

hasty iron
#

sys.modules are the currently imported modules

maiden fable
#

Oh

hasty iron
#

oh wait nvm

#

wait

#

no im right

maiden fable
#

Well it is a list of loaded modules, as said by Python docs

#

so yea, lemme see if there is any other way

hasty iron
#

just check how jishaku does it with module!

maiden fable
#

Hmm okay

#

BTW, wanted to ask another thing

grim oar
#

Ig they use ast? I haven't seen the impl myself

hasty iron
#

they must

#

i see no other way tbh

grim oar
#

Yeah same

maiden fable
#

I am making a deco (first time), and was trying to get the ctx object. So I should do args[0] to get it?

hasty iron
#

cant you just do def wrapper(ctx, *args, **kwargs)

maiden fable
#

That gonna work? Dang

#

ah wait, nvm. I am just mentioning one param instead of getting from args

hasty iron
#

if its always passed in as the first argument yes

maiden fable
#

Gotcha

#

Well, what if it is self, the first param? I don't really know

hasty iron
#

check the type?

#

idk

maiden fable
#

Okay

#

PyLance having a stroke. Bruh

grim oar
#

Andy won't like that Callable typehint 😩

hasty iron
#

also its better to do Callable[..., Any]

maiden fable
hasty iron
#

because its not complete

maiden fable
hasty iron
#

and not correct

grim oar
maiden fable
#

Oh okay

#

Wait, so I was seeing this code from a friend... Why do they have this?

hasty iron
#

have what

maiden fable
#

Nvm

grim oar
#

The typehint?

maiden fable
#

Nvm, he was checking if the command is a class

#

the loop var

grim oar
#

:loading:

maiden fable
#

Haha MyHelp is a class

grim oar
#

Hmm

hasty iron
#

i think he can just check if the function has the __self__ attr

maiden fable
#

Oh okay

hasty iron
#

nvm

grim oar
#

What if its a classmethod

#

eeeee nvm

maiden fable
#

A command and a class method?

#

:stare:

hasty iron
grim oar
#

Don't mind me, I thought it wasn't a command

maiden fable
#

I think I'mma do

if isinstance(args[0], Context):
    . . . . 
grim oar
#

That's a bad Ellipsis!

maiden fable
#

Uhhh, what?

hasty iron
#

!e ```py
print(...)

unkempt canyonBOT
#

@hasty iron :white_check_mark: Your eval job has completed with return code 0.

Ellipsis
grim oar
#

Can you be slow like a lil :crying:

maiden fable
#

Ah, well it was just some context I was giving

maiden fable
#

So in a Cog, self will always be the first param... Gotcha

hasty iron
#

staticmethods laughing

grim oar
#

in a class, every instance method will

#

and properties

maiden fable
#

I don't use them

#

idk why tbh

grim oar
#

when I use them I get called dumb so you shouldn't.

reef shell
maiden fable
#

Haha

hasty iron
#

you're always dumb nova

maiden fable
grim oar
#

How to be smort as you

#

like you

maiden fable
#

pithink how to fix this now

fallow mauve
#

whats wrong with this?

maiden fable
#

(I suck at typehinting)

maiden fable
fallow mauve
#

?

maiden fable
#

remve the ()

fallow mauve
#

ok

grim oar
#

why ctx is optional there haha

reef shell
#

why would you set ctx = None

maiden fable
#

BTW Nova, do u know this?

reef shell
#

like None.send

maiden fable
#

why is it showing Unknown?

hasty iron
#

cuz you have to do Context[Bot]

#

or your own Bot subclass

maiden fable
#

Oh

grim oar
#

Idk much about typehint stuff sry

unkempt canyonBOT
#

discord/ext/commands/context.py line 69

class Context(discord.abc.Messageable, Generic[BotT]):```
hasty iron
#

see the Generic

maiden fable
#

Ah

grim oar
#

Typehints are bad too

#

They must not exist

maiden fable
grim oar
#

static typing will be future

maiden fable
fallow mauve
# maiden fable remve the `()`

my error:

main.py:149: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
  await ctx.send(embed = discord.Embed(title="test 1", description="test 2", colour=0xffb300()))
grim oar
maiden fable
#

That is what I told...

grim oar
#

Not always but when things start getting deeper into the hole

hasty iron
#
-> Callable[[Callable[[Request, HTTPException, Union[PartialRoute, Route]], Coro]], 
            Callable[[Response, HTTPException, Union[PartialRoute, Route]], Coro]]:
``` not very complex
fallow mauve
grim oar
#

Indeed

fallow mauve
hasty iron
#

you probably didnt close a (

fallow mauve
#

thx

#

thats what it was

placid skiff
#

Someone please can check this? It keep raise ExtensionNotFound but i can t understan why

maiden fable
#

Weird

placid skiff
#

Really 😂

#

This is driving me crazy

sacred folio
#

the rain destroyed me. anyways

      new_embed = embed_message.embeds[0]
      tempTuple = new_embed.fields[0].value
      tempList = list(tempTuple)
      tempList[1] = "test"
      tempTuple = tuple(tempList)
      new_embed.fields[0].value = tempTuple

      print((new_embed).fields[0])

      await embed_message.edit(embed = new_embed)
#

@hasty iron if youre still here 🙂

hasty iron
sacred folio
#

well the problem really seems to be that when i do "new_embed.fields[0].value = tempTuble"

#

when i print it, it doesnt seem like it updates the embedded tuple

#

because i understand that tuples cant be changed, but they should be able to be replaced right?

maiden fable
#
async def wrapper(*args, **kwargs):
            if isinstance(args[0], Context) and not in_a_cog:
                ctx: Context[Bot] = args[0]
            elif in_a_cog:
                ctx: Context[Bot] = args[1]
            try:
                task = ctx.bot.loop.create_task(wait_for(fut=func(*args, **kwargs), timeout=timeout)) #type: ignore
                return await task
            except TimeoutError:
                return await ctx.send(f"Hey there! Sorry, but the command timed out after {timeout} seconds, {ctx.author}") #type: ignore

But then, in my eval it is raising an error that a kwarg (*, code) isn't being passed

hasty iron
#

why are you creating a task and then immediately awaiting it

maiden fable
#

Oh wait, nvm. I forgot to do functools.wrap()

hasty iron
#

just await the wait_for directly?

maiden fable
#

ah okay

slate swan
#

im having a really weird error with something being undefined, if anyone can help lmk

#

basically, i defined "buttons", but in my actual command where it says "await message.edit(components=buttons, embed=embed", it says buttons is not defined

sacred folio
#

show how you defined buttons, maybe i'll see something while waiting for help 😄

maiden fable
#

Okay so that doesn't work. Still blocks the bot haha

placid skiff
#

Define buttons as a Button object

slate swan
#

one moment

slate swan
# sacred folio show how you defined buttons, maybe i'll see something while waiting for help 😄
    buttons = [
          Button(style=ButtonStyle.grey, label = '1'),
          Button(style=ButtonStyle.grey, label = '2'),
          Button(style=ButtonStyle.grey, label = '3'),
          Button(style=ButtonStyle.grey, label = '×'),
          Button(style=ButtonStyle.grey, label = 'Exit')
        ],
    [
          Button(style=ButtonStyle.grey, label = '4'),
          Button(style=ButtonStyle.grey, label = '5'),
          Button(style=ButtonStyle.grey, label = '6'),
          Button(style=ButtonStyle.grey, label = '÷'),
          Button(style=ButtonStyle.grey, label = '←')
        ],
    [
          Button(style=ButtonStyle.grey, label = '7'),
          Button(style=ButtonStyle.grey, label = '8'),
          Button(style=ButtonStyle.grey, label = '9'),
          Button(style=ButtonStyle.grey, label = '+'),
          Button(style=ButtonStyle.grey, label = 'Clear')
        ],
    [
          Button(style=ButtonStyle.grey, label = '00'),
          Button(style=ButtonStyle.grey, label = '0'),
          Button(style=ButtonStyle.grey, label = '.'),
          Button(style=ButtonStyle.grey, label = '−'),
          Button(style=ButtonStyle.grey, label = '=')
        ]```
sacred folio
#

oh, so its an array or arrays of buttons,

slate swan
#

yes

sacred folio
#

does component accept that, have you tried feeding it like buttons[0][1] and see if it works?

slate swan
#
    @commands.command(aliases=['calc', 'c'])
    async def calculator(self, ctx):
      message = await ctx.send(content="Loading calculator...")
      await ctx.send(message, delete_after=3)
      expression='None'
      delta = datetime.utcnow() + timedelta(minutes=10)
      embed = discord.Embed(
        title=f"{ctx.author}\'s | {ctx.author.id}",
        description=expression,
        timestamp=delta
      )
      await message.edit(components=buttons, embed=embed)
sacred folio
#

instead of components=buttons -> components=buttons[0][1]

slate swan
#

should i change the components=buttons to components=buttons[0][1]?

sacred folio
#

because i know that for adding reactions, i couldnt await several ones in a single call, i had to do an await for each individually, so maybe something similar is happening

#

yeah, try that

junior verge
#

    embed = discord.Embed(
        title = f"{client.user.name} is online!",
        color = client.embed_color,
        timestamp = datetime.datetime.now(datetime.timezone.utc)
    )
    embed.set_footer(
        text = client.footer,
        icon_url = client.footer_image 
    )
    client.log_channel = client.get_channel(log_channel_id)
    await client.log_channel.send(embed = embed)
``` don't get what is wrong
dapper cobalt
#

What is embed_color?

#

There's nothing such as this. Try ctx.guild.me.color.

slate swan
maiden fable
#

Okay so

slate swan
#

great feeling

sacred folio
#

hmm, id like to see your code, where did you define it. does it have access to it

maiden fable
#
try:
                task = ctx.bot.loop.create_task(wait_for(fut=func(*args, **kwargs), timeout=timeout)) #type: ignore
                return await task
            except TimeoutError:
                return await ctx.send(f"Hey there! Sorry, but the command timed out after {timeout} seconds, {ctx.author}") #type: ignore

task is a blocking task, how to end it in the except clause?

dapper cobalt
paper rune
#

is it possible to send an embed without ctx?

maiden fable
#

If u have the channel object, sure

paper rune
#
       embedA=discord.Embed(title="GOAL")
        embedA.add_field(name=submission.title, value=submission.url, inline=False)
        await channel.send(embed = embedA)```
#

doesn't work

#

I have the channel and can send a message fine outside of an embed

maiden fable
hasty iron
#

then do ```py
task = loop.create_task(wait_for(*args, **kwargs))
try:
return await task
except TimeoutError:
task.cancel()
...

maiden fable
#

ah okay

fallow mauve
#

i dont understand this error

maiden fable
#

let's see

fallow mauve
maiden fable
#

U have a missing bracket in the preceding lines

fallow mauve
#

?

maiden fable
#

Still no work lol

fallow mauve
maiden fable
fallow mauve
#

but i dont

maiden fable
#

Bruh

fallow mauve
#

thats whats before it

#

wait

#

nvm

maiden fable
#

Lol

fallow mauve
#

my pc is garbage, it takes 2 minutes just to install everything

#

1 minute to install just embed

sacred folio
#

anyone who has a bit of tuple knowledge? 🙂

fallow mauve
# maiden fable Lol

my error:

Ignoring exception in command test:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 149, in test
    await ctx.send(embed = discord.embed(title="Fun Commands:", description=""))(embed.add_field(name="<ping", value="Bot replies with 'pong!'", inline=True)(embed.add_field(name="<poll2", value="starts a poll with 2 options.", inline=True)(embed.add_field(name="<poll3", value="Starts a poll with 3 options.", inline=True)(embed.add_field(name="<say [word]", value="Bot repeats what you say.", inline=True)(embed.add_field(name="<diceroll", value="Rolls a six-sided die.", inline=True)(embed.add_field(name="<mobprofile [mob name]", value="Bots sends the profile of the specified Minecraft mob.", inline=True)))))))
AttributeError: module 'discord' has no attribute 'embed'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord' has no attribute 'embed'
maiden fable
#

Embed*

elfin island
#

capital e discord.Embed

maiden fable
#

capital E

elfin island
sacred folio
#

i did, ill do it again

#
      new_embed = embed_message.embeds[0]
      tempTuple = new_embed.fields[0].value
      tempList = list(tempTuple)
      tempList[1] = "test"
      tempTuple = tuple(tempList)
      new_embed.fields[0].value = tempTuple

      print((new_embed).fields[0])

      await embed_message.edit(embed = new_embed)

well the problem really seems to be that when i do "new_embed.fields[0].value = tempTuble"
when i print it, it doesnt seem like it updates the embedded tuple
because i understand that tuples cant be changed, but they should be able to be replaced right?

fallow mauve
# maiden fable capital E

my new error:

the profile of the specified Minecraft mob.", inline=True)))))))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Ignoring exception in command test:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 149, in test
    await ctx.send(embed = discord.Embed(title="Fun Commands:", description=""))(embed.add_field(name="<ping", value="Bot replies with 'pong!'", inline=True)(embed.add_field(name="<poll2", value="starts a poll with 2 options.", inline=True)(embed.add_field(name="<poll3", value="Starts a poll with 3 options.", inline=True)(embed.add_field(name="<say [word]", value="Bot repeats what you say.", inline=True)(embed.add_field(name="<diceroll", value="Rolls a six-sided die.", inline=True)(embed.add_field(name="<mobprofile [mob name]", value="Bots sends the profile of the specified Minecraft mob.", inline=True)))))))
TypeError: 'Embed' object is not callable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Embed' object is not callable
maiden fable
#

Yea, you cannot do like that

fallow mauve
#

?

maiden fable
#

embed.add_field()

fallow mauve
#

huh?

#

then how

elfin island
sacred folio
#

well i can, but can i replace the old one easily? tryna learn the most efficient way to go about it

fallow mauve
#

can someone help me

sacred folio
#

what im trying to do is, i send an embed to the channel, with reactions on it. And then i want to track the people that react. My final step is to update the embed with the information every time someone reacts

elfin island
#

hm are you sure new_embed.fields[0].value is a tuple? i'd assume it'd turn out to be a string

fallow mauve
sacred folio
#

it is, i looked at it

#

@fallow mauve 🙂 its making me sweat at times hahah, ive never touched python

#

it looks like this when printed: EmbedProxy(name="test1", value="test2", inline=False)

sacred folio
#

and it says i cant mutate it because its a tuple when trying to directly change it

#

because im learning?

fallow mauve
#

same

elfin island
fallow mauve
#

but my embed wont work still

#

can someone help me with this huge error i have that i cant figure out?

slate swan
#

hello guys i wanted to know if anyone here knows how to fix this

CreateChannel = await guild.create_text_channel('mod-logs')
channel = discord.utils.get(ctx.guild.channels, name="mod-logs")

alright so i want to set the permissions off that channel so only administrators can see it is there any way to do that

elfin island
unkempt canyonBOT
#

discord/embeds.py lines 546 to 554

@property
def fields(self) -> List[_EmbedFieldProxy]:
    """List[Union[`​`​EmbedProxy`​`​, :attr:`​Empty`​]]: Returns a :class:`​list`​ of `​`​EmbedProxy`​`​ denoting the field contents.

    See :meth:`​add_field`​ for possible values you can access.

    If the attribute has no value then :attr:`​Empty`​ is returned.
    """
    return [EmbedProxy(d) for d in getattr(self, '_fields', [])]  # type: ignore```
slate swan
sacred folio
#

add_field for possible values you can access

#

thanks for clarifying, i assumed it was tuples because of its structure

slate swan
#

yoda

slate swan
#
CreateChannel = await guild.create_text_channel('mod-logs')
channel = discord.utils.get(ctx.guild.channels, name="mod-logs")

how can i set this channels permissios to administrator oly

vestal owl
#

Is there something called a checkerror if the check in await bot.wait_for() fails?

vestal owl
#

no

slate swan
vestal owl
#

not timeout

slate swan
#

??

vestal owl
#

checkerror

slate swan
vestal owl
#

if the condition hasn't been satisfied

slate swan
#

await channel.set_permissions(guild.default_role, viev_channel=False)

slate swan
#

otherwise no

vestal owl
slate swan
#

only administrators

vestal owl
#

yep

slate swan
#

administrators will see the channel anyways

vestal owl
#

is there a way to make it role specific though?

#

I've been having a problem with this

slate swan
#

await channel.set_permissions(yourRoleInstance, viev_channel=True)

slate swan
vestal owl
#

yourRoleInstance would be like special role right?

slate swan
#

it doesn't matter

#

just a role

#

discord.Role instance

slate swan
#

use logic to spare code

#

bruhkitty

fathom hound
#

Is there any way to catch a specific error that was raised by a command? I'm aware CommandInvokeError can somewhat catch that, but it's too ambiguous and can mean literally any command error. How can I catch a defined error that was raised by a command?

fathom hound
#
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AccountNotFound: UID None isn't associated with any server```
wicked quest
#

do research mate 💀

fathom hound
spring flax
fathom hound
#

Oh no, it's not really a Discord exception. It's a different library. But yeah, basically I'm not sure how to catch a suberror(?) from a CommandInvokeError.

spring flax
#

No idea what that is but for example you can use
if isinstance(error, commands.MemberNotFound): for dpy membernotfound error

sly cliff
#

How do you connect Spotify to a discord bot

#

Like let the user play Spotify with the bot

boreal ravine
#

tos?

dapper cobalt
#

Do you mean stream music from Spotify into a voice channel?

boreal ravine
#

yes

dapper cobalt
#

If so, that's against Spotify's Terms of Service. Therefore, we cannot assist you with that.

#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

pliant gulch
#

!d discord.ext.commands.CommandInvokeError.original

unkempt canyonBOT
crystal cliff
#

How do, I link a main py file, to a cogs, music file?

crystal cliff
#

I’m trying to make a music, bot. But I Getting a error, linking them.

tough wagon
#

ok...

crystal cliff
tough wagon
fathom hound
vestal owl
#

!check

#

!d check

unkempt canyonBOT
#

django-admin check [app_label [app_label ...]]```
vestal owl
#

!d await discord.wait_for

unkempt canyonBOT
vestal owl
#

..

tough wagon
#

@vestal owl #bot-commands pls, thanks

hasty iron
unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
vestal owl
#

thank you mate

soft lake
#

Hello guys

reef shell
#

Hi

soft lake
#

can someone tell me how to add auto reply on my bot

tough wagon
#

wdym as autoreply?

#

there is discord.Message.reply

unkempt canyonBOT
#

await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.6.
reef shell
#

or

#

what

tough wagon
#

Context.reply

unkempt canyonBOT
#

await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.6.
reef shell
#

i forgot

soft lake
tough wagon
reef shell
soft lake
soft lake
#

can someone help me

hasty iron
#

you need to learn more python

#

clearly you don’t know enough to be using discord.py

#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
vestal owl
#
primary_txt = str(message.content)
            print(primary_txt)
            translator = Translator()
            transl = translator.translate(primary_txt, src = translator.detect(primary_txt), dest = lang)
            print(transl)```

Error:
```  File "C:\Users\minua\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\googletrans\gtoken.py", line 62, in _update
    code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'```
What does this mean?
hasty iron
#

its an issue with the lib

vestal owl
hasty iron
vestal owl
hasty iron
#

did you even read the comments

vestal owl
#

nvm

vestal owl
# hasty iron did you even read the comments
primary_txt = str(message.content)
            print(primary_txt)
            translator = Translator()
            print(translator.detect(primary_txt).lang)
            transl = translator.translate(primary_txt, src = translator.detect(primary_txt).lang, dest = lang)
            print(transl)```
#

does this look right to you?

hasty iron
#

i never used the lib so idk

vestal owl
#

because this is my feedback from console:

Finished
en
Translated(src=en, dest=ar, text=Finished, pronunciation=Finished, extra_data="{'translat...")```
#

ah

slate swan
#

anyone mind helping me?

#

i am trying to make cogs for my bot, but it does not seem to work. Could someone help

#
    if filename.endswith('.py'):
        initial_extensions.append("cogs." + filename[:-3])``` ‎||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://khadz.fuckedyourmom.today/​‌‌​‌​‌​​‌‌‌​​‌​​​‌‌​‌‌​​​‌‌​​‌‌​‌‌​‌​​‌​‌‌​‌‌‌‌​‌​​‌​​‌​​‌‌​​​‌
kindred epoch
slate swan
#

how did i forget that omg 😭

kindred epoch
#

😭 why did you not read the error omg

slate swan
steady flume
#

This is MongoDB

#

Pls help me

kindred epoch
steady flume
#

Ru

#

Ty*

sacred folio
#
def check(reaction, user):
      if (str(reaction.emoji == emoji_yes) and client.user != user):
          return reaction.users()

reaction, user = await client.wait_for('reaction_add', check=check)

I use this to handle players that react on an embed, is there anyway to retrieve, basically a 'reaction_add' equivalent for whenever a user removes their reaction?

slate swan
# kindred epoch <#342318764227821568>

how do i fix this, ‎||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://khadz.fuckedyourmom.today/​‌​​‌​​‌​‌​​‌‌‌‌​‌​‌‌​‌​​‌‌‌​​‌​​​‌‌​‌​​​‌​‌​‌‌​​​‌‌​​‌‌​‌​​​‌​‌

kindred epoch
slate swan
kindred epoch
#

if you know enough python then you should be able to understand what im trying to say

slate swan
#

ive watched a few tutorials

sly cliff
#

How do we create a trivia bot

kindred epoch
slate swan
kindred epoch
slate swan
#

like a 1 hour course

#

for beginners

kindred epoch
#

freecodecamp?

#

ig thats ok

#

discord.py is not ment for people who just started coding py

#

so learn more of python first and then come back to this lib

#

is there any efficient way of sending an embed every last day of the month on 12 am est?

#

!d asyncio.sleep

unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3.10/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
manic wing
#

import asyncio asyncio.sleep(1) # stops asynchronously for a second

unkempt canyonBOT
#

random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
kindred epoch
#

hm

#

ye use that, so add a number in the position of a and another one in b

#

and import random

#

so if a is 1 and b is 10

#

it will pick a random number between 1 and 10

#

if you want 3 digits

#

then do 100 and between some other 3 digit number

#

wdym

#

it will only select a random number between the numbers you give it

#

do you want 3 random numbers or 3 digit random numbers?

hasty iron
#

they want 3 digit random numbers

#

your thing of doing randint(100, 999) wont work cuz they want numbers to be 001 and 090 for example

kindred epoch
#

ah

#

uh

#

ig youll just have to use random.randint 3 times?

slate swan
#

how could i make a global sleep time sort of thing,

for example if 5 users join across 5 different servers, on the member join event i want it to wait x amount for each dm across 5 servers(so dms are not fast and trigger antispam) - for welcome dms

hasty iron
#

if you have numpy installed you could use numpy.random.default_rng

severe mural
#
@cooldown(1, 86400, BucketType.user)
@commands.has_any_role("europe1")
async def promoeu1(ctx):
    channel = client.get_channel('892884253875007529')
    for i in range(1):
        await channel.send("f{ctx.author.mention}, Thanks you see check DM") 
        await ctx.author.send("Code your: **The code is not available code**")
        await asyncio.sleep(1) 
        await ctx.message.delete()```
#

problem error D:

hasty iron
#

that will raise other errors

#

why are you using range?

#

and get_channel takes in an int not a string

severe mural
#

@hasty iron hmm how you please write explain?

#

but sorry my no idea lol

#

no is "" change example

#

channel = client.get_channel(892884253875007529) no?

severe mural
#

is work

hasty iron
#

string wont be defined

#

string is still not defined?

#

i dont even get what you mean by test = string()

severe mural
hasty iron
#

do you want an empty string?

severe mural
#

@hollow iron oh

sly cliff
#

I thought we would have to do something complex?

severe mural
#

wait seconds

kindred epoch
severe mural
#

@hollow iron yes work thanks.

hasty iron
kindred epoch
hasty iron
#

how?

kindred epoch
#

idk lmao

#

but might just be

hasty iron
#

99% of the time you’re going to use an api for facts or stuff like that

#

which isn’t even close to complex

kindred epoch
#

true

#

@sly cliff do you want random facts?

#

seems like a good lib

civic saddle
#

are there any tutorials on making global chat bots?

pale vessel
neon cradle
#

is it possible to turn a selenium webpage element found through xpath into binary form without saving it to send to discord

#

tl;dr take picture of website part and send to discord with most efficient solution

slate swan
#
Extension 'cogs.Anti' raised an error: ModuleNotFoundError: No module named 'motor'
#

nvm

#

!d discord.Client.wait_for

#

is it possible to change the bots discord pfp w a command

jade jolt
#

why

hasty iron
#

yes

#

!d discord.ClientUser.edit

unkempt canyonBOT
#

await edit(*, username=..., avatar=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the current profile of the client.

Note

To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") is given through the use of `fp.read()`.

The only image formats supported for uploading is JPEG and PNG.

Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned.
agile shadow
#

Ok, so I have this function here,

    async def init_bot(self, bot: commands.Bot, get_locale_func: Callable[..., Coroutine[Any, Any, Any]] = None):
        self._bot = bot
        if get_locale_func is None:
            # Just use the fallback
            get_locale_func = lambda *_: self._fallback

        async def pre(ctx):
            await self.set_current_locale(await get_locale_func)

        self._bot.before_invoke(pre)```

And the issue is that i need to pass `ctx` to `await get_locale_func`, but either removing/keeping it gives me:

passing `ctx` (calling it):
```py
TypeError: 'coroutine' object is not callable```

, but removing `ctx` gives me

```py
   return preferences[ctx.author.id]
AttributeError: 'cached_property' object has no attribute 'id'```
#

I don't know how to pass ctx without calling get_locale_func, or I don't even know if I have to call get_locale_func anyways, it's weird and if anyone could explain I'd gladly appreciate

slate swan
#

Anyone knows how to edit the message a bot sends TO AN EMBED.

Ik how to do it normally ofc... message.edit(content="") problem is since content is a kwargs i can't really do content=embed=myembed i tried putting it in parethesis too like (content=(embed=myembed)) but that didnt work either it gives me a syntax error for sum reason

So what do I do?

jade jolt
#

message.edit(embed=newembed)

slate swan
#

wait i can do that??

jade jolt
#

yes?

slate swan
#

content is a kwargs

#

keyword argument

jade jolt
#

it takes the same kwargs as .send

slate swan
#

alr if u say so

jade jolt
#

iirc

#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
jade jolt
#

@slate swan

slate swan
#

hmm

#

cool

#

OHHHH

#

embed is a kwargs too 🤣

jade jolt
#

yeah

#

if u want like 3 in one message

#

max is 10 ^

slate swan
#

cool

jade jolt
#

hope it works

frosty hornet
#

how do i get a list of all members in a server

slate swan
#

why is this happening to my pymongo database?

slate phoenix
unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
slate swan
#

if message.content.startswith(messsage.role_mentions[0]):

guys im kinda stoopid today, tryna figure out how to make this actually work

#

this is off of a client.wait_for "on_message" function

frosty hornet
slate phoenix
frosty hornet
slate phoenix
#

what

#

no

frosty hornet
#

it gives me <class 'discord.member.Member'>

slate phoenix
#

you would have to do players = ctx.guild.members

frosty hornet
#

that doesnt work. it only gives me the bot itself

slate phoenix
#

that means you dont have members intents on

#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").

New in version 1.5...
frosty hornet
#

o

#

ok ill try enabling them again but i tried with a bot that has intents and it still doesnt work

#

but ill try again

slate phoenix
#

only enabling them in the dev portal wont work

#

you have to pass it through your constructor

#
intents = discord.Intents.default()
intents.members = True

bot = commands.Bot(command_prefix=prefix, intents=intents)
slate swan
#

his function says pickplayer

#

or does it mean random player?

slate phoenix
#

hes trying to get a list of all the members

#

i assume random

slate swan
#

of it random

#

then he can use do for members in ctx.guild.members B)

#

oh actually

#

wait i take that back

#

he can do what u said earlier with the players = ctx.guild.members

#

then use the random module

#

to choose a random player out of that list

#

that would be alot more efficient

slate phoenix
#

yep just an intents issue

slate swan
slate phoenix
slate swan
#

@slate swan

slate swan
slate swan
#

dunno anything about that

supple thorn
slate swan
#

idk why tf it corrected to data-sciense 🥴

#

i did shift+enter so it does it for me

dusk karma
#

For some reason, it says it isn't defined.

slate swan
dusk karma
#

First image.

slate swan
#

u gotta define stat before assignment-

#

How much experience u have wiht python?

dusk karma
#

Barely. I'm learning.

slate swan
#

this is basic stuff, u should be learning python before discord.py

#

or ur gonna struggle hard

#

trust me i tried the same thing, omg the pain

dusk karma
#

Alright. Thanks.

slate swan
#

anyways yeah

dusk karma
#

Swapped them around and the darn error is gone.

#

👍

slate swan
#

yep there ya go

#

is it ctx.reply(content=) or ctx.reply(embed=)

slate swan
#

not easy to understand things and errors

#

syntax

#

a

#

!d discord.Message

#

!d discord.Message.reply

unkempt canyonBOT
#

await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").

New in version 1.6.
slate swan
#

!okay

#

@slate swan there

#

just go on there and check the attributes

#

it supports

patent lark
slate swan
#

make sure its used on a message object

patent lark
slate swan
patent lark
#

ah okay

slate swan
#

he referenced after assignment

#

wait im dum

#

other way around lmao

#

before assignment

patent lark
#

yeah haha

slate swan
#

yeah i confused what referenced and assignment means there , we dont talk about that

patent lark
#

haha thats alright, we make mistakes like that sometimes~

slate swan
#

yee

final iron
#

Yall got any ideas for commands? Im kinda hitting a block because i've reached my python level cap

slate swan
#

oh I actually need some help as well

slate swan
#

using raw_on_reaction_add

final iron
patent lark
#

:)

slate swan
final iron
#

Ig I could make it for me only

slate swan
#

take it or leave it B)

final iron
#

How would I get started with an eval command?

slate swan
#

is how i did it

patent lark
#

yeah, for sending an embed you'd use the embed kwarg

slate swan
#

and is anyone here familiar with discord-components?

slate swan
slate swan
#

im trying to make a button, and when the button is clicked an ephemeral embed sends

#

u would know better

final iron
#

How would I get started with making an eval command?

slate swan
slate swan
patent lark
final iron
slate swan
slate swan
patent lark
#

excuse me

slate swan
#

🤣

patent lark
#

its discord.ext lol

slate swan
#

fff

patent lark
#

kill me

slate swan
#

oh u mean using
message.edit(embed=)?

#

talking about those buttons where u react to it moves to another "page"

#

when really it jsut edits a button

patent lark
#

why does it-

slate swan
#

🤣

#

audit log docs?

#

cap

#

this right?

final iron
#

Why would I need to make one?

#

Can't I just cut it off after a certain amount of lines

slate swan
#

how do i use this for channel_create and others

slate swan
#

good luck my boi, u gonna need some modules for that

#

also it might be hard for u since google kinda fricked over some popular music bots like rythm & groove for the same reason

#

using c o p y r i g h t e d m u s i c

#

imagine

#

they should be blaming the modules not the bots

final iron
#

What would I do after I create a paginator for an eval command?

#

Is there a built in function to execute command?

#

Or would I have to build it myself?

pliant gulch
#

Does not make any sense to me

slate swan
#
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 109, in on_ready
    title(f"[NukeX | chasa.wtf] Waiting for {PREFIX}n in guild..")
  File "main.py", line 48, in title
    ctypes.windll.kernel32.SetConsoleTitleW(content)
AttributeError: module 'ctypes' has no attribute 'windll'```
pliant gulch
#

NukeX? 🤔

hasty iron
#

and why windll

#

thats like only used with selfbots

slate swan
#

bro

hasty iron
#

(from the code ive seen so far)

slate swan
#

so helping or...?

pliant gulch
#

This server does not help with selfbots

hasty iron
#

there is no reason for you to be using ctypes inside a discord.py environment

slate swan
#

bro

#

just help

hasty iron
#

i mean, isnt the error a bit too clear

slate swan
#

bro idk

#

just help

slate swan
hasty iron
#

it is

pliant gulch
#

Did you mean @help.command()?

slate swan
#

instead try teaching me

slate phoenix
slate swan
#

whats a selfbot??

#

I dont even know

hasty iron
#

are you even on windows

slate swan
#

I am windows

slate phoenix
#

post your full code for the command that errors

hasty iron
#

what

pliant gulch
#

I don't see the point of using a fork right now though

hasty iron
#

they dont help with third party libs

pliant gulch
#

No need to move imo until it does or beforehand

slate swan
#

This is all the code that involves it: ```py

-- coding: utf-8 --

import discord
from discord.ext import commands
import json
import asyncio
from colorama import init, Fore
import ctypes
import sys
import os
import random
import time
import requests
import threading

init(autoreset=True)
green = Fore.LIGHTMAGENTA_EX
dgreen = Fore.LIGHTMAGENTA_EX
white = Fore.RESET
red = Fore.LIGHTMAGENTA_EX
yellow = Fore.LIGHTMAGENTA_EX
blue = Fore.LIGHTMAGENTA_EX
dblue = Fore.MAGENTA
gray = Fore.LIGHTBLACK_EX
intents = discord.Intents.all()

channel1 = f"{gray}[ {Fore.LIGHTGREEN_EX}Channel{gray} ]"
channel2 = f"{gray}[ {Fore.LIGHTRED_EX}Channel{gray} ]"
roles1 = f"{gray}[ {Fore.LIGHTGREEN_EX}Roles{gray} ]"
roles2 = f"{gray}[ {Fore.LIGHTRED_EX}Roles{gray} ]"
name1 = f"{gray}[ {Fore.LIGHTGREEN_EX}Guild{gray} ]"
name2 = f"{gray}[ {Fore.LIGHTRED_EX}Guild{gray} ]"
ban1 = f"{gray}[ {Fore.LIGHTGREEN_EX}Banning{gray} ]"
ban2 = f"{gray}[ {Fore.LIGHTRED_EX}Banning{gray} ]"
delete = f"[{Fore.LIGHTRED_EX}-{gray}]{white}"
create = f"[{Fore.LIGHTGREEN_EX}+{gray}]{white}"
perms1 = f"{gray}[ {Fore.LIGHTGREEN_EX}Perms{gray} ]"
perms2 = f"{gray}[ {Fore.LIGHTRED_EX}Perms{gray} ]"
status = f"{gray}[ {Fore.LIGHTGREEN_EX}Pings{gray} ]"
bad = f"{gray}[{blue}-{gray}]{white}"
pings = 0
bans = 0
members_count = 0

ban_threads = 0

def title(content):
ctypes.windll.kernel32.SetConsoleTitleW(content)```

pliant gulch
#

Assuming discord announces changes as it should

hasty iron
#

that seems like your typical selfbot

slate swan
#

whats a selfbot??

vale pendant
#

seems like a threaded nuker lol

slate swan
#

whats a selfbot??

final iron
#

How would I catch output from aexec (async version of exec) and assign it to a variable?

slate swan
slate phoenix
#

it’s self explanatory

slate swan
#

??

slate phoenix
#

a bot that runs on a user account

vale pendant
pliant gulch
#

!d contextlib.redirect_stdout

unkempt canyonBOT
#

contextlib.redirect_stdout(new_target)```
Context manager for temporarily redirecting [`sys.stdout`](https://docs.python.org/3.10/library/sys.html#sys.stdout "sys.stdout") to another file or file-like object.

This tool adds flexibility to existing functions or classes whose output is hardwired to stdout.

For example, the output of [`help()`](https://docs.python.org/3.10/library/functions.html#help "help") normally is sent to *sys.stdout*. You can capture that output in a string by redirecting the output to an [`io.StringIO`](https://docs.python.org/3.10/library/io.html#io.StringIO "io.StringIO") object. The replacement stream is returned from the `__enter__` method and so is available as the target of the [`with`](https://docs.python.org/3.10/reference/compound_stmts.html#with) statement:

```py
with redirect_stdout(io.StringIO()) as f:
    help(pow)
s = f.getvalue()
```  To send the output of [`help()`](https://docs.python.org/3.10/library/functions.html#help "help") to a file on disk, redirect the output to a regular file...
pliant gulch
#

Inside the context manager you would run exec

final iron
#

Ill probably need more help with this

#

Never used something like this

#

Imma read the docs first

slate swan
#

No one else answer

hasty iron
#

if you’re on windows it should’ve worked

slate swan
#

bruh idk

#

I am windows 10

hasty iron
#

why are you even trying to do that?

slate swan
hasty iron
#

??

#

i asked why

slate swan
#

idk

#

for random

hasty iron
#

you dont know?

final iron
#

You obviously know

hasty iron
#

for random?

#

so your brain was just like "ahh there is ctypes.windll.kernel32.SetConsoleTitleW that i could use for my discord bot"

vale pendant
#

prob skidded

final iron
#

Imma try to direct the output to a file then read the file and send it

hasty iron
#

thats basically using redirect_stdout

final iron
#

Yeah ik

hasty iron
#

io.StringIO is a file without a file

final iron
#

wdym

pliant gulch
#

Which can be passed to discord.File

#

to make an actual file to send

hasty iron
#

discord.File takes in io.BytesIO iirc

#

!d discord.File

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
final iron
#

This is above my knowledge tbh

hasty iron
#

it’s really simple

#

just mess around with it a bit and you’ll get the hang of it

final iron
#

alr

#

Ill start with adding the output to a file and then reading it

#

Ill try the other way though

pliant gulch
hasty iron
#

after that he said it accidentally works

pliant gulch
#

Why shouldn't it have worked in the first place

slate swan
#

does anyone know the rgb or hex of the discord embed background

#

that part by any chance

final iron
#

Haven't tested it

stark hearth
valid niche
final iron
valid niche
stark hearth
valid niche
#

It’s so much easier

stark hearth
final iron
#

Ig reddit was wrong

#

Nothing new

valid niche
#

Even with my phone I can make a screenshot and do a color pick built in

slate swan
#

you guys are life savers

lusty swallow
#

i feel like i made something wrong but im not sure

#
    @commands.command()
    async def count(self, ctx: commands.Context):
        submission: discord.Message = ctx.message.reference.resolved
        print(submission.reactions)
#

why does this returns a []

valid niche
lusty swallow
#

i mean the message i replied to when using the command has reactions

valid niche
lusty swallow
#

it does works if i'm using the message.reactions directly, just not with a resolved reference

#

wait

lusty swallow
valid niche
#

If that is, that is one of the main downsides of dpy, the cache is a complete mess

#

And hence why @river walrus started disthon :p which I’m helping with writing

median coyote
#

I have never made a discord bot, but I made a bot generate code for a discord bot.

slate swan
#

?

lusty swallow
median coyote
#

This is some of the code that the bot wrote

valid niche
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
median coyote
#

can someone tell me what they want a discord bot to do?

hasty iron
#

stuff

maiden fable
slate swan
#

anyone familiar with discord components

valid niche
maiden fable
hasty iron
#

dpy uses threads and so do you?

median coyote
#

Does anyone want me to generate a bot for them?

median coyote
#
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='!')

@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')

@bot.command()
async def hello():
    """Says hello"""
    await bot.say("Hello!")

bot.run('token')
hasty iron
#

interesting old code

#

where did you copy it from

median coyote
hasty iron
#

i mean, ctx is now a required argument in commands and bot.say is deprecated so idk what you mean

valid perch
#

.say brainmon

pliant gulch
#

Semi impl*

median coyote
hasty iron
#

generated by who??

median coyote
#

a bot

pliant gulch
#

Copilot?

median coyote
hasty iron
#

what bot

twilit adder
#

sussy

pliant gulch
#

Wouldn't expect copilot to do this anyhow

median coyote
fair rose
#

how would i make a discord bot create a webhook and make it say a message?

hasty iron
maiden fable
hasty iron
#

it writes descriptive docstrings for me

pliant gulch
hasty iron
#

which is a blessing

maiden fable
#

Ah haha. What's your lib link @pliant gulch

pliant gulch
hasty iron
maiden fable
#

Ah cool

median coyote
# fair rose how would i make a discord bot create a webhook and make it say a message?
import discord
import asyncio
import os

client = discord.Client()

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@client.event
async def on_message(message):
    if message.content.startswith('!hello'):
        msg = 'Hello {0.author.mention}'.format(message)
        await client.send_message(message.channel, msg)

client.run(os.environ['DISCORD_TOKEN'])
hasty iron
#

old code still

#

client.send_message is deprecated

median coyote
#

The bot is still a wip

hasty iron
#

did you make it??

median coyote
#

along with others

maiden fable
#

Dang, yours is clean, Andy

pliant gulch
#

Unlike discord.pys O(n) getitem for message cache

maiden fable
#

Well I didn't see each and every file, but I'mma take a look at it more closely once I get home from school

#

(I saw the http.py file and it's neat)

hasty iron
median coyote
hasty iron
#

lame

median coyote
#

I'll prove to you that it works

#

tell me something to generate

#

like "ask user for their name and print out the number of letter in their name"

hasty iron
#

i mean idk how you are generating this code, you could he just copy pasting some stuff and telling me that a bot generated it

median coyote
hasty iron
#

show me how it’s actually generated

median coyote
#

and i'll have it done in 1 sec

median coyote
hasty iron
#

huh?

visual island
hasty iron
#

im just asking what are you doing to generate the code

pliant gulch
#

Is this generation static from a template or does it change overtime

median coyote
# visual island "why does `from future import __annotations__` do not work with parameter conver...
from __future__ import annotations

from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel, Field, root_validator

from . import schemas
from .schemas import (
    ParameterConverter,
    ParameterConverterType,
    ParameterConverterValue,
)


class ParameterConverterModel(BaseModel):
    """
    ParameterConverterModel
    """

    type: ParameterConverterType = Field(
        ..., description="Parameter converter type"
    )
    value: ParameterConverterValue = Field(
        ..., description="Parameter converter value"
    )

    @root_validator(pre=True)
    def check_type(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        """
        check_type
        """
        type_ = values.get("type")
        value = values.get("value")
        if type_ == ParameterConverterType.DICT:
            if not isinstance(value, dict):
                raise ValueError(
                    f"ParameterConverterType.DICT requires value to be dict, got {type(value)}"
                )
        elif type_ == ParameterConverterType.LIST:
            if not isinstance(value, list):
                raise ValueError(
                    f"ParameterConverterType.LIST requires value to be list, got {type(value)}"
                )
        elif type_ == ParameterConverterType.TUPLE:
            if not isinstance(value, tuple):
                raise ValueError(
                    f"ParameterConverterType.TUPLE requires value to be tuple, got {type(value)}"
                )
        elif type_ == ParameterConverterType.SET:
            if not isinstance(value, set):
                raise ValueError(
                    f"ParameterConverterType.SET requires value to be set, got {type(value)}"
visual island
#

its not even dpy

median coyote
#

here's some of the code it generated, can't fit it all into discord

visual island
hasty iron
#

nice pydantic

slate swan
#
if change == "update_support":
      mymsg = await ctx.send("__Support Role Configuration__\n**`What would you like to change the support role to? [State ROLEID]`**")
      def check(user):
        return user == ctx.author
      try:
       message, user = await client.wait_for("message",check=check,timeout=30.0)
      except asyncio.TimeoutError:
       await mymsg.edit(content="__Configuration Cancelled__**\n`You took too long to respond, configuration cancelled`**")
      else:```

anyone knows why this aint workin?
#

it goes straight to the timeouterror

#

ignores my input all together

median coyote
hasty iron
visual island
slate swan
median coyote
slate swan
#

fr?

visual island
#

yea

slate swan
#

oh okay thx

hasty iron
slate swan
#

ohh i get it

#

whats \033[90m called

median coyote
#

I'm just testing discord bots rn

hasty iron
#

do you use something like gpt-2??

slate swan
#

generate discord bots?

#

huh

median coyote
#

not powerful

hasty iron
#

yeah its lame

slate swan
#

free source dpy files? lol

hasty iron
slate swan
#

cap?

#

lol

#

what module u used?

median coyote
#

we aren't using anything else

slate swan
#

for getting the music

#

oh nice

#

g

#

i can already see that ytdl is pretty useful

#

sure u can dm me

#

i might try myself

median coyote
#

@hasty iron I told my bot to generate a picture of a blanker

hasty iron
#

ok

median coyote
#
def main():
    """
    Main function
    """
    width = int(input("Enter width: "))
    height = int(input("Enter height: "))
    print("*" * width)
    for i in range(height - 2):
        print("*" + " " * (width - 2) + "*")
    print("*" * width)


if __name__ == "__main__":
    main()
#

now do you believe me?

hasty iron
#

not really

#

this isn’t really "proof"

#

when you make a github repo send me a dm or something and ill check it out

ocean leaf
#

what mistake have i done? i want it to not just break off when i forget to provide a message

meager whale
#
@client.command()
async def hello(ctx):
    await ctx.send("Hey")

@client.command()

async def kick(ctx, member: discord.Member, *, reason = None):

    await member.kick(reason = reason)

    await ctx.send(f'User {
  member
} has kicked.')
#

Help me

slate swan
meager whale
#

@slate swan help me

slate swan
ocean leaf
ocean leaf
#

i have referrenced them

meager whale
#
@client.command()

async def kick(ctx, member: discord.Member, *, reason = None):

    await member.kick(reason = reason)

    await ctx.send(f'User {
  member
} has kicked.')
dapper cobalt
meager whale
#

Oh

slate swan
#

You won't be changing lines in a single string even if its a f string

dapper cobalt
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
ocean leaf
#

for later

dapper cobalt
#

Btw, if you want it to include the whole argument and not just the first word, use *, before message.

#

ctx, *, message.

slate swan
#

is there a way to remove a users reaction off a message that has reactions

meager whale
#

@client.commands
async def invite(ctx):
await ctx.send("Invite Belle officials and Enjoy it. Link- (link entered in here) ")

boreal ravine
#

is there a kwarg for this? I use ctx.cog to display this and i wanna change it to something else

valid galleon
#

how do i check if the bot is playing something in a vc? is it by doing

      #code here```
dapper cobalt
#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
boreal ravine
#

hm

runic lagoon
#

I'm a little stuck, I'm trying to get a dictionary

#

but with a sub dictioniary

#

so, like here

#

I could get name/age/married/divorced/children/pets/cars

#

but how could I get the model of cars

#

In the python guide, it never showed it

valid galleon
runic lagoon
#

is there a better python server or something

dapper cobalt
runic lagoon
#

I'll try that

valid galleon
#

you shouldnt be using json for discord bots. try using a db like mongo as its similar to json, or use SQL

dapper cobalt
slate swan
dapper cobalt
#

No problem.

slate swan
#

.gg/dpy is their vanity

dapper cobalt
boreal ravine
#
class MyNewHelp(commands.MinimalHelpCommand):
    async def send_pages(self):
      destination = self.get_destination()
      for page in self.paginator.pages:
        embed = discord.Embed(description=page)
        embed.timestamp=datetime.utcnow()
        embed.set_author(name=ctx.author, icon_url=ctx.author.display_avatar) #current error: ctx not defined
        embed.set_footer(text='Minimal Help Command', icon_url=ctx.author.display_avatar)
        await destination.send(embed=embed)

This is my code currently and I was wondering how would I use ctx here? If I add a ctx param next to self it says Command raised an exception: TypeError: send_pages() missing 1 required positional argument: 'ctx'.

earnest canopy
#

Hi,

Write a program to accept 5 names from user and store these names into an array sort these array element in alphabetical order.

boreal ravine
#

thanks

unkempt canyonBOT
#

sorted(iterable, *, key=None, reverse=False)```
Return a new sorted list from the items in *iterable*.

Has two optional arguments which must be specified as keyword arguments.

*key* specifies a function of one argument that is used to extract a comparison key from each element in *iterable* (for example, `key=str.lower`). The default value is `None` (compare the elements directly).

*reverse* is a boolean value. If set to `True`, then the list elements are sorted as if each comparison were reversed.

Use [`functools.cmp_to_key()`](https://docs.python.org/3.10/library/functools.html#functools.cmp_to_key "functools.cmp_to_key") to convert an old-style *cmp* function to a *key* function.
visual island
#

list.sort will work also

slate swan
#

Oh

#

Didn't know about that one

sly cliff
#

how do we retrieve the data from requests

#

like if i put in a url

#

how do i get my bot to print the facts on the website (the url is of the website)

drifting arrow
#

You making a fun facts bot @sly cliff ?!

visual island
#

use aiohttp

sly cliff
drifting arrow
#

Oh

sly cliff
drifting arrow
#

not as fun as a fun facts bot 😦

visual island
sly cliff
#

better question is how do i learn this stuff

visual island
#

not just the fact text

slate swan
#

I'd recommend u don't ping the site that many times, u might get rate limited

visual island
#

yeah

slate swan
#

Use tasks.loop and have it loop each minute of each 5m

visual island
#

except if it's your own api endpoint

slate swan
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
#

Using that

slate swan
#
@tasks.loop(minutes=5)
async def api_req():
   ...  # Here add your code to do requests to the api, use aiohttp

api_req.start()
river walrus
sly cliff
#

for using urls

#

do we need to import libraries?

#

if so, which ones?

ocean leaf
#

this is my code

#

i've used the cmd

#

but it only sends the first word in the channel

#

pls help me. i want to send the full word

slate swan
ocean leaf
supple thorn
ocean leaf
#

what does that do?

slate swan
ocean leaf
#

ok

supple thorn
#

it takes every word after the command as the message

#

not only the first word

ocean leaf
#

ok got it

#

it works

steep estuary
#

how to make images/banners for levels ?

lament mesa
#

use pillow

faint shale
#

can someone send the documentation for discord library

keen talon
#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

faint shale
#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

steep estuary
vagrant brook
#

Because you just set client.launch_time to the exact same moment?

boreal ravine
#

Maybe because you defined client.launch_time in the command

#

so when u invoked the command the timer started then u subtracted that time so its 0

#

E

#

sure just define it somewhere else

sacred folio
#

Anyone that has any idea how to get a hold of a user that just removed a reaction? Had no trouble seeing who added it.

maiden fable
unkempt canyonBOT
#

discord.on_reaction_remove(reaction, user)```
Called when a message has a reaction removed from it. Similar to on\_message\_edit, if the message is not found in the internal message cache, then this event will not be called.

Note

To get the message being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

This requires both [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") and [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.

Note

Consider using [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") if you need this and do not want to enable the members intent.
sacred folio
#

@maiden fable will this tell me whether or not which user it is that removes it?

tropic briar
#

@client.event
async def on_message(ctx, message, member):
  for i in range(len(Filter)):
    if Filter[i] in message.content:
      for j in range(1):
        await member.ban(reason='filter')
        await ctx.send('A member has been banned')
``` The bot doesn't ban
boreal ravine
#

also is there an error

tropic briar
tropic briar
boreal ravine
tropic briar
#

Ok

maiden fable
#

Also u have only message, nothing else

#

In an on_message

maiden fable
boreal ravine
#

yeah because its an event it isnt a command

maiden fable
#

Then why did u tell then message.send???

boreal ravine
#

how u suppose to use the args if its an event lol

boreal ravine
maiden fable
#

I mean, u can only use one param in on_message, nothing else

boreal ravine
#

context is for commands only tho?

maiden fable
#

Yea

tropic briar
#

Still not working

boreal ravine
#

if u wanna ban the author