#discord-bots

1 messages Β· Page 999 of 1

slate swan
#

unfunny

brisk dune
#

Haha

rare saddle
#

Please tell me how to make such timestamps

slate swan
#

!d discord.utils.format_dt

unkempt canyonBOT
#

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

This allows for a locale-independent way of presenting data using Discord specific Markdown...
rare saddle
rancid vine
#

Hi I am new to programming bots (very new) and I have a problem.

#
@client.event
async def on_message(message):
    print("Message")
    username = str(message.author).split('#')[0]
    user_message = str(message.content)
    channel = str(message.channel.name)

    if message.author == client.user:
        print("Here")
        return

    if user_message.lower == "hey":
        await message.channel.send('hey')
        return
#

The message never sends although 'Message' prints.

boreal ravine
#

also, why are you casting message.content when it's already a string

rancid vine
#

I'm pretty braindead lmao

#

I still get an error

#
  await user_message.channel.send('hey')```
Error: AttributeError: 'str' object has no attribute 'channel'
#

wait

#

yeah

slate swan
rancid vine
#

But isn't that what I get from doing user_message.channel though

#

wait

#

ah i get it

#

ok thankyou

placid skiff
#

Someone experienced with selenium? i need help with a thing

jade tartan
#

Hi question how do you make your bot send multiple hyperlinks in an embed

async def verify(ctx):
    embed = discord.Embed()
    embed.description = "Read about Selfie Verification [here](https://discord.com/channels/730651046459998218/967788019526561822).",
    embed.description = "Read about Selfie & Age Verification [here](https://discord.com/channels/730651046459998218/967788019526561822)."
    await ctx.send(embed=embed)```
paper sluice
#

??

placid skiff
paper sluice
#
    embed.description = """Read about Selfie Verification [here](https://discord.com/channels/730651046459998218/967788019526561822).
                         Read about Selfie & Age Verification [here](https://discord.com/channels/730651046459998218/967788019526561822)."""
cold sonnet
#

birthday system

paper sluice
#

oh u said imagine, i thought imaginary like complex lmao

slate swan
slate swan
cold sonnet
#

but that's not good

slate swan
boreal ravine
cold sonnet
#

does birthday bot speak hungarian tho

rancid vine
#

thats pretty epic

cold sonnet
#

can it defeat goku tho

paper sluice
#

brain has left the chat

rancid vine
#

lmao

slate swan
royal jasper
#

i want to get this string \u00a7aText here \u00a7cOther text here and remove 6 algarisms after \. it is possible?

rancid vine
#

How would I make a command that would take the parameter of something like !color (command here)

cold sonnet
#

slice the string

#

or hmm

rancid vine
#
@client.event
async def on_message(message):
    print("Message")
    username = str(message.author).split('#')[0]
    user_message = message.content

    if message.author == client.user:
        print("Here")
        return

    if user_message.lower() == "Hello":
        await message.channel.send(f'Hello {message.author}')
        return
    elif user_message.lower() == f'{prefix}weather':
        print("Weather wanted")``` Also is this impractical?
cold sonnet
#

well yes,
string = string[6:]

rancid vine
#

A bunch of elifs for each different command

rancid vine
#

How would I do it correctly

#

?

slate swan
cold sonnet
#

commands

little ivy
#

Why does it only add the second button?

cold sonnet
#

my internet is dying

rancid vine
cold sonnet
slate swan
brisk dune
unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

brisk dune
#

wat

rancid vine
#

THANKS

#

caps sorry lol

cold sonnet
#

cuz it's just a folder

#

it isn't in the docs

brisk dune
#

Ah, right

cold sonnet
#

but yeah that is it

brisk dune
#

!d discord.ext.commands.command

unkempt canyonBOT
#

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

By default the `help` attribute is received automatically from the
docstring of the function and is cleaned up with the use of
`inspect.cleandoc`. If the docstring is `bytes`, then it is decoded
into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") using utf-8 encoding...
brisk dune
#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the
decorator or functional interface.
rancid vine
#
intents = discord.Intents.default()``` What are intents
cold sonnet
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

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

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

daring olive
#

announcement hey everyone, please check out #965291445999239258 and share any feedback you might have about the threads we launched last week for this channel. thank you!

#

nope.

#

i'm on mobile lol, someone help me out

cold sonnet
#

nope

slate swan
cold sonnet
#

thanks

#

you know admin's here when reaction

brisk dune
#

Ah, I have to actually join the thread to be able to mention it

#

neat

slate swan
#

not really, the ID is all you need

brisk dune
slate swan
#

True :D

paper sluice
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

['Text here ', 'Other text here']
cold sonnet
#

where was the message for cooperation on the python bot

cold sonnet
#

??

paper sluice
#

what cooperation?

cold sonnet
#

you can cooperate

#

contribute

paper sluice
#

ik the meaning

#

i just dont know what ur talking about

#

maybe i missed something Β―_(ツ)_/Β―

cold sonnet
#

there was something like this for sure

cold sonnet
#

I do not think this is it

daring olive
#

!contribute

unkempt canyonBOT
#

Contribute to Python Discord's Open Source Projects
Looking to contribute to Open Source Projects for the first time? Want to add a feature or fix a bug on the bots on this server? We have on-going projects that people can contribute to, even if you've never contributed to open source before!

Projects to Contribute to
β€’ Sir Lancebot - our fun, beginner-friendly bot
β€’ Python - our utility & moderation bot
β€’ Site - resources, guides, and more

Where to start

  1. Read our contribution guide
  2. Chat with us in #dev-contrib if you're ready to jump in or have any questions
  3. Open an issue or ask to be assigned to an issue to work on
