#discord-bots

1 messages Β· Page 709 of 1

small igloo
#

where gun

slate swan
#

It's never online tho

small igloo
slate swan
#

πŸ’€

small igloo
boreal ravine
#
        for cog in bot.cogs:
            if cog == 'Jishaku':
                pass
``` still doesnt work (jishaku still in my other object)
slate swan
#

i wish i was indianπŸ˜” love them

placid skiff
boreal ravine
#

capital case, bot

small igloo
#

eh

placid skiff
#

!d discord.ext.commands.Bot.cogs

unkempt canyonBOT
placid skiff
#

Bot.cogs is not a list

slate swan
boreal ravine
#

o

#

should i cast it then

small igloo
slate swan
#

just use bot.get_cog(cog)
And use qualified_name

#

As the example I sent above

boreal ravine
slate swan
#

tey printing cog , and you'll know why does it not work :")

boreal ravine
#
        for cog in bot.cogs:
            
            cog = bot.get_cog(cog)
            print(cog.qualified_name)
            if cog.qualified_name == 'Jishaku':
                pass
``` jsk is still in my other object
slate swan
daring valley
#
@bot.command()
@commands.cooldown(1,5,commands.BucketType.user)
@commands.is_owner()
async def say(ctx,*,rep=None):
    await ctx.send(rep)
    await asyncio.sleep(5)
    await ctx.message.delete()

well this is supposed to work but it still does the same thing (just send the message)

small igloo
#

i forgor, how to make this again...?

slate swan
boreal ravine
small igloo
small igloo
boreal ravine
slate swan
unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
slate swan
small igloo
slate swan
#

<t:<timestamp integer>:timestamp_type>

slate swan
boreal ravine
#

o

daring valley
#

so basically this is not deleting the message idk why

@bot.command()
@commands.cooldown(1,5,commands.BucketType.user)
@commands.is_owner()
async def say(ctx,*,rep=None):
    await ctx.send(rep)
    await asyncio.sleep(1)
    print("slept")
    await bot.delete_message(ctx.message) #stops here
    print("done")
boreal ravine
#

yay worked

#

@slate swan ty

slate swan
#

Great

small igloo
slate swan
#

Timestamp integer

boreal ravine
#

idk where you got that from

small igloo
boreal ravine
#

just use discord.Message.delete method

boreal ravine
daring valley
boreal ravine
small igloo
daring valley
boreal ravine
boreal ravine
small igloo
slate swan
small igloo
slate swan
#

Ignore the link

#

Just read the image

daring valley
slate swan
#

lmao

small igloo
#

<t:<3512371212>:f>

#

ok, what code there

slate swan
#

Remove the < inside

small igloo
#

<t:<3512371212:f>

#

<t:3512371212:f>

#

whoa, ggty

slate swan
#

Np

small igloo
slate swan
#

<t:<3512371212:f>

#

hmm

small igloo
slate swan
#

k

#

t:<3512371212:f

small igloo
slate swan
#

<t:3512371212:f>

small igloo
slate swan
#

ohh

small igloo
#

<t:44444444:f>

boreal ravine
small igloo
slate swan
#

<T:3512371212:f>

small igloo
slate swan
#

!e py from datetime import datetime print(f"<t:{int(datetime.now().timestamp())}:F>")

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

<t:1640523055:F>
slate swan
#

copy paste it

small igloo
#

<t:1640523055:F>

#

whoa :v nice

small igloo
slate swan
#

you can use .timestamp() function to get the timestamp for a datetime object

#

hmm

#

!d datetime.datetime.timestamp returns a float

unkempt canyonBOT
#

