#discord-bots

1 messages · Page 8 of 1

wanton roost
#

Wow, can i take it?

wanton roost
novel prairie
wanton roost
slate swan
#

You are trying to get the owner?

#

And mention them?

#

get_owner = await ctx.guild.fetch_member(ctx.guild.owner_id) part one) this will get the owner id
get_owner.mention part 2 this will allow you to mention the owner

Now again, think about the positioning of the code.

novel prairie
#

mention the owner

royal meteor
#

How can I fix this?

slate swan
#

💀

<@{ctx.guild.owner}>
novel prairie
#

like that py @bot.command() async def info(ctx): get_owner = await ctx.guild.fetch_member(ctx.guild.owner_id) get_owner.mention embed=discord.Embed (title=f""" **{ctx.guild.name} Info**""",description=f""" **Server ID** {ctx.guild.id} **Created On** {ctx.guild.created_at.strftime}("%b %d %Y") **Server Owner** <@{ctx.guild.owner}> **Member Count** {ctx.guild.member_count} **Channels** {len(ctx.guild.text_channels)} Text | {len(ctx.guild.voice_channels)} Voice **Region** {ctx.guild.region}""", color=000000) await ctx.message.reply(embed=embed)

slate swan
#

send full tb

royal meteor
# slate swan send full tb
  File "c:\Users\vaibh\OneDrive\Desktop\Advay Python Projects\main\main.py", line 22, in <module>
    asyncio.run(main())
  File "C:\Users\vaibh\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\vaibh\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "c:\Users\vaibh\OneDrive\Desktop\Advay Python Projects\main\main.py", line 19, in main
    [await bot.load_extension(f"cogs.{file[:-3]}") for file in os.listdir("cogs") if file.endswith(".py")]
  File "c:\Users\vaibh\OneDrive\Desktop\Advay Python Projects\main\main.py", line 19, in <listcomp>
    [await bot.load_extension(f"cogs.{file[:-3]}") for file in os.listdir("cogs") if file.endswith(".py")]
  File "C:\Users\vaibh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 991, in load_extension
    spec = importlib.util.find_spec(name)
  File "C:\Users\vaibh\AppData\Local\Programs\Python\Python310\lib\importlib\util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'cogs'```
thorn grove
#

ಥ_ಥ

slate swan
#

Correct me if I’m wrong

slate swan
tacit storm
slate swan
tacit storm
#

ctx.guild.owner returns a member object not an id. so you cannot mention the owner like that

slate swan
#

💀

hardy yoke
#

as established earlier, they don't have member intents. So they can't do it like that

slate swan
#

Then use @ without <>

royal meteor
slate swan
slate swan
slate swan
slate swan
#

the owner_id property doesn't require member intents

#

wb this

#

sarthyyy pepeShy

slate swan
slate swan
novel prairie
#

nvm i removed the owner thing i wil fix it later

slate swan
#

💀

novel prairie
#

but now it says something like Your ip:

thorn grove
#

Is it discord.utils again?

slate swan
slate swan
novel prairie
tacit storm
royal meteor
slate swan
slate swan
#

ever used tagscript?

#

what even is tagscript

novel prairie
#

balls

slate swan
slate swan
slate swan
novel prairie
thorn grove
slate swan
slate swan
slate swan
tacit storm
slate swan
#

you can set permission overwrites for that role in the channel

tacit storm
#

who tf turns off the guild intent either way

tacit storm
#

isn’t it enabled in Intents.default by default either way?

thorn grove
slate swan
novel prairie
#
@bot.command()
async def info(ctx):
 embed=discord.Embed (title=f"""
  **{ctx.guild.name} Info**""",description=f"""
  **Server ID** {ctx.guild.id}
  **Created On** {ctx.guild.created_at.strftime}("%b %d %Y")
  **Member Count** {ctx.guild.member_count}
  **Channels** {len(ctx.guild.text_channels)} Text | 
{len(ctx.guild.voice_channels)} Voice
  **Region** {ctx.guild.region}""", color=000000)
  message = await ctx.message.reply(embed=embed)``` ```py
  File "main.py", line 274
    message = await ctx.message.reply(embed=embed)
    ^
