#discord-bots

1 messages · Page 562 of 1

visual island
#

not 10 seconds

shell bear
#

i try

brave vessel
#

Oh it’s not working because you forgot to start the task

shell bear
#

i did start it

#

i wait for a minute now

#

to see if it changes

brave vessel
#

usually you have to start the task like this, in on_ready

#
@client.event
async def on_ready(): # let's see if the bot is up
  if not change_status.is_running(): # making sure it hasn't started yet
    change_status.start()

this needs to be defined under the tasks.loop

#

I would also recommend cycle, as above, so you don't run into an error when you reach the end

shell bear
#

oh ok

#

1 sec

#

trying again rn

#

dont think it worked

brave vessel
shell bear
#

ok

#

no errors

brave vessel
#

You won’t need the client.wait_until_ready

shell bear
#

ok

#

wait 1 minute to see if worked

#

it only says playing status 1

#

;-;

#

should i use the other cycle thing

slate swan
#

how to make !help an embedded instead of ""

boreal ravine
slate swan
#

How to make !help all fancy

#

lol

boreal ravine
#

!d discord.ext.commands.Bot.help_command

unkempt canyonBOT
slate swan
#

ty

boreal ravine
#

this

slate swan
#

discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.

#

WHAT DOES THESE EVEN MEAN??

#

like bruh

final iron
slate swan
#

wdym?

#

what requests?

#

to run the bot?

final iron
#

Are you hosting on repl?

slate swan
#

lol

#

but I havent been on this repl since yesterday

final iron
#

IP addresses that make too many invalid HTTP requests are automatically and temporarily restricted from accessing the Discord API. Currently, this limit is 10,000 per 10 minutes. An invalid request is one that results in 401, 403, or 429 statuses.

boreal ravine
slate swan
#

I read it but like

boreal ravine
#

replit uses a shared IP thats why your getting rate limited

final iron
#

^

#

@slate swan

lilac latch
#

How to check if a user is present in a server

slate swan
#

yes but how do I host it 24/7 through things like VSC

final iron
#

Use a paid service or self host

slate swan
#

I dont really want to pay for it

#

whats a self host?

final iron
#

You host it locally on your own machine

slate swan
#

just run it on my computer all the time

#

or in the background, idk

final iron
#

Better than not being able to run your bot at all

boreal ravine
slate swan
#

I have a data base of urls that I want to have automatically delete when sent what is the best way of doing this

final iron
#

You should also consider if people are actually using your bot

boreal ravine
slate swan
#

how do I run it in the background without having the app open??

#

is that possible?

final iron
#

No

slate swan
#

I mean in can run and be open but not show on my bar

lilac latch
# boreal ravine meaning?

Like I want my bot to check if my 2nd bot is present in the server if it is I don't want it to respond but if it is not I want it to send a message

valid perch
lilac latch
valid perch
gloomy coral
#

Hello

#

what is the best buttons library compatible with nextcord

#

also is discord-slash compatible with it

boreal ravine
#

if your using a 2.0 fork that has buttons use it dont use 3rd party libs + forks

slate swan
#

nextcord doesnt yet

boreal ravine
#

it was an example

boreal ravine
slate swan
#

have buttons built in

valid perch
#

I'm not spoonfeeding you it all. Figure out where to get a guild from whereever your using your code

gloomy coral
#

?

boreal ravine
gloomy coral
#

They do

shrewd pasture
#

how would i run through all banned users to unban them all

gloomy coral
#

but i want a better buttons library with extensive documentation and users using it so they may have the same bugs

shrewd pasture
#

lemme go check

slate swan
boreal ravine
gloomy coral
#

of nextcord?

boreal ravine
#

yes

gloomy coral
#

isnt there any other way?

boreal ravine
#

theres literally an examples file

#

in the source files of the fork

gloomy coral
#

I know but i havent migrated to nextcord yet... I plan to soon

#

Till then which button library can i use

valid perch
#

So why are you talking about nextcord then?

#

Are you on dpy?

#

1.7? 2.0?

boreal ravine
#

hm

slate swan
gloomy coral
#

but can you suggest a buttons libary please?

gloomy coral
#

for now i strictly need a third party library

gloomy coral
#

uh.....?

valid perch
#

Use any 2.0 version for buttons

gloomy coral
#

ok

valid perch
#

Im not sure of third party libs for it though

boreal ravine
#

3rd party libs are buggy

gloomy coral
#

ok

#

im gonna use discord_buttons tho

#

cuz why not

boreal ravine
#

nice

slate swan
shrewd pasture
#

i cant figure out how to unban all users in a dsicord

#

please someone help me out

#

it wont let me unban via id either

slate swan
#
@bot.command()
@has_permissions(ban_members=True)
async def unban(ctx, userId: discord.User.id):
  user = get(id=userId)
  await ctx.guild.unban(user)
#

im not going to waste your time please try to make sense of what that says though

#

so you don't have to ask again

gloomy coral
#

GUYS

#

HELP

slate swan
#

yeah

gloomy coral
#

I took advice from y'all and used nextcord

slate swan
#

mhm

gloomy coral
#

problem is i have like 100 discord-slash slashcommands

#

AND THEY ALL IMPORT DISCORD AND DISCORD EXT

slate swan
#

bruh

#

does not nextcord has inbuilt slash commands?

#

it does

gloomy coral
#

it doesnt

#

i cant find

slate swan
#

i read it ban

gloomy coral
#

but more importantly I cant rewrite so many lines of code

#

there must be an easier way

slate swan
#

it doesnt

#

have it

#

you can stilll use discord-slash

slate swan
#

you just have to change every instance of discord.something to nextcord.something

shrewd pasture
gloomy coral
#

how can i use the same setup then on another pc

shrewd pasture
#