daring olive
#

?

cold sonnet
#

this is indeed it

jade jolt
#

uh cannot import name 'RequestsWebhookAdapter' from 'discord'?

#

anyone know how to fix that

cold sonnet
#

is there anything you have to follow like PEP8

#

pep8 probably

jade jolt
#

i got it from the docs so. idk

boreal ravine
boreal ravine
#

I got removed

jade jolt
#

so how do i use webhooks then

boreal ravine
jade jolt
#

yeah

boreal ravine
# jade jolt yeah

Then you could do..

webhooks = await channel.webhooks()
await webhooks[0].send(...)
# since webhooks is a list just get the first webhook
# channel must be pre-defined
jade jolt
#

ah tyvm

slate swan
#

what are you gonna do with discord.py if you have nextcord and what are you gonna do with nextcord if you have discord.py

#

nakime, i told u back then that different libs can cause conflict

#

:")

#

...

paper sluice
#

i dont understand why u have the same imports like 3 times

slate swan
#

i also told u to learn python before going for discord bots :")

#

so whatever, first, decide which lib u want to use

#

:") at the very least ^

paper sluice
slate swan
#

^

#

bruh

#

ok

#

then why you've nextcord imported in your file? :")

#

....

cold sonnet
#

and you have multiple imports twice

#

too

#

discord too

paper sluice
#

deleting stuff wont work, u have too many modules that do the same thing overwritting each other, u need to uninstall one of them

#

stick to one lib

slate swan
#

yo

paper sluice
#

hi

slate swan
#

hi

cold sonnet
#

delete everything that has nextcord

slate swan
slate swan
paper sluice
#

sure

cold sonnet
#

and everything that's darker blue cuz you don't use it

slate swan
# paper sluice sure
for reaction in msg.reactions:
            if reaction.emoji == "\U0001f389":
                for users in reaction.users():
cold sonnet
#

like json or content from sympy

paper sluice
slate swan
paper sluice
slate swan
#

uh i was making

#

wait

#

just show the code.. lmao

cold sonnet
#

put all imports to the start

#

should aswell be

#

yes

slate swan
# cold sonnet should aswell be

in your about section.. why r u importing discord. when it's not even being used there ||ik this is not really relevant lmao|| :>

#

just left click on vsc and press sort imports

cold sonnet
#

hehe good point

slate swan
#

:>

paper sluice
slate swan
#

LMAO

slate swan
#

😳

paper sluice
slate swan
#

or just follow the normal order

standard libs
third party libs
files
narrow grail
#

Guys I make a role command but when I call it, i get error: Missing permissions. How to fix it?

slate swan
#

i didn't know there is a order like this.. but thanks, i'll try to remmeber lmao

#

your welcome

#

xD

cold sonnet
#

you're*

slate swan
#

LMAOO

#

fight me

cold sonnet
paper sluice
slate swan
#

f i hate lag in coding!!!!

paper sluice
narrow grail
#

Guys I make a role command but when I call it, i get error: Missing permissions. How to fix it?

slate swan
little ivy
#

TypeError: Messageable.send() got an unexpected keyword argument 'view2'

slate swan
#

the perm is: Manage roles @narrow grail

cold sonnet
little ivy
narrow grail
slate swan
#
        winners = []
        for reaction in msg.reactions:
            if reaction.emoji == "\U0001f389":
                for users in reaction.users():
                    if option == 1:
                     for i in await msg.guild.invites():
                          if i.inviter == users:
                              if i.uses < number:
                                  winners.append(users.id)
        a1 = random.choice(winners)  
``` idk
cold sonnet
#

bot cannot change your roles

#

if it's your server

narrow grail
slate swan
slate swan
slate swan
paper sluice
slate swan
#

discords documentation is a pain ngl

slate swan
#

no

slate swan
#

not dpys discords developer portal

slate swan
slate swan
slate swan
slate swan
# slate swan How so?

when connecting to the gateway to me the instructions werent straight forward and endpoint documentation is just something else

#

Not hard?

#

and hi krypton pithink

slate swan
#

Endpoint is the easiest, gateway can be complex for newcomers to websockets but it's not rocket science and pretty self explaining when you spend some time on it.

paper sluice
slate swan
#

..

boreal ravine
slate swan
#

There's a difference between making a library and understanding how the gateway works. Implementing a library is different than getting websockets and interpreting them.

slate swan
#

As we were talking about the documentation and not making a library, I don't even understand why you come with library development

#

this? (I know the for loop is a bad bad)

#

The other documentation is even easier - so yeah ..

slate swan
cold sonnet
slate swan
#

more what?

paper sluice
# slate swan ..
[users.id for reaction in msg.reactions if reaction.emoji == '\U0001f389' for users in reaction.users() if option == 1 for i in await msg.guild.invites() if i.inviter == users and i.uses < number]```
slate swan
#

uh

#

If the endpoint documentation is hard, then you need to understand how basic REST API work.

little ivy
#

How do i make the buttons be next to each other under the embed?

slate swan
slate swan
# cold sonnet ew

this is where all my private information is stored instead of an env πŸ˜”

slate swan
cold sonnet
#

don't make 2 views

boreal ravine
slate swan
#

you nest list comps lol

#

Don't make 2 views with 1 button

paper sluice
maiden fable
#

Oh hi there Krypton. Long time

slate swan
#

My hack_user function is almost 30 lines long :)

#

Hoi - not staying for a while

maiden fable
#

How you doing?

boreal ravine
cold sonnet
# little ivy

all you had to do here was delete the second view = View()