IndentationError: unexpected indent```
royal meteor
slate swan
#

Imagine using the code of red bot for a custom bot and being promoted to admin for that 💀

slate swan
#

idea

tacit storm
slate swan
tacit storm
#

it’s mid

hardy yoke
slate swan
#

And it’s being used for a 2.7k server

tacit storm
slate swan
unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
slate swan
thorn grove
tacit storm
slate swan
#

GuraSpeen y'all kids, I don't even host my bots

tacit storm
#

what.

tacit storm
#

stop using replit

hardy yoke
#

this is the repl curse

slate swan
#

Ye replit

novel prairie
tacit storm
#

i already know that you’re using replit and replit gets your shit blocked.

hardy yoke
#

type kill 1 in the shell and it'll fix itself probably

slate swan
slate swan
tacit storm
novel prairie
#

lmao

slate swan
tacit storm
slate swan
tacit storm
# novel prairie balls

so funny. im laughing my ass off because someone said “balls”. im laughing so hard rn omg

fresh ferry
#

any ideas boys ?

slate swan
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
#

who tf uses spaces tho

#

me

fresh ferry
#

so i should go forward a tab or back a tab ?

hardy yoke
#

you have a try: right there lota

slate swan
slate swan
fresh ferry
thorn grove
#

@slate swan what do i put after the target? What is for the channel viewing?

slate swan
fresh ferry
hardy yoke
# fresh ferry

if you want to use a try: statement you need to indent code inside it

although it'll break anyway because there's no except: statement

did you mean to use try?

thorn grove
slate swan
#

hi guys I am doing python app and I want to let discord show the activity of my app how to do that

slate swan
thorn grove
slate swan
thorn grove
#

Its only read message tho

fresh ferry
thorn grove
hardy yoke
slate swan
slate swan
thorn grove
slate swan
slate swan
#

!rule 7 what is it lmao

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
fresh ferry
slate swan
hardy yoke
#

oh well there's the except statement

slate swan
fresh ferry
#

its algoods i mean best way to learn right ? being chucked into the deep end ahha

slate swan
#

discord bots is totally not the best way to learn py

#

or any programming language in general

slate swan
#

that's good you'll get an easy grip at it once you check out the docs

fresh ferry
fresh ferry
#

your good man its not your job too 🙂

slate swan
#

soo dont pay

fresh ferry
slate swan
#

^ there are pretty much free resources available

#

not in one year actualy but near that maybe 1 year and 4 months like that

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.

thorn grove
#

@slate swan is is possible to set the view channel property to false to all users when i create a channel?

slate swan
slate swan
unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
slate swan
#

the overwrites kwarg

#

I learned the bad way, school and docs

thorn grove
slate swan
#

yes and stackoverflew for help

fresh ferry
slate swan
#

@commands.cooldown(1, 86400, commands.BucketType.user) how to make it into db, like if i restart bot it is not resetting for everyne

slate swan
slate swan
slate swan
#

!d discord.ext.commands.dynamic_cooldown

#

codegrepper is the badest thing everything is not working there 😂

thorn grove
slate swan
#

@fresh ferry note : start with python

slate swan
unkempt canyonBOT
#

class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.

Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.

The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.

x == y Checks if two overwrites are equal.

x != y Checks if two overwrites are not equal.

iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
slate swan
#

you would have to pass in this object for that kwarg

fresh ferry
thorn grove
slate swan
#

!d discord.ext.commands.dynamic_cooldown

unkempt canyonBOT
#

@discord.ext.commands.dynamic_cooldown(cooldown, type)```
A decorator that adds a dynamic cooldown to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