its igving random errors

slate swan
#

you can replace all the discords here

slate swan
#

!d discord.Guild.bans

unkempt canyonBOT
#

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

Retrieves all the users that are banned from the guild as a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`BanEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.BanEntry "discord.BanEntry").

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.
slate swan
#

how do you access audit logs through bot to look for certain events

boreal ravine
unkempt canyonBOT
#

class discord.AuditLogAction```
Represents the type of action being done for a [`AuditLogEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.AuditLogEntry "discord.AuditLogEntry"), which is retrievable via [`Guild.audit_logs()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.audit_logs "discord.Guild.audit_logs").
slate swan
#

heres some random code I found in the docs

#
async for entry in guild.audit_logs(action=discord.AuditLogAction.ban):
    print(f'{entry.user} banned {entry.target}')
#

so you would change the AuditLogAction.ban to a different action

valid perch
gloomy coral
#

it shows error everywhere discord is imported

slate swan
#

can someone help me with purge

chzz = guild.get_channel(887043608308514889)
await chzz.purge(limit=200)```
#

AttributeError: 'NoneType' object has no attribute 'purge'

#

however if I use it under a command it works with ctx like:

await ctx.channel.purge(limit=amount)```
gloomy coral
#

basically it cldnt get channel

#

ig its bot.get_channel

slate swan
#

dang you're right! @gloomy coral I messed up the channel id.. haha thank you so much

gloomy coral
#

xD

#
Traceback (most recent call last):
  File "C:\Users\jason\chad\bot.py", line 31, in <module>
    slash = SlashCommand(bot, sync_commands=True)
  File "C:\Users\jason\chad\venv\lib\site-packages\discord_slash\client.py", line 72, in __init__
    self.req = http.SlashCommandRequest(self.logger, self._discord, application_id)
  File "C:\Users\jason\chad\venv\lib\site-packages\discord_slash\http.py", line 22, in __init__
    self._application_id = application_id
NameError: name 'application_id' is not defined```
#

What to do??

#

using discord slash command

urban star
#

What is f-st

#

f-str*

brazen raft
#

!f-string

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

gloomy coral
#
ExtensionFailed: Extension 'cogs.wordgames' raised an error: AttributeError: module 'discord' has no attribute 'Message'
#

Help

#

i am using nextcord but it shld work right

brazen raft
#

Why do you use this directly?

#

What are you trying to do?

slate swan
#

what was the code for the process_commands thing

vagrant brook
#

await bot.process_commands(message)

#

Also next time you should probably search on docs

slate swan
#

its much easier to ask people then search through docs that make no sense to me

#

my code still dosnt work

brazen raft
#

Well but the docs for discord.py have a search bar and examples

slate swan
#

or atleast commands don't

brazen raft
#

Maybe you're returning before it reaches it?

slate swan
slate swan
brazen raft
#

It's in an on_message event, right?

slate swan
#

yeah

brazen raft
#

Do you have any other on_message somewhere?

slate swan
#

nope

brazen raft
#

Oh. Is your bot in 75+ servers & unverified?

slate swan
#

the actual command works the other ones dont

#

Indent the process commands out of your for loop

#

ok

#

it worked thanks and that the end of my bot

brazen raft
#

👍

slate swan
#

actually nah ima add a really suffisticated logging system that logs everything

late dock
#

How to run 2 python file at the same time? One will be how bot run, and one is handling command

slate swan
#

What? Just run your main bot file and use cogs for commands and event listeners

late dock
#

How to do that?

#

I want to run main file, but the command on other file

slate swan
#

Create cogs

boreal ravine
#

how do I remove this from the help command?

slate swan
#

With the hidden=True kwarg

boreal ravine
#

where do I put that

slate swan
#

In your command decorator..

#

And you need to make your own help commend

boreal ravine
#

no im using the default help command

boreal ravine
slate swan
#

Well apparently get_command is a thing

#

So get the help command and set the hidden argument to true I guess

boreal ravine
#

hm

slate swan
#

!d discord.ext.commands.Bot.get_command

unkempt canyonBOT
#

get_command(name)```
Get a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.

This could also be used as a way to get aliases.

The name could be fully qualified (e.g. `'foo bar'`) will get the subcommand `bar` of the group command `foo`. If a subcommand is not found then `None` is returned just as usual.
boreal ravine
slate swan
#

Like any normal object editing

#

x.y = z

spiral frigate
#

how to get such an ID from such a value <@&ID>

#

<@&ID> -> ID

slate swan
#

Why do you need that

spiral frigate
#

find out the ID of the specified user

slate swan
#

And where do you use that

spiral frigate
#

in the command

slate swan
#

Team?

#

use the strip function.

#

Type hint the command argument to discord.Member

#

Then you can simply use .id

spiral frigate
#

it does not output like that writes an error

slate swan
#

Then show error and code?

#

!e py stripped = '<@&1234556>'.strip('<@&>') print(stripped)

spiral frigate
#
Ignoring exception in command кик:
Traceback (most recent call last):
  File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await self.prepare(ctx)
  File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 552, in transform
    return await self.do_conversion(ctx, converter, argument, param)
  File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 505, in do_conversion
    return await self._actual_conversion(ctx, converter, argument, param)
  File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 451, in _actual_conversion
    ret = await instance.convert(ctx, argument)
  File "C:\Users\Baraban4ik\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\converter.py", line 195, in convert
    raise MemberNotFound(argument)
discord.ext.commands.errors.MemberNotFound: Member "<@&901771204652843049>" not found.
unkempt canyonBOT
#

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

1234556
slate swan
slate swan
#

lol they are typehinting it as discord.Member and pinging a role , gg

#

You know that <@&id> is a role mention and not member mention right?

#

You mentioned a role when using the command