slate swan
maiden fable
#
pip uninstall discord.py
pip install discord.py
boreal ravine
slate swan
boreal ravine
slate swan
cold sonnet
slate swan
maiden fable
#

That fixes the issue

paper sluice
slate swan
paper sluice
#

(β•―Β°β–‘Β°οΌ‰β•―οΈ΅ ┻━┻

maiden fable
#

Also run pip uninstall discord @slate swan

slate swan
#

tbh i rly didnt test my own cmd

slate swan
paper sluice
#

two*

narrow grail
#

is it possible to create a role trough a bot?

cold sonnet
slate swan
unkempt canyonBOT
#

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

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

All fields are optional.

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

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

New in version 2.0: The `display_icon` keyword-only parameter was added...
maiden fable
#

@slate swan can help you better then. I never used the module

narrow grail
paper sluice
#

two instances of bot open πŸ‘€ πŸ‘€

cold sonnet
unkempt canyonBOT
#
I don't think so.

No documentation found for the requested symbol.

cold sonnet
#

oh wait

maiden fable
slate swan
#

he has experience with py-cord

paper sluice
cold sonnet
#

gr

slate swan
cold sonnet
#

!d discord.abc.Messageable.send

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

Sends a message to the destination with the content given.

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

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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

I swear I've never written py-cord in any terminal of my device

maiden fable
#

Uh

little ivy
cold sonnet
unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
scarlet pond
#

is discord.py better or should I start using pycord

paper sluice
narrow grail
# unkempt canyon

do you also know what I have to write at permissions if I want a admin role? @slate swan

slate swan
slate swan
slate swan
cold sonnet
#

damn it then

paper sluice
slate swan
paper sluice
#

why are you using reactions, just use good ol buttons

slate swan
scarlet pond
slate swan
#

its back

scarlet pond
#

ohhh

cold sonnet
scarlet pond
#

does anybody know how to do slash commands in dpy?

slate swan
#

buttons also need that logic

scarlet pond
#

this is my code:```py
import discord
import os

bot = discord.Bot()

@bot.event
async def on_ready():
print(f"We have logged in as {bot.user}")

@bot.slash_command()
async def hello(ctx):
await ctx.respond("Hello!")

bot.run(os.environ["token"])

slate swan
#

smh

cold sonnet
#

discord.ext.commands.Bot()

paper sluice
slate swan
cold sonnet
#

and you have to add slash commands to the tree, not the bot

little ivy
slate swan
maiden fable
paper sluice
#

yea they are same size :/

scarlet pond
slate swan
scarlet pond
#

sorry I haven't done dpy development in a while

cold sonnet
slate swan
#

also we know how much ppl reacted

#

we can in buttons to but

narrow grail
#

is there a list for permissions=...?

slate swan
#

reactions are coller

paper sluice
#

they are painful to work with πŸ€·β€β™‚οΈ

slate swan
#

np ill find a way

cold sonnet
#

and ADD THE BUTTONS BEFORE YOU SEND 😭

slate swan
#

wait wait wait wait no way

#

on yesterday he even dont know python

#

hmmmmmmmm

little ivy
slate swan
#

ye

slate swan
junior verge
#

@little ivy I swear you are just copying code

cold sonnet
junior verge
#

or following a tutorial and just fully copying it

little ivy
#

euh no?

slate swan
cold sonnet
#

please stop bullying

slate swan
little ivy
#

I'm not following a tutorial or copying code

#

just trying something new

cold sonnet
#

djs is indeed better than dpy

slate swan
#

@slate swan can u suggest me something about my giv cmd

slate swan
cold sonnet
#

only one thing matters to me

slate swan
# slate swan yeah?
        winners = []
        for reaction in msg.reactions:
            if reaction.emoji == "\U0001f389":
                for users in reaction.users():
                    if option == 1:
                     for i in await msg.guild.invites():
                          if i.inviter == users:
                              if i.uses < number:
                                  winners.append(users.id)
        a1 = random.choice(winners) 
cold sonnet
#

voice receiving

boreal ravine
#

I've never seen an actual use case for voice receiving

cold sonnet
#

I wanna be in a voice channel w my bot and tell it to turn my lights off, then my raspberry will turn my lights off

maiden fable
little ivy
cold sonnet
#

😳

maiden fable
boreal ravine
#

i like node

maiden fable
#

I hate Node's errors

spring flax
#

why doesn't this send the error? ```py
import disnake
from disnake.ext import commands

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

    @commands.Cog.listener()
    async def on_command_error(self, ctx, error):
        original_error = getattr(error, 'original', error)
        await ctx.send(original_error)

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

It just prints it terminal
cold sonnet
#

I love programming

slate swan
#

its in the init

maiden fable
#

Yea

spring flax
#

sigh

slate swan
#

ew js

#

c++😩

paper sluice
#

c++ is good

cold sonnet
#

are they so bad

slate swan
maiden fable
#

Move this debate civil argument to an OT channel before I use the command

maiden fable
cold sonnet
#

yes

paper sluice
#

uwu = negation operator in eito language

maiden fable
#

Since her IQ is more than ours

slate swan
#

definitely

cold sonnet
#

I'm a self-diagnosed genius

slate swan
#

ash did notπŸ’€

#

oop

cold sonnet
slate swan
cold sonnet
#

it WHAT

#

did they implement it themselves

slate swan
#

they dont use discord.py, they have their own private wrapper

maiden fable
maiden fable
#

The endpoint works, tho it's undocumented

paper sluice
#

😩

maiden fable
#

I just LOVE it how people get access to undocumented endpoints by using the dev console

cold sonnet
#

I want voice receiving πŸ˜”

maiden fable
#

You do know I saw that, right?

maiden fable
#

But EQ isn't free from college and classes to work on the wrapper

slate swan
cold sonnet
#

deep

maiden fable
#

Stop acting as if you dk what u wrote

slate swan
paper sluice
maiden fable
#

But mods don't forget πŸ‘€

cold sonnet
#

.topic

lament depotBOT
#
**What feature would you be the most interested in making?**

Suggest more topics here!

cold sonnet
#

BRO

paper sluice
slate swan
#

you need 2.0

maiden fable
# lament depot

Smth the big bots won't copy and distribute in their names

cold sonnet
#

I just said it like 4 times

slate swan
cold sonnet
#

views are 2.0

slate swan
maiden fable
#

pip install git+https://github.com/Rapptz/discord.py

slate swan
#

the big bots

cold sonnet
#

he wants pycord

slate swan
#

Hunter can u help

maiden fable
#

Sure

#

What's up?

slate swan
cold sonnet
#

dont pycord have views or smth like 2.0 already

slate swan
cold sonnet
#

pycord is bad overall but not the point

paper sluice
#

i was literally going to say that, just took time finding an emoji

slate swan
slate swan
narrow grail
#

how to define the permissions in permissions=...?

slate swan
# maiden fable Sure
        winners = []
        for reaction in msg.reactions:
            if reaction.emoji == "\U0001f389":
                for users in reaction.users():
                    if option == 1:
                     for i in await msg.guild.invites():
                          if i.inviter == users:
                              if i.uses < number:
                                  winners.append(users.id)
        a1 = random.choice(winners) β€Š
``` is there any better way
slate swan
maiden fable
#

But u r using DPY

cold sonnet
#

pycord uses dpy namespace

maiden fable
cold sonnet
#

now it should use pycord I GUESS

maiden fable
#

pip install py-cord

slate swan
#

make sure you pip install py-cord not ``pip install pycord`

slate swan
slate swan
#

so do you get any errors? 🀨

paper sluice
#

i used think i used discord.py 2.0 but then realized it was pycord 😢

maiden fable
# slate swan Yes but low

Uh, I better not write the code rn since I'm on mobile and writing such a big and cursed ternary and list comp on mobile....

slate swan
cold sonnet
#

what's your python interpreter

#

nakime

paper sluice
slate swan
paper sluice
slate swan
#

sheesh

cold sonnet
#

like the python version that's used when you run the code

slate swan
cold sonnet
#

the amount of 3rd party libraries there is frightenin

clever field
#

how add thumbnail YOUTUBE VIDEO to discord EMBED, with youtube-dl ?

paper sluice
#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

python 2

slate swan
#
discord-components==2.1.2
discord-ext-bot==1.0.1
discord-py-slash-command==3.0.3
discord-ui==5.1.6
jishaku==2.4.0
nextcord==2.0.0a10
nextcord-ext-menus==1.5.2
``` :scared:
cold sonnet
slate swan
#

Why pycord is everywhere :?

cloud dawn
slate swan
slate swan
#

..

slate swan
#

N num of number gen

#

Well ill do it myself nvmd

cold sonnet
#
with open("file.txt", "r", encoding="utf-8") as file: print(valami := (lista := list(filter(None, [line.split(" : ")[0] if len(line.split(" : ")) != 1 else None for line in file.readlines()]))).sort(key=len), "\n\n", "\n".join(list(filter(lambda x: (len(x) == len(lista[-1])), lista))))
```still my number 1
slate swan
#

O my

#

Fuk

cloud dawn
paper sluice
#

i have 200 libs installed 😢

cold sonnet
#

ikr

#

show yours

#

I wanna see y'alls one liners

cloud dawn
#

Mine is still my url regex

narrow grail
#

how to define the permissions in permissions=...?

cold sonnet
#

I had a file with names so this read every name and showed the longest names in there

#

there were also other stuff which had to be sorted out

slate swan
narrow grail
#

how to define the permissions in permissions=...?

boreal ravine
cloud dawn
cloud dawn
#

You can also use permission code.

cold sonnet
#

!e
print((lambda x:print(*x))(["H", "e", "l", "l", "o"])β€Š)

unkempt canyonBOT
#

@cold sonnet :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print((lambda x:print(*x))(["H", "e", "l", "l", "o"])β€Š)
003 |                                                          ^
004 | SyntaxError: invalid non-printable character U+200A
narrow grail
cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

Hello
cloud dawn
boreal ravine
#

nah

cold sonnet
#

!e print("Hello")

unkempt canyonBOT
#

@cold sonnet :white_check_mark: Your eval job has completed with return code 0.

Hello
boreal ravine
#

thats too short, you gotta make it bigger

cloud dawn
paper sluice
#

!e import hello

unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

Hello world!
slate swan
#

!e import antigravity

unkempt canyonBOT
#

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

[No output]
cold sonnet
#

what

paper sluice
slate swan
#

guys import antigravity

#

its a fun easter egg

slate swan
slate swan
boreal ravine
#

stdlib

slate swan
#

its an easter egg stdlib

#

!e import("antigravity").fly()

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | AttributeError: module 'antigravity' has no attribute 'fly'
paper sluice
#

!e

with open(getattr(__import__('this'),'__file__')) as file:
    print(file.read())
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

001 | The Zen of Python, by Tim Peters
002 | 
003 | Beautiful is better than ugly.
004 | Explicit is better than implicit.
005 | Simple is better than complex.
006 | Complex is better than complicated.
007 | Flat is better than nested.
008 | Sparse is better than dense.
009 | Readability counts.
010 | Special cases aren't special enough to break the rules.
011 | Although practicality beats purity.
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/tenagiguje.txt?noredirect

rare saddle
#

How to display such an avatar in thumbnail?

narrow grail
unkempt canyonBOT
#

property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/master/api.html#discord.Asset "discord.Asset") for the avatar the user has.

If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.display_avatar "discord.User.display_avatar").
cloud dawn
#