This differs from [`cooldown()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.cooldown "discord.ext.commands.cooldown") in that it takes a function that accepts a single parameter of type [`discord.Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") and must return a [`Cooldown`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Cooldown "discord.app_commands.Cooldown") or `None`. If `None` is returned then that cooldown is effectively bypassed.

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.

New in version 2.0.
silver reef
#

hey,how can i keep track of a certain command?
example : if i run a "1st command" >> !attack (prefix = !)
so the bot will ask me to choose between 3 commands like
!npc 1 , !npc 2, !npc 3 (choosing between 3 npc to attack)
but i want the user to be able to use one of these 3 commands only when he trigger the "1st command" (!attack)
can someone tell me how to do that? is there a specific method that i have to use?

slate swan
#

@slate swan may u help me with @discord.ext.commands.dynamic_cooldown(1, 86400, commands.BucketType.user)

#

i cant catch what should i do with dynamic_cooldown

slate swan
#

Oh btw
If the user sends
.reminder 1h something
How can I make the bot respond in 1h rather than the user having to send seconds

slate swan
slate swan
#

I can’t just use it in a command where I want the bot to respond after 1h or the time the user sent

#

i even need help for myself, sorry..

robust fulcrum
#

How to fix this error?

#

Pls help anyone 🥺

thorn grove
#

@slate swan i have trouble figuring out what to put it overwrites = { }

#

I tried ctx.guild.PermissionOverwrite(view_channel=False)

#

But it says guild has no I forgor PermissionOverwrite

robust fulcrum
paper sluice
robust fulcrum
thorn grove
#

Wait

#

I forgor discord.permission.overwrote

royal meteor
#

For an icon_url in the footer of an embed, what is the recommended image size?

paper sluice
# robust fulcrum 2.0 dpy

the order in which the decorator passed arguments is interaction then button
so your function signature should be

@..button(...)
async def ...(self, interaction, button):
robust fulcrum
paper sluice
#

you have button, interaction, swap them

robust fulcrum
#

Ok

crisp dagger
#

Then

sick thorn
#

Hello everyone. i actually want to build a bot.
the function of the bot would be -- there is website which posts daily quote at morning 8:30 AM. i want the bot to fetch that quote and the post it in the channel. how would i do it

paper sluice
thorn grove
#

Guys

#

There is an error in my code

paper sluice
#

you are trying to put a discord.PermissionOverwrite object inside a set

#

why?

thorn grove
paper sluice
#

can u send a link?

#

i think it just needs to be an iterable like list or tuple, set only accepts hashable types

thorn grove
#

!d discord.PermissionOverwrite

unkempt canyonBOT
#

class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.

Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.

The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.

x == y Checks if two overwrites are equal.

x != y Checks if two overwrites are not equal.

iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
thorn grove
#

@paper sluice

fresh ferry
paper sluice
thorn grove
slate swan
fresh ferry
thorn grove
#

It says overwrite parameter needs a dict

#

Here is what i want to do: when i create a channel, I want all users to not be able to see it

slate swan
thorn grove
#

At least i think so

slate swan
#

bro I need to go please faster

#

I have to work in something

thorn grove
sick thorn
slate swan
wraith wing
cold sonnet
#

does somebody have panda's idiotic calculator

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.

fresh ferry
sick thorn
#

ty

wraith wing
#

oh no ban pls

slate swan
#

<@&831776746206265384>

fresh ferry
#

no thanks daddy

#

<@&831776746206265384>

velvet compass
#

Handled, thanks yall

wraith wing
#

boom banned 😄

slate swan
#

No need to double tag

wraith wing
fresh ferry
slate swan
velvet compass
slate swan
#

poor joe AScry

robust fulcrum
regal pulsar
slate swan
regal pulsar
#

lmao

#

the account couldve been hacked though

slate swan
regal pulsar
slate swan
robust fulcrum
#

I want to do that inside the button

slate swan
slate swan
slate swan
#

then send self ASakashrug

slate swan
#

how about send yourself

slate swan
robust fulcrum
#

I confused

#

I have a C in my calculator command so i want when someone clicks it the calculator gets reset

slate swan
#

02shrug depends on your code on how you want and set it up

robust fulcrum
#

Hmmm?

swift pumice
swift pumice
thorn grove
#

Line 24

slate swan
#

wasnt replying to you but 'kay

thorn grove
slate swan
thorn grove
robust fulcrum
#

Hmmmm

thorn grove
robust fulcrum
slate swan
#

nice

robust fulcrum
#

I did a kid mistake

slate swan
#

aren't you a kid too

swift pumice
#

when i started with python i started with discord bots

slate swan
#

totally more than three-fourth of the persons in this channel

robust fulcrum
#

How can I make that the author of the message can only use the button?

slate swan
#
class MyView(ui.View):
  def __init__(self, valid: typing.Union[discord.User, discord.Member]) -> None:
    self.valid_user = valid

  async def interaction_check(self, inter: discord.Interaction) -> bool:
    return inter.author == valid

@bot.command()
#whatever
await ctx.send("...", view=MyView(ctx.author))
robust fulcrum
#

@slate swan

slate swan
thorn grove
slate swan
thorn grove
#

Still error

#

@slate swan

slate swan
#

Hi

slate swan
thorn grove
slate swan
slate swan
slate swan
thorn grove
slate swan
#

Reality

#

Going here

#

Tmrw math exam easy

paper sluice
slate swan
#

Hey ryuga ^_^

paper sluice
#

hi

thorn grove
slate swan
#

Otherwise u also add 👋

slate swan
#

just read the docs pepe_exit

thorn grove
#

Line 23

paper sluice
paper sluice
#

you just did overwrite = discord....its supposed to be a dict

thorn grove
#

Okay

thorn grove
paper sluice
robust fulcrum
thorn grove
#

Oh

#

Wait

#

Yep

#

How?

slate swan
#

"whenever a button is clicked", didnt refer to a specific button

thorn grove
#

It still dont work lol ಥ╭╮ಥ

#

New code:

#

Same error

vocal snow
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
thorn grove
#

It expects a dict

vocal snow
#

Then why aren't you passing a dict 🤨

thorn grove
thorn grove
#

Whats a dict

vocal snow
#

!dictionary

#

Yeah you should just google this

#

It's a basic data structure

eternal fox
#

i mean

slate swan
eternal fox
eternal fox
slate swan
vocal snow
#

You really can't code properly on a phone

#

And it's more of a text editor than an IDE

slate swan
#

I cant even type properly on phone pepe_exit imagine writing code

vocal snow
#

I can't imagine staring at a small screen for hours, it must be really bad for your eyes

#

Although I use light mode so maybe i shouldn't speak

paper sluice
slate swan
#

how to delete 5 messages in the “channel” sent by the “bot”

slate swan
#

Mhm

#
def check(msg: discord.Message):
  return msg.author.id == client.user.id
await ctx.channel.purge(check=check, limit=...)
silver reef
#

anyone knows how to track specific command?

vocal snow
slate swan
vocal snow
#

Yes!!

slate swan
#

I hate lambda for no reason

vocal snow
#

You want to log whenever a certain command is used or something like that?

robust fulcrum
#

Finally me done with button calculator

silver reef
#

its something like if command 1 is True the other commands can run

vocal snow
#

You could use bot.wait_for... or you might need to implement a command handler suited to your case

novel prairie
#

i want to remove the "help" command that is already build in my bot and i dont know how so i used this py bot.remove_command('help') but it didnt work also i put this code at the top of my code how can i fix this

vocal snow
vocal snow
silver reef
#

ye that what iam searching for

#

can u send me a link of that?

novel prairie
#

i want to remove the command in the picture

vocal snow
novel prairie
#

in the top of my code in the main.py file?

vocal snow
#

commands.Bot(help_command=None)

thorn grove
thorn grove
#

Or array

#

But how would i turn it to an dict?

#

@vocal snow

vocal snow
#

turn what to a dict?

thorn grove
#

The overwrites

vocal snow
#

you don't turn the overwrites to a dict, you use them in a dict

#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
vocal snow
#

there are examples here, please check

thorn grove
#

Okay

novel prairie
#

um

#

can someone help me?

#

with the code

vocal snow
#

are you getting an error?

paper sluice
novel prairie
thorn grove
vocal snow
#

I would recommend learning about dicts first

vocal snow
novel prairie
thorn grove
#

@paper sluice

vocal snow
thorn grove
#

So lemme guess

#

My code was wrong 🤦

novel prairie
vocal snow
#

if that's where you're doing bot = commands.Bot(...) sure

novel prairie
#

oke

paper sluice
novel prairie
vocal snow
#

no man 🤦

#

I would recommend learning some python basics

novel prairie
#

sorry im new to dev

vocal snow
#

!resources check these out

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.

novel prairie
#
Traceback (most recent call last):
  File "main.py", line 1, in <module>
    commands.Bot(help_command=None)
NameError: name 'commands' is not defined```
silver reef
#

@vocal snow can u send me a link of how to use the command handler thing?

vocal snow
#

I meant that you'd have to implement your own command handler for a compicated usecase

glad cradle
vocal snow
#

!d discord.Client.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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
novel prairie
glad cradle
#

😐

novel prairie
#

i already have that

#

lmao

novel prairie
glad cradle
eternal fox
novel prairie
novel prairie
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.

glad cradle
novel prairie
#

yea but now i have this error py File "main.py", line 18, in <module> bot = commands.bot(help_command=None) TypeError: 'module' object is not callable

eternal fox
novel prairie
#

ok wait a min

glad cradle
#

it's commands.Bot(...) not commands.bot(...)

vocal snow
eternal fox
#

ye

#

Yee,python is very case sensitive

novel prairie
#

i dont want to sent my full code here sorry

#
File "main.py", line 17, in <module>
    bot = commands.Bot(help_command=None)
TypeError: __init__() missing 1 required positional argument: 'command_prefix'```
#
bot = commands.Bot(command_prefix="!", intents=intents,case_insensitive = True)```
eternal fox
unkempt canyonBOT
#

examples/basic_bot.py line 16

bot = commands.Bot(command_prefix='?', description=description, intents=intents)```
novel prairie
#
import discord
from discord.ext import commands
from discord.ext.commands import bot
import asyncio
import datetime as dt
client = discord.Client()
import youtube_dl
import pafy
import datetime
import humanfriendly
import os
import praw
import random
intents= discord.Intents.default()
intents.members = True
reddit = praw.Reddit(client_id = "", client_secret = "", username = "", password = "", user_agent = "pythonpraw", check_for_async = False)
bot = commands.Bot(help_command=None)
bot = commands.Bot(command_prefix="!", intents=intents,case_insensitive = True)
eternal fox
#

wha-

novel prairie
eternal fox
#

flabbergasted rn

novel prairie
#

what

#

sorry lmao like i said im new

novel prairie
paper sluice
#
from discord.ext.commands import bot
bot = commands.Bot(help_command=None)
bot = commands.Bot(command_prefix="!", intents=intents,case_insensitive = True)

💀 please learn basics of python before making a discord bot, its fairly advanced

eternal fox
#

ok so remove

bot = commands.Bot(help_command=None)
```py
then edit 
```py
bot = commands.Bot(command_prefix="!",intents=intents,case_insensitive = True)

into this:


bot = commands.Bot(command_prefix="!",intents=intents,case_insensitive = True,help_command = None)
#

dont mind the py

paper sluice
#

you shouldn't spoon feed

glad cradle
#

thx for the secrets

eternal fox
#

😀

novel prairie
#

NOOOOO

royal meteor
#

How to fix "The application did not respond" error

glad cradle
royal meteor
#

Not in terminal

glad cradle
eternal fox
#

okk soo uhh i have a question,is there any other language you can use to make discord bots other than node.js and python

paper sluice
#

you can make it in any language

eternal fox
#

okioki thx thx

fresh ferry
#

bot hosting site says i dont have proper perms for bot to operate to full capacity, yet on my discord dev portal iv given it admin controls and pretty much every perm their is ? im scratching my head in mass confusion

slate swan
#

Is anyone having problems with slash commands?

#

I'm trying to make a slash command but it just doesn't assume it exists

#

but the funny part is that it takes over 3 others that I had created before

hushed galleon
royal meteor
#

What is the cause of "The application did not respond" and how do I fix it???

cloud dawn
cloud dawn
royal meteor
cloud dawn
#

This is the case with slash command or any components like button, modals etc.

slate swan
#

I have these two codes. The bot is just assuming that the 1st command exists and is not assuming that the 2nd command exists, when the two are exactly the same.

#

and I don't have any kind of error, that's the problem

cloud dawn
cloud dawn
cloud dawn
fresh ferry
cloud dawn
# slate swan wdym?

pong, channel_message, deferred_channel_message, deferred_message_update, message_update, autocomplete_result, modal, these are all the responses.

#

You could also get a not responded if the code couldn't reach the response, aka an error.

slate swan
#

I'm not able to create other slash commands in any folder I put. It's not just that

cloud dawn
# slate swan wdym?

Well like you said they should work, so it's likely a register/sync error.

royal meteor
dapper geyser
#

can some one help me my giveaway bot is half working but he cant count down and cause of that no one is the winer 💀

royal meteor
cloud dawn
#

unless you use py-cord i think.

#

Not sure but I thought they still used ctx for everything.

cloud dawn
fresh ferry
#

iv given all my bots every permission that im capable of giving thats including admin, iv spent 2 days trying to fix this.... any help would be thankful ❤️

dapper geyser
cloud dawn
dapper geyser
#

tbh i am really new and just making the bot fore my friends bday so i dont know a lot about coding

novel prairie
royal meteor
vocal snow
fresh ferry
novel prairie
vocal snow
fresh ferry
vocal snow
#

Also; you can't ban the server owner

fresh ferry
cloud dawn
vocal snow
#

Oh wait you're removing roles not banning someone i misread

#

Although the reasons should be the same

fresh ferry
dapper geyser
#

can some one help me my giveaway bot is not working idk why ```
from re import A
import discord
from discord.ext import commands
import datetime
import asyncio
import random
import time
#give away bot

TOKEN = "token"

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

@bot.command()
@commands.has_role("Owner")
async def giveaway(ctx, minute : int, prize: str):
await ctx.message.delete()
embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)

end = datetime.datetime.now() + datetime.timedelta(seconds = minute*60)

embed.add_field(name = "ends at:", value = f"{end}")
embed.set_footer(text = f"end {minute} minutes from now!")

my_msg = await ctx.send(embed = embed)

await my_msg.add_reaction("🎉")

await asyncio.sleep(minute)

new_msg = await ctx.channel.fetch_message(my_msg.id)

users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(bot.user))


winner = random.choice(users)

await ctx.send("congratulations! {winner.mention} you won {prize}!")

bot.run("token")```

fresh ferry
dapper geyser
#

bot dont whana count down so he just like starts the giveaway but dont goes down to 0 and no one wins

robust fulcrum
#

How can I make my bot send message when i click button?

vocal snow
#
assert guild.me.top_role > role
``` can you add this before you call remove_roles and make sure it doesn't raise AssertionError?
#

(for @fresh ferry )

cloud dawn
dapper geyser
#

i have a bot that delte racist comment if u want it

gusty shard
#
@bot.event
async def on_message(message):
    await bot.process_commands(message)
    if len(message.content) > 2:
        id = str(message.author.id)
        await asyncio.sleep(delay=random.randint(1,6))
        data[id]['level'] += random.randint(1,5)
        with open("values.json", "w") as f:
            json.dump(data,f,indent=4)```

can somebody help me? i cant find where is the problem
fresh ferry
#

im making source of my bot public once it works properly so im not too fussed sharing source

vocal snow
#

Don't worry about that, just add the line right above where you see bot.remove_roles

robust fulcrum
cloud dawn
#

20-30 usd for a public sophisticated bot seems like a scam already, those aren't easy to create.

dapper geyser
#

hi

slate swan
#

@cloud dawn I understood the error

cloud dawn
slate swan
robust fulcrum
#

I made a button calculator

cloud dawn
cloud dawn
robust fulcrum
#

I want to send a message on button click

#

I know about editing but forgot about sending

cloud dawn
robust fulcrum
#

Oh

robust fulcrum
cloud dawn
#

await interaction.response.send_message("Hey!") full code

#

Missed an n

vocal snow
# fresh ferry

Yep, right above that line add assert member.guild.me.top_role > role

robust fulcrum
cloud dawn
# fresh ferry

I really don't like this code, it's not really efficient.

cloud dawn
vocal snow
#

Yeah it's pretty poorly written

cloud dawn
#

Uses a for loop on remove role but it also take lists py_guido 🤏

#

Api calls: 🚶

fresh ferry
fresh ferry
cloud dawn
# fresh ferry

Aka if you were to put this bot public I'd suspect ratelimits, now I'm also wondering if it has autosharding or not.

fresh ferry
#

JavaScript*

cloud dawn
#

JS is also much harder to learn/ jump into.

fresh ferry
cloud dawn
vocal snow
#

But then again it might be best to just scratch this code

cloud dawn
vocal snow
#

That is true

fresh ferry
#

yeah ima just yeet it all three sources... do you guys know anyone i can pay properly to rebuild my ideas... cause i need them asap for my server for moderation reasons :/

cloud dawn
#

I don't like people being scammed ducky_drawing

fresh ferry
fresh ferry
cloud dawn
#

(Not true but I like coding ok lol)

royal meteor
#
embed = discord.Embed(...)

embed.add_field(name = "foo", value = "Value", inline = True)

if #some condition:
    #change the embed field value to "Value2"

How can I do this?

fresh ferry
#

but shall i direct message you ??

cloud dawn
cloud dawn
royal meteor
cloud dawn
#

Or have a ternary

#

More complex

#
embed = discord.Embed(...)
embed.add_field(name="foo", value="Value" if ??? else "value2", inline=True)
#

@royal meteor If value is either None you could also use the or operator.

dapper geyser
#

panda can u pls help me at somthing

#

code too big fore discord ...

cloud dawn
#

"Works for me"? Did you copy it?

dapper geyser
#

yes

cloud dawn
#

I recommend starting off easier then.

dapper geyser
#

just found it and thougth why not just take it also in my bot but dont works fore me somhow

vale wing
#

🙃

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

dapper geyser
#

i fixed it no error lemme try it if it works

vale wing
#

Why the hell do you have so many useless imports (and even duplicated ones)

#

Like I highly doubt you'd ever need setuptools for a discord bot

dapper geyser
#

i will make it later but it works so i dont really minde

vale wing
#

Just run import optimization in your ide (depends which one you use)

#

And evaluating math expressions with eval() isn't a good idea unless the possible values in a string are strictly limited

#

You'd better use some math parser

vale wing
#

!pypi strmath for example

unkempt canyonBOT
#

A module for evaluating math expressions without eval()

dapper geyser
#

ye u right

#

but ot works so thanks bro 😄

royal meteor
#

How to fix this?

paper sluice
vale wing
#

await inter.response.defer() in most of libs afaik

royal meteor
#

Ok thanks

royal meteor
vale wing
#

Before ofc

#

It basically sends "bot is thinking" message and when bot sends actual message, it removes "thinking" message

royal meteor
vale wing
#

Then check for errors in console as @paper sluice said

sick birch
#

It may not necessarily be an error, something is taking more than 3 seconds. You should check to see what’s causing that. It’ll usually be something external, like an API or a database

royal meteor
royal meteor
sick birch
#

Yeah read/write to JSON files may potentially be taking more than 3 seconds

royal meteor
sick birch
grim oar
#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
grim oar
#

oldest_first=True

royal meteor
sick birch
#

Right

grim oar
#

No lol

royal meteor
# sick birch Right

I tried that but now the application is stuck on Bot is thinking ... and not giving any response

sick birch
#

You may just have some errors then

royal meteor
slate swan
#

message = bot.get_channel(1000852468743282788).get_partial_message(1002254511336857672)
await message.edit(embed=stats)

Why bot edit delete message e

#

And how can i fix

winter gull
#

i am trying to send a message in a specific channel and i used this

#
lb_channel = bot.get_channel(config["lb-channel-id"])
#

it is giving me None when i try to do

lb_channel.send(<some message>)
slate swan
#

is the channel Id correct

#

@winter gull

#

you should also probably await until the bots cache is ready

winter gull
#

alright i try awaiting

slate swan
#

send your whole code

winter gull
#

TypeError: object NoneType can't be used in 'await' expression

slate swan
#

Send the code you used.

#

@winter gull Can I see the code for that command

winter gull
#

its a task

slate swan
#

that's why

winter gull
#

not a command

#

should i make it a global variable?

slate swan
#

before you assign lb_channel add await client.wait_until_ready()

winter gull
#

ow alright

slate swan
#

you're probably getting the NoneType error because the channel isn't in the bot's cache yet, thus adding the await will wait until it is

winter gull
#

alrr tysm

slate swan
#

Did it work?

winter gull
#

it workss

slate swan
#

Nice 😄

winter gull
#

yessss

slate swan
cursive spindle
#

how i can make a error handler only for on_cooldown

slate swan
cursive spindle
#

how i can return the CommandOnCooldown time to datetime?
You are on cooldown. Try again in 7199.07

slate swan
#

you just used the default cooldown thing ?

#

commands stop working on my bot, is there a new update?

#

i got no error on the bot

cursive spindle
slate swan
# cursive spindle yes
from datetime import datetime
datetime.fromtimestamp(SECONDSVAR).strftime("%A, %B %d, %Y %I:%M:%S")

I assume secondsvar is the seconds until cooldown is over

cursive spindle
slate swan
#

you could also convert it to hours, minutes, seconds

datetime.timedelta(seconds=secondsvariable)
#

that arent any tutorials or videos that practise good practices, wont find any

#

just try some code out and ask for help here if you run into issues

#

you'll probably want to use a database though

#

Like mongodb

#

mongodb ew

#

Or any other database...

#

yes.

#

I like your asuna pfp

#

and I like you

#

I actually use json databases way to much

#

:pepeShy:

slate swan
slate swan
slate swan
#

I find it harder to use json-based databases for no reason lmao

slate swan
#

dictionaries suck, try relational DBs

#

or Google sheets bored

slate swan
#

nah that's worse than json

#

@slate swan have you seen all of sao?

whole sparrow
#

whats the dsicord.py website that helps alot like its smt like vklotr.dev

#

idk

slate swan
#

@whole sparrow

whole sparrow
#

?

whole sparrow
#

Oo I didnt ask for embed builders I meant that there was this website that showed how to make a discord.py bot really well but I completely forgot the URL

whole sparrow
whole sparrow
#

nope

#

oooof sadge ill try to find it

#

i had it bookmarked idk wher eit went

vale wing
grizzled badger
#

could anyone help me (pretty new to discord bots) make a bot respond to multiple messages abt the same thing

#

for example a higher or lower game where the user inputs higher or lower mulitple times

silver reef
#

the bot works fine but it keeps sending me a TimeoutError whenever the timeout hits 2.0 so i tried the code below to prevent that from happening but its not working any solution?

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="f")
#________________________
@bot.listen()
async def on_ready():
    print("readyyyyyyyyyyyyyyy")