spiral frigate
#

I'm an idiot didn't know

ocean leaf
#

is it the correct way to do this? I want to make a database of all reaction roles and it's role id but instead of creating another json obj, it edits the existing one. How can i make it create a separate json obj for all reaction emoji and roles?

slate swan
boreal ravine
#

cringe json

ocean leaf
maiden fable
#

Read the JSON file
Save the dict in a variable
Append the new record to the dict
Open in write mode and just save the new dict to the json

slate swan
slate swan
#

Might want to try it out sometimes

ocean leaf
#

now i remember the keyword is "append"

#

i have to learn searching

#

thanks for the link btw

slate swan
#

add data to json python
append data to json python
add data to existing json python

#

Just think about what you want to do in a few words

tough wagon
#

Any tutorials how to work with subcommands?

ocean leaf
#

@slate swan it gives AttributeError: 'dict' object has no attribute 'append'

near oyster
#

AttributeError

cyan bay
#

sup so how do i make the embed a different color

tough wagon
#

bruv

#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
serene forum
#

i need help

tough wagon
#

color attr

serene forum
#

anyone wanna help me

#

PLease?

tough wagon
#

just send question bruh

serene forum
#

ok

#

bruh

rigid torrent
#

Hi
I wanna make a reply bot how do I make it ?

tough wagon
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.
tough wagon
#

or ctx.reply

rigid torrent
tough wagon
#

then how?

serene forum
#

i have a bot, i made it, so now i want to make an embed, I MADE IT, now i want to change the color, i did NOT make it

#

so how to change color

weary onyx
unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
tough wagon
#

there is color attr

serene forum
serene forum
#

me no understand

#

ok wait

cyan bay
#

click that link

#

it takes u to the documentation i think

tough wagon
#

u make wtf = discord.Embed(title="bruh", description="very bruh lol", color=discord.Color.blue())

cyan bay
#

then when u want to send the embed u do await message.channel.send(wtf = wtf), right?

serene forum
#

sry not that one

cyan bay
tough wagon
#

just like bruh

#

not in add_field

serene forum
#

?

tough wagon
#

in specifing embed

serene forum
#

what not in add field

tough wagon
#

like embed=discord.Embed(..., color=...)

tough wagon
serene forum
#

oh

#

got it.

#

THEN where do i put it?

tough wagon
#

bruh?

hasty iron
#

they just told you

tough wagon
serene forum
cyan bay
tough wagon
#

we dont spoonfeed

serene forum
cyan bay
#

wtf = discord.Embed(title="bruh", description="very bruh lol", color=discord.Color.blue())

#

thats the code

serene forum
cyan bay
serene forum
tough wagon
#

sorry but no

serene forum
#

ok nm

serene forum
cyan bay
serene forum
#

bruhhhhhhhhh im a beginerrr bruhhhhhhhhhhhhhhhh

cyan bay
#

just type color = discord.Color.blue()

serene forum
#

ok fine

tough wagon
#

now you just move color=discord.Colour.dark_blue() to embed

serene forum
tough wagon
#

wtf

#

learn python please

cyan bay
#

🤦‍♂️

serene forum
#

fuck you guys

tough wagon
#

no problem

hasty iron
#

lmao

tough wagon
cyan bay
#

k i fixed ur code in replit @serene forum

tough wagon
#

oh @hasty iron maybe u know how to use subcommands, or where is their docs

hasty iron
#

!d discord.ext.commands.Bot.group

unkempt canyonBOT
#

@group(*args, **kwargs)```
A shortcut decorator that invokes [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
tough wagon
#

bruv didnt think it's group

#

thx anyway

slate swan
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
tough wagon
ocean leaf
#

i wanna create a new json obj

#

i want to append data in the json file inside a different {}

tough wagon
#

dict[index] = value

ocean leaf
tough wagon
#

yes

#

in json there is only one {} that can contain more data

ocean leaf
boreal ravine
tough wagon
#

like { 'bruh': 182, 'lol': { 'bruhy': 1 } }

ocean leaf
ocean leaf
ocean leaf
#

lemme try

tough wagon
#
data = get_json_data
data[message.id] = {'role_id': role_id, ...}```
ocean leaf
#

can u pls give me another example of what and how to do that?

tough wagon
#

can be like that

ocean leaf
tough wagon
tough wagon
#

i already forgot how to get that dict form json)

ocean leaf
#

ik

#

wait

brave ravine
#

is there a reason behind bots not being able to have rich presence images?

boreal ravine
brave ravine
#

ya

#

they technically do have a rich presence, but its just "playing __" for example

#

without an image

boreal ravine
#

well have you tried testing it on your bot using an rpc maybe before asking here

brave ravine
#

that was not my question

boreal ravine
#

I think u can but im not sure

#

i know

boreal ravine
brave ravine
#

makes sense

#

kinda wish it was built into discord.py cause i wanna customize my personal bots more

edgy trellis
#

what loop don't cause commands to not works and is not infinite(you can set how many times it will be repeated)?

brave ravine
#

this kind of loop