!resources

unkempt canyonBOT
#
Resources

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

cold sonnet
unkempt canyonBOT
#

property default_avatar```
Returns the default avatar for a given user. This is calculated by the user’s discriminator.
narrow grail
cloud dawn
#

😒

rare saddle
#

For some reason it doesn't work for me

cold sonnet
#

!d discord.Guild.create_role

unkempt canyonBOT
#

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

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

All fields are optional.

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

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

New in version 2.0: The `display_icon` keyword-only parameter was added...
#

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

property default_avatar```
Equivalent to [`User.default_avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.default_avatar "discord.User.default_avatar")
narrow grail
cloud dawn
#

!d disnake.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://docs.disnake.dev/en/latest/api.html#disnake.User.avatar "disnake.User.avatar")
paper sluice
slate swan
unkempt canyonBOT
#

property display_avatar```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
slate swan
cold sonnet
#

well panda said it

cloud dawn
#

Also pretty sure avatar returns an asset object.

paper sluice
ashen perch
#

hey im getting this really annoying bug where it will send every message twice even though there is no reason why this should be happening any idea how to fix?

cloud dawn
#

!d disnake.Asset

unkempt canyonBOT
#

class disnake.Asset```
Represents a CDN asset on Discord.

str(x) Returns the URL of the CDN asset.

len(x) Returns the length of the CDN asset’s URL.

x == y Checks if the asset is equal to another asset.

x != y Checks if the asset is not equal to another asset.

hash(x) Returns the hash of the asset.
cold sonnet
#

permissions=discord.Permissions(kick_members=True)

ashen perch
#

k

cold sonnet
#

right?

rare saddle
#

ohhhh, yea. Thanks you

obtuse abyss
#

guys, how i m supposed to load_extension in discord.py 2.0 now that its asyncronous?

slate swan
#

have you guys ever tried making a discord api wrapper because ws and gw are a pain

cloud dawn
unkempt canyonBOT
#
Huh? No.

No documentation found for the requested symbol.

slate swan
#

oop

#

..

#

websockets and gateway

#

well there's a setup_hook method in the Bot class

narrow grail
cloud dawn
#

!d discord.Client.setup_hook

unkempt canyonBOT
#

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

A coroutine to be called to setup the bot, by default this is blank.

To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.

This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.login "discord.Client.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") event.

Warning

Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.wait_for "discord.Client.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready")...
ashen perch
slate swan
#

theyre a pain

ashen perch
#

ty

slate swan
#

@ashen perch ur banner is working as a light for me with full brightness

cold sonnet
#

on_ready sucks

paper sluice
cold sonnet
#

NICE

boreal ravine
#

@slate swan make an interactions API wrapper for discord, theres not many out there and most of them aren't maintained

cloud dawn
boreal ravine
#

that's not what I meant

boreal ravine
#

I mean an API wrapper only for interactions so no gateway stuff involved, the bot is gonna respond/listen through HTTP requests

slate swan
#

but i need your guys style of implementations!

cloud dawn
#

Danny want's you to sync slash commands using a command_prefix Bot. Meaning you still need message intents, design flaw.

obtuse abyss
#

sorry for it

cold sonnet
cloud dawn
slate swan
#

ill check other slash command wrappers and ill make it better

obtuse abyss
slate swan
#

How to make drop-down menu?

cold sonnet
#

uh

slate swan
#

robins examples are bad

#

fight me robin

slate swan
#

@slate swan so, i can change into dropdown also?

cloud dawn
slate swan
#

I want to convert this script into dropdown@slate swan

#

My bot script

warm tulip
#

guys helpppppp

#

when i type this cmd and when i type the prefix it says that cmd name didnt found

  async def help(self, ctx:commands.Context):
     embed=discord.Embed(title="HELP MENU mod bot:",  description="** **", color=0x79ff00)
     embed.add_field(name="report", value="for reporting someone get ticket.\nUsage: go in ticket channel")```
obtuse abyss
slate swan
#

Like discord.ui.SelectMenu ?

cold sonnet
#

sorry

paper sluice
warm tulip
#

when i type this cmd and when i type the prefix it says that cmd name didnt found

 async def help(self, ctx:commands.Context):
    embed=discord.Embed(title="HELP MENU mod bot:",  description="** **", color=0x79ff00)
    embed.add_field(name="report", value="for reporting someone get ticket.\nUsage: go in ticket channel")```
paper sluice
cold sonnet
warm tulip
#

guyssssssss

#

when i type this cmd and when i type the prefix it says that cmd name didnt found









@commands.command(name="help")
 async def help(self, ctx:commands.Context):
    embed=discord.Embed(title="HELP MENU mod bot:",  description="** **", color=0x79ff00)
    embed.add_field(name="report", value="for reporting someone get ticket.\nUsage: go in ticket channel")```
cloud dawn
unkempt canyonBOT
#

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

A coroutine to be called to setup the bot, by default this is blank.

To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.

This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.login "discord.Client.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") event.