@bot.listen()
async def on_message(message):
    if message.content.startswith('$greet'):
        channel = message.channel
        await channel.send('Say hello!')

        def check(m):
            return m.content == 'hello' and m.channel == channel
        try:
          msg = await bot.wait_for(
        'message', check=check, timeout =2.0)
        except TimeoutError:
          print("there was an error") #this line  is just testing                                           not the actual code
        await channel.send(f'Hello {msg.author}!')

bot.run(my_secret)

sick birch
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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
silver reef
sick birch
silver reef
#

ye when i dont reply in 2 secs i want sth to happen

#

like the bot says "timeout " or sth

sick birch
#

So put that within the except block

silver reef
#

but it keeps giving me error in the console

sick birch
#

What's the error in console?

silver reef
sick birch
#

Full traceback please

silk fulcrum
#

he uses wrong Timeout

#

its asyncio.TimeoutError

#

not just TimeoutError

grizzled badger
silver reef
# sick birch Full traceback please
Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/runner/ddgtrhyrehr/venv/lib/python3.10/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 23, in on_message
    msg = await bot.wait_for('message', check=check, timeout = 2.0)
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError


sick birch
silk fulcrum
silver reef
#

ok ill try that

grizzled badger
#

i have no idea how to use anything else

sick birch
#