#
for x in range(0, 5):
  do something```
edgy trellis
brave ravine
#

yes thats how loops work

slate swan
#

how can you send message to a user using their ids

brave ravine
#

possible (thanks to the people that corrected me, taught me something new)

#

u can send a message to a user who used a command tho

brave ravine
#

thats what i did for a few of my bots help commands so that they didnt clutter chats

tough wagon
#

get by id

boreal ravine
unkempt canyonBOT
boreal ravine
#

save that in a variable

#

then send it

tough wagon
#

lol bruh k_weirdxd

vale narwhal
#

How do i convert time to timestamp i tried the datetime to timestamp one but have no idea how to convert the "time" to timestamp

date_string = "10/26/2021"
date = datetime.datetime.strptime(date_string, "%m/%d/%Y")
timestamp = datetime.datetime.timestamp(date)
await ctx.send(f"<t:{round(timestamp)}:R>")
tough wagon
#

not here

vale narwhal
vale narwhal
#

That's why im asking here

tough wagon
#

yes but you need a number like 120958235 that you are converting from datetime

#

so not here

#

it could be related to this channel if you asked like how to make timestamp

slate swan
#

In user_id: Value "<built-in function id>" is not snowflake.
i am using await bot.fetch_user(id)

tough wagon
#

more code pls

urban star
#

How can I use rich presence?

#

With dpy

boreal ravine
#

how would I set my help command in a cog (im using the default one just editing it)?

tough wagon
#

first 3 lines are init of cog

#

Help() = your help command

boreal ravine
#

ty

urban star
tough wagon
urban star
#

Why

tough wagon
#

you think i know?

urban star
#

There is a code but I can't find it

tough wagon
#

@discord-developers WHY BOTS CANT USE RICH PRESENCE

urban star
tough wagon
#

ok

urban star
#

Just mean if anyone knows it

tough wagon
#

@strong ibex whyyy

slate swan
#

Is it possible that there can be a Nonetype on client.guilds?

slate swan
#

Ohh how

#

Lol

tough wagon
#

sry edited

#

it can be [], not none

urban star
#

@indigo moth

slate swan
#

Who are you pinging?

urban star
#

I don't know

#

Just anyone

#

🙂

keen talon
urban star
#

@wary basalt

urban star
late dock
#
foot = [
  "Trivia:\n...1",
  "Trivia:\n...2",
  "Trivia:\n...3"
]
embed.set_footer(text=random.choice(foot))

When I doing this, it give me error. Did I miss something or it not possible?

tough wagon
#

what error

slate swan
# tough wagon what error
@client.command(pass_context=True)
async def drink(ctx):
    client.counter += 0.03
    client.dict[ctx.author.id] = client.counter
    await ctx.send(f'{ctx.author.mention}\'s Blood Alcohol Concentration level is now {client.counter}')
    await asyncio.sleep(60*(60))
    client.counter = 0

@client.command()
async def checkbac(ctx, arg : discord.Member):
    await ctx.send(f'{ctx.mention} has a BAC of {client.dict[arg.author.id]}')```
spring zealot
#

error pls

slate swan
#

its a game
basically
i run this function, my "counter" adds 0.3 and sets the updated value to my name
and in the next function im getting the counter value

#

ik its not

spring zealot
#

ok but what was the error that came

keen talon
tough wagon
#

not he asked bruh

late dock
tough wagon
#

how do you define command

slate swan
#

self explanatory

tough wagon
#

like decorator @commands.command

spring zealot
#

doesnt look like it's related with the game code

keen talon
tough wagon
spring zealot
tough wagon
#

it's not related to aliases

late dock
spring zealot
#

send full command definition

#

including decorators

keen talon
late dock
#
    @block_info.command(name='grass_block', aliases='grassBlock')
    async def grassBlock(self, ctx):
        title = 'Grass Block'
        desc = 'A grass block is a natural block that generates abundantly across the surface of the Overworld.'
        link = 'https://minecraft.gamepedia.com/wiki/Grass_Block'
        pict = 'https://static.wikia.nocookie.net/minecraft_gamepedia/images/b/b5/Vector_dirt.svg/revision/latest/scale-to-width-down/192?cb=20180202214450'
        
        val1 = 'JE: `minecraft:grass_block`\nBE: `minecraft:grass`'
        val2 = 'Tool: `Shovel`\nMin: `By Hand`'
        foot = [
            "Trivia:\nThis was first block added in Minecraft just like cobblestone and dirt",
            "Trivia:\nA grass block used as icon of the Minecraft Launcher and BE App",
            "Trivia:\nGrass blocks and dirt blocks changing between each other is a common cause of chunk updates."
        ]

        embed=discord.Embed(title=title, url=link, description=desc)
        embed.add_field(name='Block ID', value=val1, inline=True)
        embed.add_field(name='Tool', value=val2, inline=True)
        embed.set_thumbnail(url=pict)
        embed.set_footer(text=random.choice(foot))

        await ctx.send(embed=embed)
slate swan
# keen talon share error
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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: 'Context' object has no attribute 'mention'```
spring zealot
spring zealot
#

if u want only 1 alias just put the alias in a list

spring zealot
late dock
#

Oh I'm dumb

#

I though it was my random

spring zealot
#

that code looks fine

slate swan
late dock
#

Ok it work

celest cobalt
#

code:

@client.command()
async def server(ctx, *, args):
    username = ctx.message.author
    bprint.info(f"{username} used the 'server' command")

    if args.lower() == "info":
        bprint.info(f"{username} used the 'server - status' command")
        content = "info!"

    elif args.lower() == "start":
        bprint.info(f"{username} used the 'server - start' command")
        content = "start!"

    else:
        content = "else??"

    await ctx.send(content)

problem: If someone only uses $server with no args it spits out an args error. But I want it so that a error msg appears in chat. How could I do that?

slate swan
#
@client.command(pass_context=True)
async def drink(ctx):
    client.counter += 0.03
    client.dict[ctx.author.id] = client.counter
    await ctx.send(f'{ctx.author.mention}\'s Blood Alcohol Concentration level is now {client.counter}')
    await asyncio.sleep(60*(60))
    client.counter = 0

@client.command()
async def checkbac(ctx, arg : discord.Member):
    await ctx.send(f'{ctx.mention} has a BAC of {client.dict[arg.author.id]}')```
spring zealot
slate swan
#

shit

tough wagon
#

@slate swan

slate swan
#

my bad

spring zealot
tough wagon
slate swan
#