datetime.timestamp()```
Return POSIX timestamp corresponding to the [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instance. The return value is a [`float`](https://docs.python.org/3/library/functions.html#float "float") similar to that returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time").

Naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances are assumed to represent local time and this method relies on the platform C `mktime()` function to perform the conversion. Since [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") supports wider range of values than `mktime()` on many platforms, this method may raise [`OverflowError`](https://docs.python.org/3/library/exceptions.html#OverflowError "OverflowError") for times far in the past or far in the future.

For aware [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") instances, the return value is computed as:

```py
(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
```   New in version 3.3.

Changed in version 3.6: The [`timestamp()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp "datetime.datetime.timestamp") method uses the [`fold`](https://docs.python.org/3/library/datetime.html#datetime.datetime.fold "datetime.datetime.fold") attribute to disambiguate the times during a repeated interval.
small igloo
slate swan
small igloo
#

!e

from datetime import datetime
print(f"<t:{int(datetime.now()}:F>")
unkempt canyonBOT
#

@small igloo :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print(f"<t:{int(datetime.now()}:F>")
003 |                                        ^
004 | SyntaxError: f-string: closing parenthesis '}' does not match opening parenthesis '('
slate swan
#

!local-file

unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

small igloo
#

oh

#

!e

from datetime import datetime
print(f"<t:{int(datetime.now())}:F>")```
unkempt canyonBOT
#

@small igloo :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | TypeError: int() argument must be a string, a bytes-like object or a real number, not 'datetime.datetime'
small igloo
#

:l

#
from datetime import datetime
print(f"<t:{int(datetime.now().timestamp())}:F>")
slate swan
#

. timestamp when?

small igloo
#

why must timestamp

#

!e ```py
from datetime import datetime
print(f"<t:{int(datetime.now().timestamp())}:F>")

unkempt canyonBOT
#

@small igloo :white_check_mark: Your eval job has completed with return code 0.

<t:1640523367:F>
small igloo
#

<t:1640523367:F>

heavy folio
slate swan
# small igloo _wut wut_
#subfile
def hello(name: str) -> str:
    return "hello" + name

#main
import subfile

subfile.hello("name")

makes a bit more sensepithink

small igloo
heavy folio
#

what

slate swan
#

How can i split split arg1 and arg2 with :
My code
async def connect(ctx, arg1, arg2)
Example
Connect lnm.net:lnm

small igloo
#

ok, still not understand
how to check is "something" in the column "name" in "table_name"

slate swan
#

!command arg1 arg2

#

Works fine

#

!command arg1**:**arg2

#

Oh

#

.split

slate swan
heavy folio
#

no ones gonna spoon feed you

boreal ravine
unkempt canyonBOT
#

@boreal ravine :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | AttributeError: 'ellipsis' object has no attribute 'split'
boreal ravine
#

oops

heavy folio
#

oh shit

#

what did i do wrong blobpain

slate swan
#

Why u delete xddd

slate swan
heavy folio
#

OH YEAH

slate swan
#

!e py a = "python is great" m = a.split() print(m)

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

['python', 'is', 'great']
heavy folio
#

!e ```py
e = "arg1:arg2"
spl = e.split(":")
print(spl[0])
print(spl[1])

unkempt canyonBOT
#

@heavy folio :white_check_mark: Your eval job has completed with return code 0.

001 | arg1
002 | arg2
boreal ravine
#

i have no idea how that happened

small igloo
boreal ravine
#

i have no idea?

slate swan
boreal ravine
# slate swan show the class' init
class HelpCommand(commands.HelpCommand):
    def __init__(self):
        super().__init__(
            command_attrs={
                "hidden": True,
                "help": "Shows help about a module, group or a command",
            }
        )
``` i hate working with the help command class
#

i wanna access commands.Context in it but i cant 4 some reason

small igloo
boreal ravine
slate swan
boreal ravine
daring valley
#

how to create discord event in py? i literally can't find it anywhere

slate swan
#

oh nvm

boreal ravine
unkempt canyonBOT
#

@event```
A decorator that registers an event to listen to.

You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events).

The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)"), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.9)") is raised.

Example

```py
@client.event
async def on_ready():
    print('Ready!')
boreal ravine
daring valley
daring valley
small igloo
slate swan
#

!d discord.ext.commands.HelpCommand.context

unkempt canyonBOT
slate swan
#

It returns the same object

boreal ravine
#

o

daring valley
small igloo
boreal ravine
slate swan
#

you need to use fork

small igloo
heavy folio
#

πŸ’€

slate swan
#

Js => just sucks

small igloo
small igloo
slate swan
boreal ravine
#

the context?

full valley
#

for an embed field

#

do u need both value and text

boreal ravine
full valley
#

name & value *

#

damn

quick gust
#

bump

boreal ravine
#

!d discord.TextChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
quick gust
#

I know

slate swan
#

!d discord.TextChannel.edit takes a category kwarg

unkempt canyonBOT
#

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

Edits the channel.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
small igloo
boreal ravine
#

i think it has a category kwarg

quick gust
#

I just want to know how to get the category

boreal ravine
unkempt canyonBOT
slate swan
#

Bot.get_channel

#

With category id

quick gust
#

isn't this the same?

small igloo
quick gust
slate swan
#

Read the 3rd line of the docs of that method

#

!d discord.TextChannel.move

unkempt canyonBOT
#

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

A rich interface to help move a channel relative to other channels.

If exact position movement is required, `edit` should be used instead.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to do this.

Note

Voice channels will always be sorted below text channels. This is a Discord limitation...
quick gust
#

ah

#

so I shall use .edit instead

#

alright

slate swan
#

Sure

#
[x for x in z for y in w]

is this a correct way of doing 2 for loops in a list comp?

small igloo
slate swan
#

Why not [ x for x in [ z for y in w]]

small igloo
slate swan
slate swan
unkempt canyonBOT
#
Out of the question.

No documentation found for the requested symbol.

small igloo
#

:l

slate swan
#

!d discord.utils.get

unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
small igloo
#

iterable

#

attrs

slate swan
slate swan
slate swan
quick gust
#
await ticket_channel.edit(position=13)``` I have this but it isn't moving the channel position
#

no errors

#

nvm I just gave it the category instead

tidal hawk
#

What may trigger a tasks.loop 5 times in a minute, if the loop is set for 1 hour

#

for example, this loop is being activated SIX times in 1 hour

#

but the loop is set for 3 hours

visual island
#

the place where you start the loop.

#

I'm assuming you're starting the weather_loop function in on_ready no?

lament mesa
visual island
#

requests lib too

tidal hawk
#

I started with Cog's class, is it bad practice?

#

Can one problematic function intervene with other loops within the same Cog class?

visual island
#

depends on what problem is on the "problematic function". But show us how you start the loop

tidal hawk
visual island
#

hmm, that should be fine already

visual island
tidal hawk
#

outputs the weather_loop content 6 times within 1 minute

#

same goes for other loop

visual island
tidal hawk
#

yes

patent lark
visual island
#

okay, now try printing something and see how much did it print

brazen raft
waxen python
#

Does anyone know if there is a library that is like discord.py's format but instead is used for creating terminal applications?

boreal ravine
#

what are terminal applications

brazen raft
#

= console applications

waxen python
#

i mean like, just a py script that opens in the terminal

#

like literally the default

brazen raft
#

Every python file .py opens a terminal/console window

waxen python
#

yeah

#

but like, able to create command structures for the console instead of a discord bot

#

etc

brazen raft
#

Isn't it open-source?

#

You can yoink the code that you need

brazen raft
waxen python
#

thats true, just wondering if there is one similar done already

#

if not, i could look into it

brazen raft
#

So you just want the command handling system in discord.py for console applications?

#

Do you have a "chat" mechanism working for that?

waxen python
#

yeah like groups etc

waxen python
brazen raft
#

It shouldn't be difficult to redo it

#

It is kind of similar to using input with shlex

#

And you need to make a class and decorators and everything

#

Good luck with that

waxen python
#

lol

cinder horizon
#
@bot.command()
async def annoy(ctx, times : int, *, content):
  elif not isinstance(times, int):
    await ctx.reply("The number of times should be a digit", mention_author=True)
  else:
    if times > 10:
      return await ctx.send("You tryna break me or what?")
    else:
      for i in range(times):
        await ctx.send(content)

Error

Converting to "int" failed for parameter "times".
```...tried it but it no work...wut do i do?
honest vessel
#

@tidal hawkwhy u run every 3rd hour dosnt weather change more often than that? πŸ˜„

#

or is it t limit the rate calls of api?

cinder horizon
manic wing
#

well that explains it

honest vessel
manic wing
#

you want times to be an int, but @lOlMohAn69 is not an int

#

do you mean discord.User?

cinder horizon
#

like if iz times is not int(thenks to sm fools of my frnds they cannot stick to syntax so i wanted to notify thm abt tht)...soooooo how do i do tht?

cinder horizon
honest vessel
honest vessel
#

you should set a cooldown on that command

#

like 30sec-1min

cinder horizon
honest vessel
#

you can check type with just print(type(x))

#

did u cut off the code?

cinder horizon
honest vessel
#

elif not isinstance(times, int):

cinder horizon
#
elif not type(times) == int:
``` this works?
#

ok nope

#

it does not...

honest vessel
#

time=1
if type(times) is int:
... print("a")
...
a

cinder horizon
#

!e

time=1
if type(times) is int:
  print("a")
unkempt canyonBOT
#

@cinder horizon :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | NameError: name 'times' is not defined. Did you mean: 'time'?
slate swan
#

I'm trying to make a verification command but idk how to check if the user sent the correct code in the verification channel

    @commands.command()
    @commands.has_role(924672205038710824)
    async def verify(self,ctx):
        verification_code = random.randint(1111,9999)
        if ctx.channel.id == 921720659653054464:
            try:
                verification_embed = discord.Embed(title=":police_officer: Verify :police_officer:", color=0xd7832b, description=f"To keep our server safe please enter the code you see below in [#921717709589336065](/guild/267624335836053506/channel/921717709589336065/).\n`{verification_code}`")
                await ctx.author.send(embed=verification_embed)
            except:
                await ctx.send("__**I cannot dm you!**__\nPlease open you dm's in user settings.")
        else:
            pass

    async def on_message(self,message):
        if message.channel.id == 921720659653054464:
            if message.content == verification_code:
cinder horizon
#

!e

times=1
if type(times) is int:
  print("a")
unkempt canyonBOT
#

@cinder horizon :white_check_mark: Your eval job has completed with return code 0.

a
honest vessel
#

if type(times) is not int:
... print("x")
... else:
... print("z")
...
z

cinder horizon
#

is not

#

my bad

honest vessel
#

@cinder horizondid you cutoff the beginning of your if-statement here? @bot.command() async def annoy(ctx, times : int, *, content): elif not isinstance(times, int): cause u starting it with elif

slate swan
#

isinstance is the best you can use

cinder horizon
slate swan
#

i wonder why you are doing it again when its typehinted as int tho

honest vessel
#
if isinstance(times, int):
...     print("a")
...
a```
cinder horizon
#

peashe

#

i shall try

honest vessel
#
@bot.command()
async def annoy(ctx, times : int, *, content):
  if ctx.channel.id == 763705746235588658:
    pass
  
  if not isinstance(times, int):
    await ctx.reply("The number of times should be a digit", mention_author=True)
honest vessel
#

you need to make a new if-statement

patent lark
#

..

honest vessel
#

you use elif when its same statement

cinder horizon
# slate swan .

like removed the : int and tried it n it works....
and had ta make a new if statement yes

cinder horizon
honest vessel
patent lark
#

thats just a typehint

honest vessel
#

could also check if its .isdigits()

slate swan
#

!d discord.ext.commands.BadArgument

unkempt canyonBOT
#

exception discord.ext.commands.BadArgument(message=None, *args)```
Exception raised when a parsing or conversion failure is encountered on an argument to pass into a command.

This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
slate swan
#

just typehint it to int ->if its not, it will raise a commands.BadArgument

patent lark
#

!d discord.ext.commands.Bot.wait_for

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**...
honest vessel
#

that example should give u a hint

#

(change "hello" to your verification code)

lusty ether
#

hey can any one give me code for clear command
a very good clear command like dyno

slate swan
#

nah , but here's the docs

#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Examples

Deleting bot’s messages...
lusty ether
#

i know this one

#

i am talking about clearing last x messages form specific member

slate swan
#

and , if you want to make something like dyno's purge command , you'd be using typing.Union as the first arg of the command

lusty ether
#

i know

lusty ether
lusty ether
slate swan
#

!d typing.Union

unkempt canyonBOT
#

typing.Union```
Union type; `Union[X, Y]` is equivalent to `X | Y` and means either X or Y.

To define a union, use e.g. `Union[int, str]` or the shorthand `int | str`. Details...
slate swan
#

!d typing.Optional

unkempt canyonBOT
#

typing.Optional```
Optional type.

`Optional[X]` is equivalent to `X | None` (or `Union[X, None]`).

Note that this is not the same concept as an optional argument, which is one that has a default. An optional argument with a default does not require the `Optional` qualifier on its type annotation just because it is optional. For example:

```py
def foo(arg: int = 0) -> None:
    ...
```  On the other hand, if an explicit value of `None` is allowed, the use of `Optional` is appropriate, whether the argument is optional or not. For example...
lusty ether
#

yea we are taking None here

#

got you point

#

you are correct they are same

slate swan
#

atleast read what the docs say above

#

yea

patent lark
#

Optional [SomeType] is the same as Union [SomeType, None].

lusty ether
patent lark
#

πŸ‘

velvet tinsel
#

just a quick question

patent lark
#

ask away

velvet tinsel
#

in example.com/foo, what is foo called

#

it seems ot but πŸ˜›

slate swan
#

a webpage?

patent lark
#

network address?

lusty ether
#
async def on_command_error(self, ctx, error):
#

if we can't do this then how to get channel where error occured

shadow wraith
#

its ctx and error only unless you're in a cog

craggy cloak
#

What else do I need to install to get my bot online?

boreal ravine
velvet tinsel
patent lark
lusty ether
boreal ravine
boreal ravine
craggy cloak
patent lark
#

!d discord.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

await on_command_error(context, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
boreal ravine
#

takes 2 parameters

lusty ether
#

i tried async def on_command_error(self, ctx, error):

boreal ravine
lusty ether
#

but it seems error is not working

boreal ravine
lusty ether
#

elif isinstance(error, commands.errors.ExtensionNotFound):

#

never true

craggy cloak
lusty ether
#

discord.ext.commands.errors.ExtensionNotFound: Extension 'cogs.@robust token' could not be loaded.

#

while error is this

boreal ravine
lusty ether
boreal ravine
#

ic so whats the issue?

lusty ether
boreal ravine
lusty ether
boreal ravine
#

try changing the elif to if

lusty ether
#

ok

patent lark
#

what?

lusty ether
#

not working

boreal ravine
#

hm no idea then

patent lark
lusty ether
patent lark
#

show me your current code

slate swan
#

how to create a command with space i mean command "c#command help"

patent lark
#

and explain the issue that happens when an exception could be raised

lusty ether
patent lark
#

show me the entire event

lusty ether
#

i have this is error
discord.ext.commands.errors.ExtensionNotFound: Extension 'cogs.@robust token' could not be loaded

patent lark
lusty ether
#
async def on_command_error(self, ctx, error:commands.CommandError):
        if isinstance(error, commands.errors.NotOwner):
            message = "You are not owner!"
        elif isinstance(error, commands.errors.BadArgument):
            message = "Bad argument!"
        elif isinstance(error, commands.errors.ExtensionNotFound):
            message = "Extension not found!"
        else:
            raise (error)```
#

this is code

patent lark
#

okay.. for any error you set a value to a variable, how is this supposed to return the message variable?

slate swan
wispy spade
patent lark
#

this is called snake casing

lusty ether
slate swan
patent lark
#

you're not doing anything to handle the error

lusty ether
patent lark
#

but as far as function definition, it must be snake cased

patent lark
#

you're doing nothing to handle the error

lusty ether
patent lark
#

doesnt look like it

slate swan
#

how do i fix this error?

Because no versions of discord match >1.7.3,<2.0.0
   and discord (1.7.3) depends on discord.py (>=1.7.3), discord (>=1.7.3,<2.0.0) requires discord.py (>=1.7.3).
slate swan
wispy spade
#

oh

#

You might be looking for a command group there

patent lark
#

ah like a subcommand?

wispy spade
unkempt canyonBOT
#

@discord.ext.commands.group(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").

This is similar to the [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") decorator but the `cls` parameter is set to [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group") by default.

Changed in version 1.1: The `cls` parameter can now be passed.
slate swan
lusty ether
#

print(type(error))

#

why this is giving error?

slate swan
lusty ether
#

aah got it

slate swan
#

!e

print(type("hello"))
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

<class 'str'>
lusty ether
#

!d discord.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

await on_command_error(context, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
slate swan
#

what are you trying to do?

lusty ether
#

why my on_command_error not working

slate swan
lusty ether
#

elif isinstance(error, commands.errors.ExtensionNotFound):

patent lark
#

smh

slate swan
#

your whole function

lusty ether
#

when i am getting this error my handeler is ignoring it

slate swan
patent lark
#

@lusty ether i’ve tried helping you, your on_command_error is perfect , you are just using it incorrectly.

lusty ether
#

this is new code still not working

slate swan
lusty ether
#

lol

tidal hawk
#

Does somebody have an idea, why my tasks.loop(hours=3) runs 5-6 times within ONE hour

#

Sometime it doesnt set footer etc.. line 112

patent lark
#

move the embed.set_footer() above your for loop.

tidal hawk
#

how does it change the output?

lusty ether
#

@patent lark i tried to print the error type and found my error is not ExtenstionNotFound its command invoke

lusty ether
#

but why

tidal hawk
patent lark
#

the only thing between your embed object and footer method is your for loop. id assume this could be an issue as to why it isnt setting

tidal hawk
#

But why does it run the loop function like 20 times within 3 hours

boreal ravine
tidal hawk
#

instead 1 time in 3 hours

tidal hawk
patent lark
#

are you sure theres only one instance of the bot running?

tidal hawk
#

yes

patent lark
#

where do you start the loop?

lusty ether
# patent lark huh?
discord.ext.commands.errors.ExtensionNotFound: Extension 'cogs.@robust token' could not be loaded.```
```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ExtensionNotFound: Extension 'cogs.@MEE6#4876' could not be loaded```
here my command handler is taking second error not first one
manic wing
#

on_ready probably

tidal hawk
#

on Cog class attribute

manic wing
#

hence the issue

boreal ravine
#

cog gets loaded multiple times

patent lark
#

if its in on_ready that would be an issue since on_ready could be dispatched multiple times

meager smelt
#

How do i make my bot send "blocked messages"?

tidal hawk
boreal ravine
#

pycharm pyflakes are one of the reasons why i dont wanna use it

boreal ravine
meager smelt
#

like this one

boreal ravine
patent lark
#

uh. block your bot? lmao

boreal ravine
#

thats discord

boreal ravine
#

i dont even think theres an endpoint for it afaik

boreal ravine
meager smelt
#

didn't even realise that i blocked the bot

slate swan
#

Hey what am i doing wrong pls explain

#

On line 6

patent lark
#

client = discord.Client() *

slate swan
#

Ohh ok actually am following https://youtu.be/SPTfmiYiuok this tutorial and i copy pasted them here but didnt worked

Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it.
🚨Note: At 16:43, Replit now has a new method for environment variables. Check the docs: https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables

Along the way, you will learn to use Repl.it's built-in database and cr...

β–Ά Play video
craggy cloak
slate swan
#

Ohk

patent lark
#

dont follow youtube tutorials, the code is probably outdated and poorly written.

#

you should also use the bot object not discord.Client()

#

this is probably the best tutorial i can point you to

slate swan
#

Ohhk thnx

patent lark
#

but you should learn python before jumping into discord.py. discord.py is a complex library, not for beginners.

#

you need basic knowledge of Python, Asynchronous Programming, and Object Oriented Programming (OOP)

slate swan
#

In which channel can i learn basic things of python?

hushed field
#

python official docs

#

handbooks, guides, small challenges

slate swan
#

Ohk

hushed field
#

https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
https://automatetheboringstuff.com/ (for complete beginners to programming)
http://greenteapress.com/wp/think-python-2e/ (another decent book)
See also:
http://www.codeabbey.com/ (exercises for beginners)
https://realpython.com/ (good articles on specific topics)
https://learnxinyminutes.com/docs/python3/ (cheatsheet)

slate swan
#

Thnx

boreal ravine
#

or just watch a video

#

i recommend tech with tim

alpine vault
#

What is the difference between discord.Guild.emojis and await discord.Guild.fetch_emojis() ?

shadow wraith
slate swan
hollow plover
#

how do you istall discord 2.0.0?

#

what is the command in terminal for linux

#

thanks

slate swan
hollow plover
#

ill check thanks :)

slate swan
#

yw

sage otter
devout iris
#

i want to add a few languages to my bot but idk how to add this. Do u know?

hollow plover
#

thanks it worked :0

devout iris
#

What can i do

slate swan
hollow plover
#

i thinks so lmao

sage otter
#

No I use windows too

#

It’s basically the same

slate swan
#

im only in windows cause of gaming

sage otter
#

I use windows for all of the above. Idrc for Linux or Mac. It also doesn’t make my opinion any better on Linux when people who stan it constantly shit on windows and poach people to go to Linux.

cloud dawn
#

Yeah also fine, relax day today.

slate swan
alpine vault
#

What really is available and non-available emojis? (Like the ones returned by xyz.available)
How does an emoji become non-available?

alpine vault
cloud dawn
#

Bot is unable to send the emoji because it doesn't have the permission to format it.

alpine vault
cloud dawn
#

Bots can't have nitro so the checklist will be of the guild emoji's and discords default emoji's

hollow plover
#

can anyone help on using the new discord.ui.Buttons to make a subclassed help command? I know how to make one with menus but not these new buttons

#

i dont want code, but explanation pls thnks

slate swan
#

to make buttons you dont subclass ui.buttons?

cloud dawn
#

I mean you could

slate swan
#

Β―\_(ツ)_/Β―

cloud dawn
#

But he stated the help command okimii

hollow plover
#

yes

slate swan
#

dont get why ui.buttons is needed

hollow plover
#

a bit like the dank memer help command

slate swan
#

ah a paginator

hollow plover
#

yes yes that is the word

#

but withdiscord.ui.Buttons

slate swan
#

doesnt the class already have a paginator in it?

#

with reactions

hollow plover
#

what, HelpCommand?

slate swan
#

yes

hollow plover
#

i dont think so, my current one is using discord.menus

slate swan
#

ah ic

#

what lib are you using?

hollow plover
#

and pycord

quick gust
#

just pycord then lol

slate swan
#

yeah

quick gust
#

pycord is a dpy fork

hollow plover
#

my bad

slate swan
#

most forks are better than dpy itself

hollow plover
#

oh ok

#

i will look at the docs for once and try to figure it out

#

if not ill probs come back to ask tomorrow lmao

#

thanks

slate swan
#

yw

hollow plover
#

i found it tysm for the guidnce :)

slate swan
devout iris
#

hey how to run a file with command?

#

i.e. i have 2 bot and i want to write a command like !run bot2 and second bot's main file will run.

#

how can i make this?

manic wing
devout iris
#

alrightyyyyy thx i'm gonna try

slate swan
#

someone can help me with this?

#

but , this will stop your first bot

devout iris
#

like that?

manic wing
slate swan
#

oh nice then....

slate swan
maiden fable
manic wing
#

if you want the first one to continue, sure

maiden fable
#

!d asyncio.loop.subprocess_shell

unkempt canyonBOT
#

coroutine loop.subprocess_shell(protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)```
Create a subprocess from *cmd*, which can be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") or a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") string encoded to the [filesystem encoding](https://docs.python.org/3/library/os.html#filesystem-encoding), using the platform’s β€œshell” syntax.

This is similar to the standard library [`subprocess.Popen`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen "subprocess.Popen") class called with `shell=True`.

The *protocol\_factory* must be a callable returning a subclass of the [`SubprocessProtocol`](https://docs.python.org/3/library/asyncio-protocol.html#asyncio.SubprocessProtocol "asyncio.SubprocessProtocol") class.

See [`subprocess_exec()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.subprocess_exec "asyncio.loop.subprocess_exec") for more details about the remaining arguments.

Returns a pair of `(transport, protocol)`, where *transport* conforms to the [`SubprocessTransport`](https://docs.python.org/3/library/asyncio-protocol.html#asyncio.SubprocessTransport "asyncio.SubprocessTransport") base class and *protocol* is an object instantiated by the *protocol\_factory*.
slate swan
#

pls someone can help me with that?

maiden fable
#

Why do u have a double brackets in discord.Color

slate swan
#

☠️ pip install embed

maiden fable
#

Lmao

#

!pip embed

unkempt canyonBOT
manic wing
maiden fable
#

Lol

shadow wraith
#

bro he thinking this is nodejs

slate swan
#

fixed it

shadow wraith
slate swan
shadow wraith
#

bro one second let me install discord.ext.menus πŸ•΄οΈ

manic wing
#

you guys arent seeing the worst problem

slate swan
manic wing
#

channel = client.get_channel(##LOGS CHANNEL ID)

shadow wraith
#

oh fuck it installed it πŸ’€

#

nvmvnmvvm

slate swan
#

so many if state ments for option times

#

when you can just do it in minutes or hours

shadow wraith
#

!d disnake.ext.commands.Context.reply

unkempt canyonBOT
#

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

A shortcut method to [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send") to reply to the [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message").

New in version 1.6.

Changed in version 2.3: Added `fail_if_not_exists` keyword argument. Defaults to `True`.
shadow wraith
#

phew, it exists still, i thought mention_author was the replacement

#

why is this underlined :[

slate swan
slate swan
shadow wraith
#

importing disnake.ext and disnake works

#

but this seems to be fucked up

#

wait

#

im so fucking stupid

#

it's disnake.ext.buttons

#

but still same issue :|

lament mesa
#

maybe an issue with pylint?

shadow wraith
#

wait disnake.ext.menus doesn't exist fucl

#

πŸ•΄οΈ

lament mesa
#

ext.menus is an external package

shadow wraith
#

can't you read it's disnake πŸ•΄οΈ

#

!pypi disnake-ext-menus

unkempt canyonBOT
shadow wraith
#

πŸ•΄οΈ

#

don't read the pull request or die

boreal ravine
tawdry perch
#

Because I'm banned from there

boreal ravine
#

just appeal

#

most appeals get accepted

shadow wraith
#

πŸ˜ƒ

slate swan
shadow wraith
#

of asynchronous stupidity

slate swan
#

lol

shadow wraith
#

bro this was a troll pull request

slate swan
#

i should learn regex before i do my api wrapperπŸ˜”

boreal ravine
#

@tawdry perch lmfao what

shadow wraith
#

πŸ’€ bro import pygame?

slate swan
boreal ravine
tawdry perch
boreal ravine
#

but it was planned too have it

shadow wraith
slate swan
boreal ravine
#

i think pycord has a wip voice receiving model

shadow wraith
#

im pretty sure disnake does too even though i've never heard of it

shadow wraith
#

πŸ˜ƒ

boreal ravine
#

disnake doesnt have everything you know

shadow wraith
boreal ravine
shadow wraith
#

yes

sage otter
shadow wraith
#

in this server i'd agree

#

πŸ˜„

lone hazel
#

hallo everyone

sage otter
#

If you go here it’s more of a non-hostile environment towards people who don’t as much python

shadow wraith
boreal ravine
shadow wraith
sage otter
#

If you actually act the way people act in the discord.py server. You would get punished here.

lone hazel
#

how do you mean

shadow wraith
#

true

#

can someone post a question im gtting bored

lone hazel
boreal ravine
sage otter
lone hazel
#

ahhh

#

I see thank you

sage otter
#

Oh yeah it’s not documented.

shadow wraith
#

πŸ’€

#

if no documentation no concept of implementation or understanding

#

😭

sage otter
#

I mean there’s probably doc strings in the source.

shadow wraith
shadow wraith
#

@unkempt canyon

boreal ravine
#

how do I do it?

shadow wraith
#

possible but idk

sage otter
#

Mark are you genuinely asking a question or asking something you already know.

boreal ravine
#

he did say he wanted a question.. pithink

sage otter
#

i mean I see you a lot in the official dpy server. You seem pretty experienced and knowledgeable about this stuff.

shadow wraith
#

ill ask a question

#

how do you <insert long shit with high expectations here>

boreal ravine
#

no

shadow wraith
#

you can't fetch the oldest reddit posts with a upvote amount of -1,000 :Sob:

#

probably because you can

slate swan
#

regex is built in to python with the access word "re" right

sage otter
#

Yeah

shadow wraith
#

!e
import re

unkempt canyonBOT
#

@shadow wraith :warning: Your eval job has completed with return code 0.

[No output]
shadow wraith
#

yup usually it return modulenotfound error so πŸ‘

slate swan
shadow wraith
#

!e
import sys as disnake
import random as discord
disnake.exit()

unkempt canyonBOT
#

@shadow wraith :warning: Your eval job has completed with return code 0.

[No output]
wanton veldt
#

any ideas? ```py
import discord
from discord.ext import commands, tasks

class join(commands.Cog):
def init(self, bot: commands.Bot):
self.bot = bot

@commands.event
async def on_member_join(member):
    channel = client.get_channel(910565602362556426)
    embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined the server.")
    ember=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
    await channel.send(embed=embed)
    role = discord.utils.get(member.guild.roles, name = "γ€ŒπŸŒ γ€USER")
    await member.add_roles(role)
    print(f"{member} was given {role}")

def setup(bot: commands.Bot):
bot.add_cog(join(bot)) ```

quick gust
#

what is @commands.event?

#

is that a thing

sage otter
#

No

#

He probably wants Cog.listener()

quick gust
#

do commands.Cog.listener() instead if you're in a cog

quick gust
wanton veldt
#

I don't know, I've never used cogs in python before

#

thx

wanton veldt
# quick gust ^

Ignoring exception in on_member_join Traceback (most recent call last): File "C:\Python310\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) TypeError: join.on_member_join() takes 1 positional argument but 2 were given

#
import discord
from discord.ext import commands, tasks

class join(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_member_join(member):
        channel = client.get_channel(910565602362556426)
        embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined the server.")
        ember=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
        await channel.send(embed=embed)
        role = discord.utils.get(member.guild.roles, name = "γ€ŒπŸŒ γ€USER")
        await member.add_roles(role)
        print(f"{member} was given {role}")



def setup(bot: commands.Bot):
    bot.add_cog(join(bot))    ```
#

I m getting this error now

scenic lark
wanton veldt
#

oh yea i m dumb thx

craggy cloak
upbeat otter
#

:dogepray:

sage otter
#

i lose my a little bit of my sanity everytime someone calls vsc an ide

dawn thorn
#

Someone can help me in visual studio code?

neat gale
#

do i have to install anything special to get is_playing and is_paused to work?

quick gust
dawn thorn
quick gust
#

ask away then

dawn thorn
#

I need to show the problem in share screen

neat gale
#

well it dont work

quick gust
#

would be better if u could ask it here, expecting people to screenshare for your problem is a little hard

dawn thorn
#

If I wrote the problem you won't understand

boreal ravine
dawn thorn
#

And I can explain it

#

I just need to hope for someone nice to help me

neat gale
# boreal ravine show error

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'is_paused'

scenic lark
#

Screen record the issue @dawn thorn

dawn thorn
scenic lark
#

Nah sorry man you should just screen record via OBS and send it here

dawn thorn
#

I don't have nitro, discord won't lemme send it

boreal ravine
#

@dawn thorn cant u just send error

dawn thorn
#

Ther is no error

scenic lark
#

You can just put it in google drive and make it public and send the link here

blissful lagoon
#

please don't use ableist language

neat gale
#

sry

dawn thorn
#

If I want to run like print('hello world') It tells me to select a file (I do not know why)

boreal ravine
#

@neat gale lmfao?

neat gale
#

uhm

#

...

neat gale
#

yeah im dumb

scenic lark
#

Run python <filename>.py then in the terminal

dawn thorn
#

But why I need to select file

scenic lark
#

Screen shot the error dude

dawn thorn
#

Bruh I told you

quick gust
scenic lark
#

Go to the file directory and run the command I'm so confused

dawn thorn
#

Nvm I'll do it myself

craggy cloak
#

async def create_db_pool(): client.pg_con = await create_pool

upbeat otter
frosty jolt
#

anyone know a good host and good ide to use? ive been using repl and uptimerobot but its kidna slow

craggy cloak
#

Ok lol now i get another error but i know how i can fix that err thx anyway :)

wanton veldt
#

Hi i have a question i have this code ```py
from discord.ext import commands

class Ping(commands.Cog, name="Ping"):
def init(self, bot: commands.Bot):
self.bot = bot

@commands.command()
async def ping(self, ctx):
    await ctx.send(f"The current latency is: {round(commands.latency * 1000)} miliseconds")

def setup(bot: commands.Bot):
bot.add_cog(Ping(bot))
and i get this errorAttributeError: module 'discord.ext.commands' has no attribute 'latency'

maiden fable
#

self.bot.latency

wanton veldt
#

dosent work

scenic lark
#

^ self yeah

wanton veldt
#

oh ok

lunar quail
#
def get_emote_vacancy(guild_obj: discord.Guild):

    static_count = 0
    animated_count = 0

    print(guild_obj.emojis)  # Gets the entire tuple of custom emojis in the guild
    print(len(guild_obj.emojis)) # 56
    for each_emote in guild_obj.emojis:
        # Problem : This for-loop is exhausted after only getting the first object in guild_obj.emojis
        # Despite there being multiple emojis
        print(each_emote)
        if not each_emote.animated:
            static_count += 1
        else:
            animated_count += 1
        # Exits after printing first one

        print(static_count, animated_count) # "1 0" since first emoji was non-animated
        print(guild_obj.emoji_limit) # 50 (unboosted server)
        emote_vacancy = {
            "static": guild_obj.emoji_limit - static_count, # 49
            "animated": guild_obj.emoji_limit - animated_count, # 50
        }

        return emote_vacancy

How do I properly access all the elements in what discord.Guild.emojis returns? for loop only seems to get the first element.

maiden fable
#

Do you have intents?

lunar quail
maiden fable
#

Wait so if it prints all that, then whTs the problem (and yea, emoji is included in default intents)

upbeat otter
slate swan
#
import discord
import os
from alive import keep_alive



client = discord.Client()




@client.event
async def on_ready():
  print("Logged in as {0.user}".format(client))

@client.event
async def on_message(message):
  if message.author == client.user:
    return

  if message.startswith("!hello"):
    await message.channel.send("Test")
    
      

keep_alive()
client.run(os.getenv('token'))
slate swan
#

why does that not print "test"

#

when i do the command !hello

maiden fable
upbeat otter
#

:dogepray:

lunar quail
#

I get the first element and the for loops exits

upbeat otter
maiden fable
slate swan
#

oh yeah it does

upbeat otter
#

then hard luck

#

lol wait

maiden fable
#

U r returning inside the loop :DDD

lunar quail
#

oooooh

upbeat otter
#

first of all use discord.ext.commands.Bot

lunar quail
#

fooking hell my eyes

upbeat otter
#

@slate swan

slate swan
#

where do i put it

#

what does it do

lunar quail
#

Thanks for the help @maiden fable

maiden fable
upbeat otter
# lunar quail fooking hell my eyes

its fine, I just spent 20 minutes rewriting three of my functions because it didnt return a list and only a string because of my indentation

slate swan
lunar quail
upbeat otter
lunar quail
#

we monkes are stupid

slate swan
#

of what

maiden fable
upbeat otter
maiden fable
#

They warn me always when I use return and not break inside a loop

upbeat otter
#

oopsie

slate swan
#

client = discord.ext.commands.Bot()

lunar quail
maiden fable
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **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.
slate swan
#

?

#

like that?

upbeat otter
#

yeah

maiden fable
slate swan
#

do u know why it doesnt work tho

maiden fable
#

Cz it would send Test, instead of printing it lol

slate swan
#

nvm

#

i get the error has no attr startswith

maiden fable
#

Ah yea that too

#

U need to do message.content.startswith

slate swan
#

oh k

#
import discord
import os
from alive import keep_alive



client = discord.ext.commands.Bot()




@client.event
async def on_ready():
  print("Logged in as {0.user}".format(client))

@client.event
async def on_message(message):
  if message.author == client.user:
    return

  if message.content.startswith("!hello"):
    await message.channel.send("Test")
    
      

keep_alive()
client.run(os.getenv('token'))
maiden fable
#

Imagine 😐

#

Just use discord.Client for now bruv

slate swan
#

i was told to use that lmao

#

if u look above i did use discord.Client()

#

blame @upbeat otter

#

ok works now thanks

lunar quail
maiden fable
lunar quail
tawdry perch
#

I have seen people use jishaku but I forgot what that is.. and how do I install it?

maiden fable
maiden fable
#

It's a module on pypi

tawdry perch
#

hm?

maiden fable
#

Wait lemme get it

#

There (:

tawdry perch
#

thx!

craggy cloak
#
Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:\Users\simon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\simon\Desktop\Database Bot\cogs\economy.py", line 17, in on_ready
    await self.client.pg_con.execute("ALTER TABLE economy ADD COLOMN IF NOT EXISTS userid BIGINT NOT NULL")
  File "C:\Users\simon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\asyncpg\pool.py", line 564, in execute
    return await con.execute(query, *args, timeout=timeout)
  File "C:\Users\simon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\asyncpg\connection.py", line 318, in execute
    return await self._protocol.query(query, timeout)
  File "asyncpg\protocol\protocol.pyx", line 338, in query
asyncpg.exceptions.PostgresSyntaxError: syntax error at or near "EXISTS"
Ignoring exception in command None:

#

Who can help?

maiden fable
#

Giving code would be appreciated

tawdry perch
#

how am I supposed to use jsk commands?

craggy cloak
maiden fable
tawdry perch
#

<bot prefix>jsk <command> ?

maiden fable
maiden fable
tawdry perch
#

that did not work, there was nothing in console either

upbeat otter
#

What even are jsk cmds

craggy cloak
# maiden fable economic.py
from discord.ext import commands
from discord.utils import get 



class Economy(commands.Cog):
    def __init__(self, client):
        self.client = client




    @commands.Cog.listener()
    async def on_ready(self):
      print("test")
      await self.client.pg_con.execute("CREATE TABLE IF NOT EXISTS economy (userid BIGINT NOT NULL , money BIGINT)")
      await self.client.pg_con.execute("ALTER TABLE economy ADD COLOMN IF NOT EXISTS userid BIGINT NOT NULL")
      await self.client.pg_con.execute("ALTER TABLE economy ADD COLOMN IF NOT EXISTS money BIGINT")


    async def add(self, id, amount=30):
      bal = await self.client.pg_con.fetchrow("SELECT money FROM economy WHERE userid = $1",id)
      await self.client.pg_con.execute('UPDATE economy SET money = $1 WHERE userid = $2',amount+bal[0],id)

    async def check(self, id):
      user = await self.client.pg_con.fetchrow("SELECT * FROM economy WHERE userid = $1",id)
      if not user:
        await self.client.pg_con.execute("INSERT INTO economy (userid, money) VALUES ($1, $2)",id, 30)

    async def balance(self, id):
      bal = await self.client.pg_con.fetchrow("SELECT money FROM economy WHERE userid = $1",id)
      return bal[0]


maiden fable
#

@tawdry perch try reading the readme

tawdry perch
#

I will, gotta goo πŸ‘‹

cloud dawn
maiden fable
#

@craggy cloak it's COLUMN not COLOMN

craggy cloak
#

lol

upbeat otter
maiden fable
#

Facts

proven osprey
#

how to take away the ability to connect from everyone to the voice channel?

unkempt canyonBOT
#

await edit(*, name=..., permissions=..., colour=..., color=..., hoist=..., mentionable=..., position=..., reason=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the role.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this.

All fields are optional.

Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.

Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead.
maiden fable
#

!d discord.Permissions.connect

unkempt canyonBOT
somber crown
#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
somber crown
#

how do i add images to a file through a file dir? not using url

slate swan
maiden fable
upbeat otter
slate swan
slate swan
unkempt canyonBOT
maiden fable
slate swan
maiden fable
#

Yup most people only use its eval

tawdry perch
maiden fable
#

Yea yea

maiden fable
slate swan
maiden fable
tawdry perch
#

Will the eval be ran in my local machine or in some sand box

maiden fable
#

!d eval

unkempt canyonBOT
#

eval(expression[, globals[, locals]])```
The arguments are a string and optional globals and locals. If provided, *globals* must be a dictionary. If provided, *locals* can be any mapping object.
maiden fable
#

!d exec

unkempt canyonBOT
#

exec(object[, globals[, locals]])```
This function supports dynamic execution of Python code. *object* must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). [1](https://docs.python.org/3/library/functions.html#id2) If it is a code object, it is simply executed. In all cases, the code that’s executed is expected to be valid as file input (see the section [File input](https://docs.python.org/3/reference/toplevel_components.html#file-input) in the Reference Manual). Be aware that the [`nonlocal`](https://docs.python.org/3/reference/simple_stmts.html#nonlocal), [`yield`](https://docs.python.org/3/reference/simple_stmts.html#yield), and [`return`](https://docs.python.org/3/reference/simple_stmts.html#return) statements may not be used outside of function definitions even within the context of code passed to the [`exec()`](https://docs.python.org/3/library/functions.html#exec "exec") function. The return value is `None`.
slate swan
#

read the docs its quite helpful

somber crown
maiden fable
proven osprey
somber crown
# maiden fable Idts
        if role not in member.roles:
            try:
                embed.set_image(url=f"attachment://D:/acrella-bot/verification/captcha/{captcha}.png")
                value = await ctx.send(embed=embed, delete_after=30)
                msg = await self.bot.wait_for('message', check=check, timeout = 30)
                if msg.content == key:
                    await value.delete()
                    await member.send(embed=passbed)
                    await member.add_roles(role)
                    await ctx.message.delete()
            except asyncio.TimeoutError:
                pass``` Β―\_(ツ)_/Β―
tawdry perch
#

ok so the eval is ran in my local computer and is not sandboxed by default, right?

vocal shoal
#

what is a good dpy alternative since you knwo, it got discontinued

tawdry perch
#

disnake

tawdry perch
#

disnake > pycord imo

slate swan
#

ok that doesnt matter

wanton veldt
#

how can i reload my cogs?

vocal shoal
slate swan
#

discum

vocal shoal
#

anyways will make sure to chewck em out thank you

tawdry perch
slate swan
#

what is the best module for making python guis

slate swan
#

i want to make something with tabs, buttons, image displayer, input boxes

tawdry perch
#

nvm I just thought about things

slate swan
tawdry perch
#

I was just thinking where it executes the eval in

slate swan
#

jsk only responds to the bot owner tho

tawdry perch
#

that is good to know, so server owner can't run those commands/admins?

slate swan
#

i recommend you add your id in the owner kwarg in the bot constructor

tawdry perch
#

good, then I can keep that extension in there

slate swan
#

nice

wanton veldt
tawdry perch
#

make a argument that takes the name of extension and then use the reload_extension

slate swan
#

youll have to make a command for it

proven osprey
wanton veldt
#

hi i have a question why i get this error?

from discord.ext import commands
from discord.utils import get

class join(commands.Cog, name="join"):
    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_member_join(self, member):
        channel = commands.get_channel(910565602362556426)
        embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined the server.")
        ember=embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
        await channel.send(embed=embed)
        role = discord.utils.get(member.guild.roles, name = "γ€ŒπŸŒ γ€USER")
        await member.add_roles(role)
        print(f"{member} was given {role}")
        
def setup(bot: commands.Bot):
    bot.add_cog(join(bot))
slate swan
#
self.bot.get_channel(int)
vocal shoal
#

discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.moderation' raised an error: ImportError: cannot import name 'InteractionType' from 'discord_components'
Why failing to import InteractionType, or is it InteractionEventType?

slate swan
#

is there a parameter for user banners?

#

is

discord.Member

is discord just a var of the class i.e

discord.Member = Member()
proven osprey
#

guys how to make the buttons can be pressed more than one time?

slate swan
proven osprey
#

i cant ask here or what?

slate swan
#
self.stop()

stops the class from listening to an interaction?

brave vessel
#

but the view automatically times out after 3 minutes or so of no interactions

proven osprey
stuck parrot
#

hi

#

Why if I change the value of **alarm **using the command it's not reflected on the on_ready event

@client.command()
async def alarmvalue(ctx, number):
    alarm = number
    while True:
        try:
            number = float(number)
            if number % 1 == 0:
                await ctx.send(int(number))
            else:
                await ctx.send(number)
        except ValueError:
            await ctx.send("Value is not an integer.")
        return

@client.event
async def on_ready():
    
   

    while True:
        
        channel = client.get_channel(1232323

)
        price = driver.find_element_by_css_selector(".last")
        print(price.text)
        print(alarm," alarm")
        

        if float(price.text) <= float(alarm):
            print(price.text,"-------------")
            await channel.send(price.text)
        #Send the message to discord
     

        if  float(price.text)<= 0.98*alarm:
            print((price.text),"--------------")
        #Sent the message to discord

        time.sleep(1.5)
slate swan
proven osprey
#

if i clicked on button, it answered me and then im trying to click another, it writes me an interaction error

proven osprey
slate swan
proven osprey
#

no i didnt

slate swan
#

and its still doing what its supposed to right

proven osprey
#

i made only three buttons

slate swan
#

L

slate swan
#

well idrk about that since i use disnake

#

@brave vessel hey fronto do you mind answering some of my questions?

proven osprey
#

do i have to write something to use the buttons more than once? did you write something when you did something like that on disnake?

slate swan
#

well idk because in disnake you have to subclass ui.view

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

slate swan
#

mostly about oop

cloud dawn
slate swan
proven osprey
#

why do most of people use disnake? why is it better?

slate swan
cloud dawn
slate swan
#

yeah no need for third party libs

#

!pypi disnake

unkempt canyonBOT
slate swan
proven osprey
#

understood, thank you

slate swan
#

yw

slate swan
cloud dawn
slate swan
#

yeah and why discord.?

cloud dawn
#

unless call is defined Member() doesn't make sense

cloud dawn
slate swan
#

is that really allpithink