Good time to learn then

grizzled badger
#

yep

#

youtube here i come

sick birch
silk fulcrum
#

youtube here is trash

sick birch
silk fulcrum
#

even just read the docs is better

snow trench
#

guys how i can stop my bot from running

silk fulcrum
#

i know it's hard but try

sick birch
#

Close the application that's running it

snow trench
#

i just clicked the run button on vscode

snow trench
sick birch
#

Open the terminal, and you should be able to CTRL+C to terminate it

silk fulcrum
silver reef
# silk fulcrum <@702994033613471885> in except

now its giving me another error :

Ignoring exception in on_message
Traceback (most recent call last):
  File "main.py", line 23, in on_message
    msg = await bot.wait_for('message', check=check, timeout = 2.0)
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/ddgtrhyrehr/venv/lib/python3.10/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 24, in on_message
    except asyncio.TimeoutError:
NameError: name 'asyncio' is not defined

sick birch
#

import asyncio

silver reef
#

oh ok xd

grizzled badger
#

update my bot can say hello

slate swan
#

Why i cant repear process in 10 sec on on_rady event
Im tried with
But its dont work
time.sleep(10)

silk fulcrum
slate swan
#

And its didnt repeat event

silk fulcrum
#

of course it does not

#

it just does action when it starts up

#