arg.mention

tough wagon
#

ok arg

spring zealot
#

ctx.author is the author of the message
if you want their mention, it's ctx.author.mention

tough wagon
keen talon
spring zealot
#

it would be better to rename arg to member to make it more clear to read

spring zealot
#

but yes arg.mention then

tough wagon
#

like args=""

#

it will set args to empty string by default

keen talon
slate swan
# tough wagon he said `arg.mention`, look he have `arg: discord.Member` argument?
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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: KeyError: 439875622626394122
#

my. code is working, but there's a little bug

slate swan
#

If i do !checkbac before i even drink, rather than it giving me 0.00 it gives me error

tough wagon
slate swan
keen talon
slate swan
#

no way to fix?

keen talon
tough wagon
slate swan
#

u mean accept?

keen talon
slate swan
#

just accept it :(

#

i can write if else statment

tough wagon
#
if user_id not in dict:
    return await ctx.reply('use !drink first')```
slate swan
#

yea

tough wagon
keen talon
tough wagon
#

too broad exception clause

vagrant brook
#

Actually

#

if user_id not in dict: works too

tough wagon
#

uh ye

celest cobalt
#

any other ideas?

tough wagon
#

wdym? error?

keen talon
tough wagon
celest cobalt
keen talon
celest cobalt
#

heres the code im sending the error in a sec

lament mesa
celest cobalt
#

error:

Ignoring exception in command server:
Traceback (most recent call last):
  File "C:\Users\49159\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\49159\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await self.prepare(ctx)
  File "C:\Users\49159\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\49159\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 706, in _parse_arguments
    kwargs[name] = await self.transform(ctx, param)
  File "C:\Users\49159\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: args is a required argument that is missing.
slate swan
#
if ctx.author.id not in client.dict:         await ctx.send('0.00')
#

same error tho

tough wagon
slate swan
#

why retunr tho?

keen talon
#

lol u didn't even listen to what we said

slate swan
#

pls explain too

tough wagon
slate swan
#

ok

celest cobalt
slate swan
#

same error with return as well

tough wagon
#

most of users that ask there dont know basics

tough wagon
slate swan
#

1 sec

keen talon
keen talon
slate swan
#
@client.command(pass_context=True)
async def drink(ctx):
    client.counter += 0.02
    client.dict[ctx.author.id] = client.counter
    await ctx.send(f'{ctx.author.mention}\'s Blood Alcohol Concentration level is now {client.counter}')
    await asyncio.sleep(60*(30))
    client.counter = 0

@client.command()
async def checkbac(ctx, *, arg : discord.Member):
    await ctx.send(f'{arg.mention} has a Blood Alcohol Level of {client.dict[ctx.author.id]}')
    if ctx.author.id not in client.dict:
        return await ctx.send('0.00')
tough wagon
tough wagon
#

if should be before await ctx.send

slate swan
#

fockk bro my head is spinning

#

my bad

keen talon
boreal ravine
slate swan
#

lmk when u find this on a tutorial

tough wagon
#

yeah pass_context is bruhy useless

keen talon
slate swan
#

literally wrote it myself by okay

keen talon
slate swan
#

dont care what yall say bro im proud bc ik i wrote this shit

tough wagon
boreal ravine
#

literally pass_context=True is from < 1.0

#

I mean > 1.0

boreal ravine
#

why did you use pass context then

slate swan
#

that i looked up

boreal ravine
slate swan
#

but most of the stuyff if by me

#

and bro yall so tough on discord yall aint gonna open ur mouth if u see me irl

#

little ass kid

keen talon
boreal ravine
#

why did u use pass context then

#

Nice

reef shell
#

<@&831776746206265384>

#

Please check

hot cobalt
#

@slate swan Please calm down, there's really no need to get angry no matter the situation

slate swan
#

my fault

keen talon
#

mods can check deleted msg

#

XD

slate swan
#

imma just leave chat

boreal ravine
#

ok

sage swift
#
   async def solarflare(self, ctx, startTime=None, endTime=None):
        url = f'https://api.nasa.gov/DONKI/FLR?startDate={startTime}&endDate={endTime}&api_key=Sw74skknSPoVUr4N7o6JsS0cep35Y4ylLelzsXy8'
        data = requests.get(url).json()
        pages = len(data)
        content = data[0:pages]
        current_page = 0
        message = await ctx.send(f"Page {current_page}/{pages}:\n{content[current_page - 1]}")
        await message.add_reaction("◀")
        await message.add_reaction("▶")

        def check(reaction, user):
            return user == ctx.author and str(reaction.emoji) in ["◀", "▶"]

        while True:
            try:
                reaction, user = await self.bot.wait_for("reaction_add", timeout=60, check=check)

                if str(reaction.emoji) == "▶" and current_page != pages:
                    current_page += 1
                    await message.edit(content=f"Page {current_page}/{pages}:\n{content[current_page - 1]}")
                    await message.remove_reaction(reaction, user)

                elif str(reaction.emoji) == "◀" and current_page > 1:
                    current_page -= 1
                    await message.edit(content=f"Page {current_page}/{pages}:\n{content[current_page - 1]}")
                    await message.remove_reaction(reaction, user)


                else:
                    await message.remove_reaction(reaction, user)

            except asyncio.TimeoutError:
                await message.delete()
                break


def setup(bot):
    bot.add_cog(SpaceWeather(bot))

So what i wanted it to do was after the user clicks the reaction, it moves to the next page (edits the message) and remove the reaction, after clicking once it works fine, but it doesnt remove the reaction or doesnt move to the next page after that

deep musk
#

How can I get the cog class name for a command/group?

boreal ravine
deep musk
#

yes

lament mesa
#

!d discord.ext.commands.Command.cog

unkempt canyonBOT
reef shell
unkempt canyonBOT
reef shell
#

Same with the group

deep musk
#

Ah cool thanks! (both)

devout iris
#

Hey

reef shell
unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
reef shell
#

!d discord.ui.Select

unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.

This is usually represented as a drop down menu.

In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Select.values "discord.ui.Select.values").

New in version 2.0.
safe fulcrum
#

How to set webhook username using python

random sleet
#

i have this problem that reason is only the first word in the sentence. Does somebody know how to get the hole string?

boreal ravine
coral vessel
#

i tried write bot.event command
but is that possible if only we as admin can command the bot (not member) ?

brave flint
#

hello i got a issue on heroku, did anyone can help me?
2021-10-27T09:26:21.966670+00:00 heroku[worker.1]: Starting process with command `phyton main.py` 2021-10-27T09:26:22.581705+00:00 heroku[worker.1]: State changed from starting to up 2021-10-27T09:26:22.637325+00:00 app[worker.1]: bash: phyton: command not found 2021-10-27T09:26:22.743918+00:00 heroku[worker.1]: Process exited with status 127 2021-10-27T09:26:22.933383+00:00 heroku[worker.1]: State changed from up to crashed

slate swan
safe fulcrum
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

manic wing
boreal ravine
#

pain.exe

slate swan
slate swan
#

Lucas

#

xD

reef shell
slate swan
#

just trying to see if it works

boreal ravine
#

it does you just made a typo

reef shell
#
member = discord.Object(id=0) # user ID
try:
    await guild.unban(member)
except discord.NotFound:
    # member not banned / doesnt exist 
boreal ravine
#

it's supposed to split the name & the tag using # but u did a

reef shell
#

don't follow yt tutorials

boreal ravine
slate swan
#
async def add(ctx , num1:int , num2:int):
 await ctx.reply(num1 + num2)```
#

why isnt this code working?

slate swan
#

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "add" is not found

boreal ravine
#

did u run the command

slate swan
#

yh

boreal ravine
#

!add 1 5

#

hm

slate swan
#

i did that n it aint working for some reason

boreal ravine
#

@slate swan show full file if you could

unkempt canyonBOT
#

Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

slate swan
#
from discord.ext import commands
from discord.ext.commands.core import command

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

@bot.command()
async def hello(ctx):
 await ctx.reply('Wagwan?')

@bot.command()
async def add(ctx , num1:int , num2:int):
 await ctx.reply(num1 + num2)

bot.run(')```
boreal ravine
#

hm

boreal ravine
slate swan
#

u want me to delete it?

boreal ravine
#

yes

#

maybe it overwrites from discord.ext import commands idk

#

@slate swan does .hello work?

slate swan
#

yh

#

nah the add function still dont work

boreal ravine
#

show full traceback/error

slate swan
#
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "add" is not found```
boreal ravine
#

full traceback if u could

slate swan
#

i cant get commands.Bot's listen method to work in the main discord bot file

safe fulcrum
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
boreal ravine
slate swan
#

it shows theres no problem

slate swan
boreal ravine
#

usually like this

Ignoring exception in 
file://ur_file

the above exception was blah blah blah
slate swan
#

its almost like it never worked except it worked like 4 hours ago

boreal ravine
#

show me what u did

slate swan
#

its like it does not got run atall

#
discord.ext.commands.errors.CommandNotFound: Command "add" is not found ```
#

this is all it shows me

slate swan
boreal ravine
slate swan
slate swan
#

this is all i have output woze

slate swan
boreal ravine
#

hm

slate swan
#

i disable members intents and it works 😡

boreal ravine
#

oh

tawdry perch
slate swan
#

did i say it works??? i ment it never works

slate swan
#

but i already have

tawdry perch
slate swan
#

whats that

tawdry perch
#

And does other commands work?

slate swan
tawdry perch
#

And what is the full traceback

slate swan
#
discord.ext.commands.errors.CommandNotFound: Command "add" is not found
tawdry perch
#

Thats the whole traceback?

slate swan
#

yh

tawdry perch
#

Actually

#

Try renaming it

slate swan
#

isnt tracebaxk the thing that comes in the terminal

boreal ravine
#

yes

slate swan
#

yh thats what comes up

boreal ravine
#

u said it dindt show up though

slate swan
#

and now fucking on_message is not working cant fetch anything on_ready is not working

#

nothing is working anymore

#

Shuts down computer

#

im about to destroy my computer

slate swan
boreal ravine
slate swan
boreal ravine
slate swan
#

...

tawdry perch
#

@slate swan rename the command

slate swan
#

i have

#

n it still aint working

tawdry perch
#

But all other commands work..?

slate swan
#

it works

boreal ravine
#

how

slate swan
#

but when i change it

#

it does not

boreal ravine
#

hm

#

@slate swan show tracebackk

slate swan
#

bro how many times have i shown u guys the traceback

slate swan
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

tawdry perch
slate swan
#

fuck me it works now

#

out of nowhere it just works

#

i restarted visual code

#

thank you @tawdry perch @boreal ravine

tawdry perch
#

I guess you never save the file

slate swan
boreal ravine
#

LMFAO

tender charm
#

Hello, when I create folder for new discord bot, and when I will open cmd for that folder, I use command pip install discord.py and in the code I use import discord and from discord.ext import commands. After start program, it will do this: ModuleNotFoundError: No module named 'discord.ext'; 'discord' is not a package

#

Please help, what can i do?

elfin island
#

what did you name this folder you created?

elfin island
#

if you perchance called it discord python is now confused about what to import (the library you installed or this folder) (this conflict can occur if you named a file in this folder as discord.py as well)

tender charm
#

what is it?

maiden fable
#

Which IDE do u use?

#

Like which text editor

tender charm
#

VSC

maiden fable
#

Oh ok nvm then

valid galleon
#

so i made a seperate dban command which deletes the messages in the last 24 hours(which is default). but i dont want it to delete the messages when the normal ban command is used. this is the code that i have. what am i doing wrong?

    @commands.command()
    @commands.has_permissions(ban_members = True)
    async def ban(self, ctx, member: discord.Member,*,reason = None, delete_message_days = 0):```
#

?

slate swan
valid galleon
boreal ravine
#

then dont make it delete it?

valid galleon
boreal ravine
#

i dont think ban commands delete messages

valid galleon
#

this is what i m using rn:
async def ban(self, ctx, member: discord.Member,*,reason = None, delete_message_days = 0):

valid galleon
boreal ravine
#

i dont think its possible

graceful gulch
boreal ravine
valid galleon
graceful gulch
#

set delete_message_days to 0

valid galleon
#

ive done that already though

boreal ravine
#

thats a parameter though

valid galleon
#

do you think its delete_message_days : 0 and not delete_message_days = 0?

graceful gulch
boreal ravine
graceful gulch
#

how do u expect to ban someone without banning them??

boreal ravine
#

!e

def ban(dmd: 0):
  return dmd
print(ban("5"))
#

oh 🗿

valid galleon
#

umm

unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

5
boreal ravine
#

hm

#

didnt know that worked

pliant gulch
#

Type hints don't do anything in vanilla python

#

They are strictly for readability

upbeat otter
#

Guys, how do I move a channel to a category? this is the code i have

async def mover(ctx, position, name):
  if ctx.message.author.guild_permissions.manage_channels:
    channel = get(ctx.guild.channels, name=name)
    await channel.edit(category=position.upper())
pliant gulch
#

In dpy internally they convert it

graceful gulch
pliant gulch
boreal ravine
pliant gulch
#

And if you run it then it won't error

pliant gulch
boreal ravine
#

!e

def add(a, b):
  return a + b
print(add("hi", "you"))
``` who would wanna add strings together though
unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

hiyou
slate swan
boreal ravine
#

but we werent talking about isinstance

pliant gulch
#

Either way tyoehints in regular python don't do anything they just tell the person what the function expects

boreal ravine
#

you can do that?

pliant gulch
#

ctx.command === command?

#

You put in an extra =

visual island
pliant gulch
#

But doesn't do anything afterwards

#

No, I meant you put in an extra = on actidrnt

#

You only need 2

upbeat otter
#

Guys, how do I move a channel to a category? this is the code i have

async def mover(ctx, position, name):
  if ctx.message.author.guild_permissions.manage_channels:
    channel = get(ctx.guild.channels, name=name)
    await channel.edit(category=position.upper())
acoustic sleet
#

How can I DM a user with my bot?
im using cogs

boreal ravine
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
boreal ravine
#

show code

acoustic sleet
boreal ravine
#

why is ur elif statement

slate swan
#

indentation?

boreal ravine
#

inside your if statment

slate swan
#

that elif don't connect to anything

boreal ravine
boreal ravine
#

its supposed to be like this

if ...:

elif ...:
``` but you did
```py
if ...:
  
  elif ...:
urban star
#

how can I get discord api ping?

slate swan
#

?

upbeat otter
#

api ping?

urban star
#

There is no api ping?

#

???

upbeat otter
#

it will give the bot's ping

urban star
#

Okay

slate swan
#

oh

urban star
#

I see

#

Thanks

upbeat otter
valid galleon
#

what about the message latency?

slate swan
#

can anyone help me or provide docs to make a fight mini-game command? like !fight {user}
but the options like fight,block,kick
and each user gets 1 chance after other and the fight ends 1 user hp goes 100-0 and options will be used as kick not !kick or !fight kick

slate swan
# slate swan can anyone help me or provide docs to make a fight mini-game command? like !figh...

I'll tell you how you can do it to take the user input, the rest is pure python which you have to do yourself, if you don't know then you really need to learn more python because this is really basic, to get the user input use wait_for and for the check simply check if the author is any of them (you can decide who starts), make sure you have a turn var which holds one of the users, after each time a user gives an answer, make sure to change the turn with the other player so that when you check for their message it'll only take the current player that needs to input and not both of them, after you got the message use .content.lower() and check if it's one of your options, if it is then do whatever you need to do, otherwise do something else

#

It's really really easy to create one, gl 👍

#

!d discord.ext.commands.Bot.wait_for

#

This is the wait_for that you'll need

#

It didn't send 🤨

#

!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**...
#

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

There

#

Ugh not it sent twice

#

Weird

#

Well whatever, gl 🚶‍♂️

junior terrace
#

hello

#

how do i make it case sensitive?

leaden jasper
#

how to get list of running tasks

junior terrace
#

if message.content.startswith('blender progetto'):

#

i have tried with if message.content.lower.startswith('blender progetto'):

#

but doesnt work

visual island
#

.lower()

#

you forgot parentheses

visual island
slate swan
#

How can I get the users who clicked the button?

leaden jasper
#

how to name a task

supple jacinth
#

hello im new to discord py, would someone be able to help me make a command handler?

upbeat otter
upbeat otter
leaden jasper
#

oh

supple jacinth
#

Wdym i said what i wanted to do

upbeat otter
mortal thistle
#

how can I delete all rows at once from my sqlite database?

supple jacinth
#

no command handler

#

like have commands in files in a folder

upbeat otter
upbeat otter
upbeat otter
boreal ravine
#

same

upbeat otter
mortal thistle
#

hello

#

Can someone help me how do I delete all rows in my sqlite database without deleting my database?

upbeat otter
mortal thistle
#

😦

#

ok

upbeat otter
mortal thistle
#

that's why I came here

upbeat otter
brave flint
#

um did anyone understand about heroku?

upbeat otter
mortal thistle
#

I did it

upbeat otter
#

oh sad

mortal thistle
#

anyways, thanks @upbeat otter

brave flint
#

i deployed like 9 time and it always show a same error
Process exited with status 127

visual island
leaden jasper
upbeat otter
neon oyster
#

how do i accept 2 errors only saying except once

leaden jasper
upbeat otter
visual island
neon oyster
#

thx

leaden jasper
#

when i do

for i in asyncio.all_tasks(bot.loop):
  print(i.get_name())
``` it doesnt print the name of the function
leaden jasper
#

i wanna get the names of running tasks

#

but how do u name a task first

upbeat otter
leaden jasper
#

i need to do it with a command outside the task

visual island
upbeat otter
#
@tasks.loop(time):
  async def function1():
    print("function1 is running")
    #do other stuff
#

this should help tho

leaden jasper
leaden jasper
#

my tasks works fine i dont need help with that

#

im trying to get a list of running tasks by doing a command elsewhere

#

ur giving me the wrong help btw

visual island
leaden jasper
visual island
#

i.set_name()?

#

never been this far but lets see

leaden jasper
#

i think gota do get_task() then set_name in the task function

supple jacinth
#

😩

valid perch
upbeat otter
leaden jasper
upbeat otter
leaden jasper
#

i did

i can make a function just how do u name the task

supple jacinth
visual island
supple jacinth
#

also whats wrong here?

leaden jasper
boreal ravine
supple jacinth
#

im trying to psudocode

boreal ravine
supple jacinth
supple jacinth
visual island
boreal ravine
supple jacinth
boreal ravine
#

hm

supple jacinth
#

lol

visual island
#

similar to := in python

boreal ravine
#

wait ill give a tutorial

boreal ravine
#

👀

safe fulcrum
#

Ok, is there a way to send webhooks and embeds using discord webhook

#

embed.add_field(name='etc'....)

boreal ravine
#

yes

safe fulcrum
#

how do i send a webhook trought that library

boreal ravine
safe fulcrum
#

yes

boreal ravine
#

!d discord.TextChannel.create_webhook

unkempt canyonBOT
#

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

Creates a webhook for this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.

Changed in version 1.1: Added the `reason` keyword-only parameter.
boreal ravine
#

!d discord.Webhook.send

supple jacinth
unkempt canyonBOT
#

await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., wait=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message using the webhook.

The content must be a type that can convert to a string through `str(content)`.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object.

If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects to send.
safe fulcrum
#

Ohh

visual island
safe fulcrum
#

thanks

#

wait

solemn grove
#
@bot.listen()
async def on_message(message):
  if not (message.author == bot.user) and (message.content.lower().startswith('Hi')):
    await message.reply(f"Hello", mention_author=True)

why it isnt working?

safe fulcrum
#

how should i put "await"

boreal ravine
visual island
safe fulcrum
#

i mean

#

im not making a bot

supple jacinth
safe fulcrum
#

imma send u the code

supple jacinth
upbeat otter
safe fulcrum
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

solemn grove
safe fulcrum
#
embed = discord.Embed(
    title = 'Title',
    colour = discord.Colour.blue()
)

embed.add_field(name='Field', value='Value')

send(???)

@boreal ravine

leaden jasper
boreal ravine
visual island
boreal ravine
boreal ravine
safe fulcrum
#

yeah

upbeat otter
#

how do I make it like: it shows, Voting Website in an embed, and it should take it to youtube?

safe fulcrum
#

ik

unkempt canyonBOT
#

@safe fulcrum, looks like you posted a Discord webhook URL. Therefore, your message has been removed, and your webhook has been deleted. You can re-create it if you wish to. If you believe this was a mistake, please let us know.

safe fulcrum
#

wt-

boreal ravine
# safe fulcrum ik

yes, pass in all the required args (name should be enough) and then save the webhook thingy in a variable then send it

upbeat otter
faint orchid
#

Hello. Please help me solve the problem - I created a bot that should change banners on the server after a certain time. But before launching, it gives the following error:

===== RESTART: C:\Users\Дмитрий\Desktop\discord-banner-changer-main\main.py ====
Traceback (most recent call last):
  File "C:\Users\Дмитрий\Desktop\discord-banner-changer-main\main.py", line 2, in <module>
    import discord
ModuleNotFoundError: No module named 'discord'

Code:

import os
import discord
import random
from discord.ext import tasks

BOT_TOKEN = ''

client = discord.Client()

@client.event
async def on_ready():
    print("logged in: ", client.user)

@tasks.loop(minutes=5)
async def main():
    images = os.listdir('images')
    image = random.choice(images)
    with open(f'images/{image}', 'rb') as f:
        guild = client.get_guild(530367265053474818)
        await guild.edit(banner=f.read())

@main.before_loop
async def before_main():
    await client.wait_until_ready()


main.start()
client.run(BOT_TOKEN)
leaden jasper
#

nope

#

i.get_coro().__name__ seems to print the type i guess

supple jacinth
leaden jasper
#

_loop would be other tasks

supple jacinth
#

main.py

from discord.ext import commands
import os

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

bot.load_extension("somecommands")

bot.run(os.environ['TOKEN'])

commands/somecommands.py

from discord.ext import commands # Again, we need this imported


class SomeCommands(commands.Cog):
    """A couple of simple commands."""

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

    @commands.command(name="ping")
    async def ping(self, ctx: commands.Context):
        """Get the bot's current websocket latency."""
        await ctx.send(f"Pong! {round(self.bot.latency * 1000)}ms") # It's now self.bot.latency

def setup(bot: commands.Bot):
    bot.add_cog(SomeCommands(bot))
upbeat otter
supple jacinth