Warning

Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.wait_for "discord.Client.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready")...
little ivy
#

Is this possible with python?

boreal ravine
#

yes

cloud dawn
#

!d discord.ui.Modal

unkempt canyonBOT
#

class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.

This object must be inherited to create a modal popup window within discord.

New in version 2.0.

Examples...
little ivy
#

Thanksss

boreal ravine
#

anything is possible if you try hard enough

tired hinge
slate swan
#

Is there a way to run a bit of code when any commands is run and only go through with the command when a condition is met?

cloud dawn
unkempt canyonBOT
#

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

Responds to this interaction by sending a modal.
paper sluice
#

!d discord.ui.View.add_item

unkempt canyonBOT
#

add_item(item)```
Adds an item to the view.

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

add ur option to that

slate swan
#

Thx

warm tulip
#

when i type this cmd and when i type the prefix it says that cmd name didnt found help me

 async def help(self, ctx:commands.Context):
    embed=discord.Embed(title="HELP MENU mod bot:",  description="** **", color=0x79ff00)
    embed.add_field(name="report", value="for reporting someone get ticket.\nUsage: go in ticket channel")```
cloud dawn
unkempt canyonBOT
#

discord.ext.commands.on_command(ctx)```
An event that is called when a command is found and is about to be invoked.

This event is called regardless of whether the command itself succeeds via
error or completes.
warm tulip
#

ya

slate swan
# unkempt canyon

then how would i make it so the command doesnt run if a condition isnt met without manually adding an if statement to every single command

warm tulip
slate swan
cloud dawn
cloud dawn
#

on_message populair one.

slate swan
cloud dawn
warm tulip
#

look my bot prefix is d! and when i use this :

  async def help(self, ctx:commands.Context):
     embed=discord.Embed(title="HELP MENU mod bot:",  description="** **", color=0x79ff00)
     embed.add_field(name="report", value="for reporting someone get ticket.\nUsage: go in ticket channel")```