and also there are a lot of syntax mistakes in this code

#

if it is the original one

slate swan
#

why does the embed continues?

slate swan
#

But i have problem with os

#

When u try to
gg = os.system("tps")
await ctx.send({gg})
Its dont work its send 256 but running process is 0

slate swan
slate swan
#

its the normal code i used always but here

#

@client.command()
async def help(ctx):
    embed = discord.Embed(title='simple degenerate bot', color=0x2c2f33)
    embed.set_footer(text = f"Requested by {ctx.author.name}")
    embed.add_field(name='Server', value='**`serverinfo`, `members`, `banner`, `icon`, `setbanner`, `seticon`**', inline=False)
    embed.add_field(name='General', value='**`botinfo`, `userinfo`, `ping`, `ubanner`, `avatar`,**', inline=False)
    embed.add_field(name='Moderation', value='**`ban`, `kick`, `unban`, `massunban`,`purge`, `nuke`**', inline=False)
    await ctx.channel.send(embed=embed)
#

did they update it sorry im slow

silk fulcrum
#

i dont see 32ms..... here

slate swan
#

me either

#

true here wait

#
@client.command()
async def ping(ctx):
    embed = discord.Embed(color=0x2c2f33, description=f'**`{int(client.latency * 1000)}ms....`**')
    embed.set_footer(text = f"Requested by {ctx.author.name}")
    await ctx.send(embed=embed)```
#

what do you mean by 'embed continues'

#

look at the screenshot

silk fulcrum
#

like it's too long?

slate swan
#

yeah

silk fulcrum
#

empty space

slate swan
#

Looks like that's just default?

silk fulcrum
#

but i guess that's just the thing about an embed

#

if it does like that

slate swan
#

other bots dont do that

silk fulcrum
#

waht

slate swan
#

like the embed is so huge i dont get it

#

perhaps you need inline?

silk fulcrum
slate swan
#

as u see there

#

it stops mine continues

slate swan
silk fulcrum
#

but still embed

slate swan
#

?

#

because they embed differently

silk fulcrum
#

bruh, python bot makes all embeds this same length

#

but in every case it looks natural at least

slate swan
#

I know what you mean, I'm pretty sure they embed differently on discord

#

<meta content="embed title" property=og:description>
Usually add embeds like that, in the html though

grizzled badger
#

how do i use the info (message content etc) from a wait_for() function?

slate swan
# slate swan

idk acc whats happening but all the embeds satrted looking longer

slate swan
silk fulcrum
#

that's a check

#

and if you want a message that was sent, after that wait_for

#

that is message = await bot.wait_for(...)

#

and u use message as usual

slate swan
#
@client.command()
async def test(ctx) -> None:
    embed = discord.Embed()
    embed.add_field(name="Test Name", value="Test Value")
    await ctx.send(embed=embed)

idk if add fields are smaller than other embeds, you could try it though

winter gull
#

Is there anything I could do to make a leaderboards like structure in embeds?

grizzled badger
silver reef
silk fulcrum
slate swan
#

you have to add the value and name to the field obviously

#

*edited..

silk fulcrum
#

and then some error like title in Embed definition is required occu.. ok ok ill stop now

slate swan
#

No it wouldn't

silk fulcrum
slate swan
#

Unfortunate

silk fulcrum
#

🗿

indigo pilot
cold sonnet
#

I have a question

#

why do people screenshot something to upload on a website and copy paste the url here instead of screenshotting something and directly copy pasting here

slate swan
#
from discord.ext import commands

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

welcome_channel = ""

@bot.event

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

async def on_member_join(member):
    if welcome_channel != "":
        await bot.send_message(welcome_channel, "Welcome to the server, {}!".format(member.mention))
        print("Welcome message sent to {}".format(welcome_channel))


@bot.command()

async def SetWelcome(ctx):
    await ctx.reply('Set welcome channel to ' + ctx.message.channel.name)
    welcome_channel = ctx.message.channel.id```
#

Events dont do anything

indigo pilot
#

It automaticly uploads it to the website

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.

indigo pilot
#

All i need to do is do control shift 4
take the ss
and it copys the url to my clipboard

glad cradle
slate swan
#

and fix syntax

#

Syntax?

#

wait nvm

#

it was bugged on my screen

#

Oh yeah, it might look wierd, I'm used to c++

#

haven't done python in years

#

nah you're good

#
from discord.ext import commands

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

welcome_channel = ""

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

@bot.event
async def on_member_join(member):
    if welcome_channel != "":
        await bot.send_message(welcome_channel, "Welcome to the server, {}!".format(member.mention))
        print("Welcome message sent to {}".format(welcome_channel))


@bot.command()
async def SetWelcome(ctx):
    await ctx.reply('Set welcome channel to ' + ctx.message.channel.name + "!\n")
    welcome_channel = ctx.message.channel.id```
#

@slate swan could you tell me what's the problem with the thing?

#

I was guessing it's that welcome_channel needs a name instead of an Id but that would be dumb

tough lance
#

Nani

#

There are many things wrong with that code

slate swan
#

That's not helpful, tell me what's wrong with it.

#

@tough lance

slate swan
#

What version are you using

surreal walrus
#

anyone how do I fix this for my bot

slate swan
#

idfk, last time i used it was in 2019

#

or 20

#

i think i'm using discord 1.0? idk

#

Update it first.. there are already many breaking changes in api itself

grizzled badger
#

anyone know how to wait for a message and use the content instead of getting the id, channel, author etc

slate swan
#

I was using discord 1

surreal walrus
slate swan
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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
uncut jacinth
#

Hey guys, how do i add description to my arguments in slash commands

slate swan
#

bruv wtf is this shit

#

import discord

bot = discord.Bot()

@bot.slash_command()
async def hello(ctx, name: str = None):
name = name or ctx.author.name
await ctx.respond(f"Hello {name}!")

@bot.user_command(name="Say Hello")
async def hi(ctx, user):
await ctx.respond(f"{ctx.author.mention} says hello to {user.name}!")

bot.run("token")

uncut jacinth
grizzled badger
surreal walrus
slate swan
#

This shit is terrible, who invented discord 2.0

#

You printed its class representation not the actual message

grizzled badger
slate swan
slate swan
#

it was a joke, either way discord py 2.0 is weird

#

Well discord itself is much weird so cant expect any better

#

Nah

grizzled badger
slate swan
#

Js is not that wierd

#

nvm

#

Yall gotta help me with this shit:

tough lance
#

I suggest you read the docs before trying anything

slate swan
slate swan
#

the example of the docs

tough lance
#

Where?

#

Send the link

slate swan
slate swan
# surreal walrus no :{

!e When you try to access a key from a dictionary and if it does not exist, you get a KeyError ```py
my_dict = {'foo': 1}
print(my_dict['bar'])