in consle it says <Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "help" is not found>
slate swan
#

Is there any best and free hosting website or app?

cloud dawn
slate swan
warm tulip
#

sad why nobody is helping me

cloud dawn
unkempt canyonBOT
#

await cog_before_invoke(ctx)```
A special method that acts as a cog local pre-invoke hook.

This is similar to [`Command.before_invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.before_invoke "discord.ext.commands.Command.before_invoke").

This **must** be a coroutine.
slate swan
cloud dawn
#

!d discord.ext.commands.Context.invoke

unkempt canyonBOT
#

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

Calls a command with the arguments given.

This is useful if you want to just call the callback that a
[`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally...
cloud dawn
slate swan
cloud dawn
# slate swan yep

So you want to block certain people from commands, on what condition if I may ask.

slate swan
#

uff

cloud dawn
# slate swan yep

!d discord.app_commands.check Could this work out, saves the hassle of before invoking etc since that is for pretty advanced stuff.

unkempt canyonBOT
#

@discord.app_commands.check(predicate)```
A decorator that adds a check to an application command.

These checks should be predicates that take in a single parameter taking a [`Interaction`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction "discord.Interaction"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure") exception is raised and sent to the appropriate error handlers.

These checks can be either a coroutine or not.

Examples

Creating a basic check to see if the command invoker is you...
random quail
#

i need helpive never coded anything

#

and i want to make discord bot

slate swan
#

... don't make one :")

obtuse abyss
# obtuse abyss but i use discord.ext commands, then my code is kinda different so i dont know h...
import discord
from discord.ext import commands
from discord.ui import Button, View

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

bot = commands.Bot(command_prefix='+', intents=intents, help_command=None)

@bot.event
async def on_ready():
    print(f'Conected as {bot.user}')
    await bot.change_presence(activity=discord.Game(name=f'+help |  🎡'))

does someone know where i need to put the load_extension?

random quail
#

i want to make one

slate swan
#

learn basics first

random quail
#

help

slate swan
#

don't go for discord bot at start @random quail

slate swan
#

bruhh

cloud dawn
unkempt canyonBOT
#

cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check")
for every command and subcommand in this cog.

This function **can** be a coroutine and must take a sole parameter,
`ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
random quail
#

i want help

slate swan
#

ok what help

slate swan
#

:")

cloud dawn
narrow grail
#

how to delete a role?

slate swan
random quail
#

making a bot for discord

cloud dawn
# slate swan Commands
def is_me():
    def predicate(interaction: discord.Interaction) -> bool:
        return interaction.user.id == 85309593344815104
    return app_commands.check(predicate)

@tree.command()
@is_me()
async def only_me(interaction: discord.Interaction):
    await interaction.response.send_message('Only you!')
random quail
#

thats what help

#

idk how to code

slate swan
random quail
#

also i want to go for bots direectly

slate swan
slate swan
random quail
slate swan
#

you cant code a dpy bot without knowledge of py itself

slate swan
random quail
#

H O W

random quail
#

im using replit

slate swan
cloud dawn
#

This should get you started, a strong will is required to jump in directly to bots tough.

random quail
#

what

slate swan
#

tell me

random quail
#

w h a t

slate swan
#

@random quail u can copy the discord bot codes available on github directly if u don't want to learn how to code :")

#

if u want to code, then don't go for discord bots directly

slate swan
random quail
cloud dawn
#

Could you guys please behave yourself? Instead of saying "learn python first" you could also advice him and ```
tell me how to send messages to the terminal eli
tell me

slate swan
slate swan
random quail
#

I DONTKNOW HOW TO FUCKING CODE

#

I KNOW HOW COPY AND PASTE THO

cloud dawn
#

So? If you don't want to help let it be.

slate swan
#

If anyone copy my code is there any option like copy right?

random quail
#

GITHUB TIME

paper sluice
#

can u stop?

slate swan
# random quail GITHUB TIME

In this video, we will create a Discord Bot with discord.py v1.7.3 in 2021. This is an updated version of the video where I showed how to do the same thing last year.

If you have any suggestions for future videos/doubts, leave it in the comments below. I might not be able to answer everyone but you can join my discord server for help: https://d...

β–Ά Play video
cloud dawn
slate swan
slate swan
# slate swan what

If anyone using my bot script is there any option on discord we report him/her or copy-right claim?

random quail
#

wheres code for chat bot

cloud dawn
slate swan
pliant gulch
#

If you have a copyright notice or a "no license" you can file a DMCA takedown when someone uses it without permissions

cloud dawn
#

You can have it open sourced with a GPL license if you want but you need to claim it yourself.

slate swan
#

Ok

cloud dawn
# slate swan Ok

The most basic copyright license is structured as such ```
Copyright (C) 2017-2018 {company name or your name} <{email}>

This file is part of the {project name} project.

The {project name} project can not be copied and/or distributed without the express
permission of {company name or your name} <{email}>.

pliant gulch
#

Generally if you don’t want someone using your work, you’d use a no license

pliant gulch
cloud dawn
cloud dawn
pliant gulch
#

Is that not a valid point?

cloud dawn
#

It's just that people will copy it anyways.

pliant gulch
#

Ok, and if you really care then go through via a DMCA takedown

cloud dawn
#

Okay sure but how would you prove it if they'd copy a part of the code.

pliant gulch
#

That’s situational

#

None the less if you are that paranoid don’t bother

#

If you don’t believe in the OSS cause you don’t need to partake in it

#

Brings in another point besides transparency, open sourced code regardless of license is a good inspiration material

#

As long as your within licenses, or only use it for inspirations

slate swan
#

this is some interesting convo.. nice

slate swan
cloud dawn
#

I'm talking hypothetically, matter of fact you mentioning inspiration is the fact I brought "copying parts" up. Would they also be liable if it is "too similar".

pliant gulch
#

That’s up for the courts to decide

pliant gulch
cloud dawn
#

Indeed, It's just that some concepts are copied anyways. Not talking about code but features of phones for example. Could someone patent that?

#

It's certainly inspiration.

slate swan
cloud dawn
#

How?

slate swan
#

idk how to explain

royal jasper
#

how can i bypass a character in a re.sub("[^0-9]", "", versions)?

pliant gulch
# cloud dawn How?

For an example, I have a program that prints "Hello World" but I have many different ways in code to actually achieve this

#

The feature is that it can print "Hello World"

royal jasper
dull terrace
slate swan
dull terrace
pure sparrow
slate swan
#

Glowstik Calculator vibes

slate swan
#

oh nvm

#

NVM

pure sparrow
cloud dawn
slate swan
#

you have to import the stuff with
from discord_components import *

west crane
#

how can i add invisible field

#

to an embed

pure sparrow
#

from discord_slash import ButtonStyle, SlashCommand

cloud dawn
slate swan
#

does the code work?

west crane
slate swan
cloud dawn
cloud dawn
slate swan
#

yes

cloud dawn
pure sparrow
#

yep and install the pip package wait I send it

slate swan
#

from discord_components import Button, ButtonStyle

#

thats not dpy2

slate swan
pure sparrow
#

pip install discord-py-slash-command

cloud dawn
#

!d discord.ButtonStyle

unkempt canyonBOT
#

class discord.ButtonStyle```
Represents the style of the button component.

New in version 2.0.
slate swan
pure sparrow
#

you are on linux ?

#

im on mac bro I don't know what you mean...

slate swan
#

ahem ahem

#

πŸ’€

pure sparrow
#

how to use pycord ?

cloud dawn
#

Syntax of the code above is invalid.

slate swan
#

i just burped so fucking loud

slate swan
slate swan
slate swan
cloud dawn
unkempt canyonBOT
#

exception discord.app_commands.CheckFailure```
An exception raised when check predicates in a command have failed.

This inherits from [`AppCommandError`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.AppCommandError "discord.app_commands.AppCommandError").

New in version 2.0.
#

discord.ext.commands.on_command_error(ctx, error)```
An error handler that is called when an error is raised
inside a command either through user input error, check
failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
slate swan
#

discord slashes are ew

slate swan
slate swan
cloud dawn
#

You can't import top level packages.

slate swan
cloud dawn
#

Use relative imports.

slate swan
slate swan
cloud dawn
cloud dawn
rare saddle
#

Why doesn't the banner of a person show up? If what he has

dull terrace
slate swan
cloud dawn
unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

slate swan
#

still awaiting on that example πŸ‘€

cloud dawn
#

!d discord.app_commands.AppCommandError

unkempt canyonBOT
#

exception discord.app_commands.AppCommandError```
The base exception type for all application command related errors.

This inherits from [`discord.DiscordException`](https://discordpy.readthedocs.io/en/master/api.html#discord.DiscordException "discord.DiscordException").

This exception and exceptions inherited from it are handled in a special way as they are caught and passed into various error handlers in this order...
rare saddle
cloud dawn
dull terrace
slate swan
cloud dawn
unkempt canyonBOT
#

property banner```
Returns the user’s banner asset, if available.

New in version 2.0.

Note

This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.fetch_user "discord.Client.fetch_user").
cloud dawn
#

I recommend reading the docs, it's an optional Asset.

rare saddle
cloud dawn
slate swan
dull terrace
#

Someone motivate me to code today, up to 3.5k lines of code and spacing out froggy_chill

cloud dawn
#

Please search relative imports, if you still need help please provide your project structure and what you are trying to do.

cloud dawn
#

What did you make?

dull terrace
#

I'm definitely being fairly efficient compared to my first bot

#

It's a game with images and tons of stuff

cloud dawn
dull terrace
#

Using pillow

cloud dawn
dull terrace
#

I didn't even know there was an async version of pillow

cloud dawn
cloud dawn
dull terrace
#

How would it be an issue?

slate swan
cloud dawn
dull terrace
#

The image generation takes 100ths of a second if remember right, the saving of the image to disk is the slowest

cloud dawn
#

So error will be the exception object containing what was the issue.

#

ctx will be the command that has gotten an error.

slate swan
cloud dawn
slate swan
cloud dawn
#
@bot.listen()
async def on_command_error(ctx, error):
    # Per usual, getting the original error
    error = getattr(error, 'original', error)

    if isinstance(error, CheckFailure):
        await ctx.send("Not enough permissions to run this command.")
unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
#

getattr(object, name[, default])```
Return the value of the named attribute of *object*. *name* must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, `getattr(x, 'foobar')` is equivalent to `x.foobar`. If the named attribute does not exist, *default* is returned if provided, otherwise [`AttributeError`](https://docs.python.org/3/library/exceptions.html#AttributeError "AttributeError") is raised.

Note

Since [private name mangling](https://docs.python.org/3/reference/expressions.html#private-name-mangling) happens at compilation time, one must manually mangle a private attribute’s (attributes with two leading underscores) name in order to retrieve it with [`getattr()`](https://docs.python.org/3/library/functions.html#getattr "getattr").
slate swan
#

time to rewrite all my commands PepeHands

slate swan
# cloud dawn Why?

Ive handled errors and shit that i can handle there in each and every command one by one

cloud dawn
slate swan
#

atleast my commands wont look like a sloppy peice of shit anymore

#

triggers my ocd when ive rushed a command :(

#

do what pandabear said

slate swan
#

what he said

pure sparrow
#

if I don't do it I can't import the package

tough lance
#

I don't really understand if you didn't understand the question or being sarcastic

slate swan
#

I also want to add gif on my bot

#

How to add this?

cloud dawn
slate swan
slate swan
slate swan
tough lance
#

Not u

dull terrace
#

i'm also adding reaction gifs on my bot i think

#

thinking the best way is to make a subreddit and upload a ton there with specific titles then use the reddit api to load all the links and titles in

slate swan
#

Api

dull terrace
#

saves bandwidth of uploading every single time

slate swan
tough lance
slate swan
#

i honeslty dont know

tough lance
slate swan
#

The error is from pycord i think

#
embed.add_field(name=f":flashgun:| **add now:flashgun: **", embed.set_image(url="gif_url")
#

@slate swan correct?

slate swan
tough lance
slate swan
#

use the command i sent you in cmd

#
embed.add_field(name=f":flashgun:| **add now:flashgun: **",value="https://cdn.discordapp.com/attachments/960814524187938816/967838916814209084/standard.gif")
dull terrace
slate swan
#

Ohh

#

the image will appear at the bottom of the embed above the footer and such

#

or gif at this example

#

Ok thx sir

cloud dawn
severe rampart
#

could i get an example button made with disnake? i forgot how they work

slate swan
#
embed.add_field(name=f":gc_number_6: | **Invite:flashgun: **",value="desc")
embed.set_image("https://cdn.discordapp.com/attachments/960814524187938816/967838916814209084/standard.gif")
#

Correct?

severe rampart
#
embed.set_image(url = "https://cdn.discordapp.com/attachments/960814524187938816/967838916814209084/standard.gif")
slate swan
#

Ok

junior verge
#

quick question

slate swan
#

@severe rampart

junior verge
final iron
#

Roles of what

junior verge
#

the server

final iron
#

!d discord.Guild.roles

unkempt canyonBOT
#

property roles```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.
junior verge
#
@client.command()
async def roles(ctx):
    await ctx.send(discord.Guild.roles)
#

Like that?

severe rampart
#

indentation error right

slate swan
final iron
#

No

junior verge
#

How then

slate swan
severe rampart
junior verge
#

I just want it to return a quick list of the roles nothing special

final iron
#

!d discord.ext.commands.Context.guild is your guild object

unkempt canyonBOT
slate swan
#

no

final iron
#

Yes

slate swan
#

it returns a guild object

final iron
#

Same thing

slate swan
#

no

final iron
#

Potato potato

slate swan
#

🀨

final iron
#

The end result is the same thing

slate swan
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
junior verge
#
@client.command(pass_context=True)
async def delrole(ctx, role: discord.Role):
    await client.delete_role(role)
    await ctx.send("The role {} has been deleted!".format(role.name))
``` Why doesn't this work
final iron
#

Because it's old ass code that you didn't write

slate swan
#

copied?

final iron
#

client.delete_role() 🀣

slate swan
junior verge
#

yeah I just wanted a quick code lmao

#

I cba to write something

#

just need something quick to work xd

final iron
#

If you knew basic oop it would take 2 seconds to write

#

It's just 3 lines

final iron
#

1st line is your command decorator

#

2nd line is function constructor

slate swan
final iron
#

Bro be quiet

slate swan
#

function signature*

#

learn py

final iron
#

3rd line is function body

junior verge
#

so whats the client.delete role thing

final iron
#

It's outdated

#

And irrelevant

junior verge
#

No am I asking

#

What it is now

final iron
#

What are you trying to do

slate swan
junior verge
#

Just delete a role like .delrole @role