To suppress it, either use a try-except or use the `.get` method ```py
try:
    print(my_dict['bar'])
except KeyError:
    pass
# or
print(my_dict.get('bar'))
unkempt canyonBOT
#

@slate swan :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | KeyError: 'bar'
slate swan
tough lance
slate swan
tough lance
#

Yea not the official one

slate swan
#

fucking hell

#

which one's the real

tough lance
#

Discord 2.0 isn't even on pypi

slate swan
tough lance
#

You need to install manually from GitHub

slate swan
slate swan
#

It's not stable yet. The PyPi one still offers 1.7.3 (latest stable version)

#

i found it

tough lance
surreal walrus
slate swan
#

Create a command named dc with test as one of it's subcommand

#

I can't be fucked to deal with this utterly dumb shit lmfao

#

im just gonna use js

#

Or use cobol shipit

warped mirage
#

Guys can someone help me code a set prefix command, multi guild, using txt

sick birch
#

What issues are you having? Could you provide any code/tracebacks?

warped mirage
#
@client.command()
@commands.has_permissions(administrator = True)
async def set_prefix(ctx):
    prefix = "!"
    file = "prefix.txt"
    if prefix == "!":
        await ctx.send("Prefix set to !")
    else:
        await file.read("prefix") 
       ``` i started but idk how to do it
sick birch
#

Override the get_prefix command of your bot subclass, and return the appropriate prefix for that guild

#

Keep in mind this is called every message so you'll want to implement some sort of caching

winter gull
#

Hello!!
I want to send a message in a specific channel which i am able to do with the get_channel attribute. And also edit the message which is also i am able to do with get_message method, i want something like when the bot runs it checks If the channel exists, if not it throws an error apart from that, when the message is sent i want to edit the message repetitive while getting the new data. I want opinions on this, one thing would be to use on_ready() command and do the same idrk what to do

sick birch
winter gull
#

There is? I used it recently

sick birch
#

Could I see it?

winter gull
#

Like, bot.get_message(<Id>)

sick birch
#

Yeah that's not a thing

#

Well it was before v1.0 but I doubt anyone uses that anymore as it's incredibly outdated

winter gull
#

It is ig renamed to fetch_message

sick birch
#

Not just renamed, the functionality is completely different

#

It makes an API request, instead of just getting from the cache

#

And I don't believe you need to fetch_message just to edit a message

winter gull
#

Oh

sick birch
#

You can use the message returned from the send()

#
msg = await bot.get_channel(...).send(...)
await msg.edit(...)
winter gull
#

Ahh

#

Can I like use this as an argument for another function too?

sick birch
#

Use the returned message from send()?

winter gull
#

Oh yes hmm

#

I'll think abt it, tysmm

#

Also uhh i was reading the docs and came across creat_guild() so i had a doubt, does it like create a guild? If so will the bot be the owner?

sick birch
#

Right:

async def edit_message(message: discord.Message, content: str) -> None:
  await message.edit(content=content)

@bot.command()
async def my_command(ctx: commands.Context) -> None:
  message = await ctx.send("This message is about to be edited")
  await asyncio.sleep(5) # wait 5 seconds
  await edit_message(message, "This message has now been edited!")
winter gull
#

Ow

#

Tyyyy!!

whole sparrow
odd mango
#

is there any lib that converts strings like "12d 2h 4m" to a datetime object?

#

i am trying to make a timed mute command

cold tide
#

What does this mean??

odd mango
cold tide
#

Okay ty

slate swan
#

its better off helping here and having multiple minds giving there own opinions and answers to the problem

#

and it gives the users more options on how to fix there problem

slate swan
#

wut

#

Im rec tutorial on yt for prefixes

#

I dont know is eanble to send video because its ad

#

ah you mean a tutorial link, well its not really an ad if youre helping the person and yt ads are kinda bad and old ngl

cold tide
#

Can anyone please give me a example on how to make a command that gives you a certain role??

slate swan
#

like adds a role?

cold tide
#

Yes.

slate swan
#

to the author or?

#

Guys how can I make api call someon help I beg

smoky cedar
#

You'd just call a method that makes a call?

slate swan
smoky cedar