#discord-bots
1 messages Β· Page 999 of 1
Haha
Please tell me how to make such timestamps
!d discord.utils.format_dt
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...
thanks you
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.
lower(), it's a method so call it
also, why are you casting message.content when it's already a string
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
user_message is a string, as you can see, you're even typecasting it
you need a TextChannel object to send messages which you can get from the channel property of the Message object, i.e. message
But isn't that what I get from doing user_message.channel though
wait
ah i get it
ok thankyou
Someone experienced with selenium? i need help with a thing
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)```
??
oh sorry wrong channel
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)."""
birthday system
oh u said imagine, i thought imaginary like complex lmao
user_message contains message.content which makes it, message.content.channel and as message.content already returns a string and channel isnt a method of the string class, it wont work
uh, you do know that birthday bot exists
but that's not good
no
why have it in one bot when you can have it in multiple
does birthday bot speak hungarian tho
thats pretty epic
can it defeat goku tho
brain has left the chat
lmao
agreed
strains to relate
i want to get this string \u00a7aText here \u00a7cOther text here and remove 6 algarisms after \. it is possible?
How would I make a command that would take the parameter of something like !color (command here)
@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?
well yes,
string = string[6:]
A bunch of elifs for each different command
yes
make commands
commands
my internet is dying
How
don't reassign view
because , you only need one
@rancid vine
!d discord.ext.commands
No documentation found for the requested symbol.
wat
Ah, right
but yeah that is it
!d discord.ext.commands.command
@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...
!d discord.ext.commands.Command
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.
intents = discord.Intents.default()``` What are intents
!intents
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.
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!
#discord-bots-meta
nope.
i'm on mobile lol, someone help me out
nope
not really, the ID is all you need
But to be able to actually see it in my list of mentionable channels/threads
True :D
!e
import re
uni = re.compile(r'\\u.{5}([^\\u]*)')
print(uni.findall(r'\u00a7aText here \u00a7cOther text here'))
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
['Text here ', 'Other text here']
ty
where was the message for cooperation on the python bot
??
what cooperation?
ik the meaning
i just dont know what ur talking about
maybe i missed something Β―_(γ)_/Β―
there was something like this for sure
I do not think this is it
!contribute
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
- Read our contribution guide
- Chat with us in #dev-contrib if you're ready to jump in or have any questions
- Open an issue or ask to be assigned to an issue to work on
?
this is indeed it
uh cannot import name 'RequestsWebhookAdapter' from 'discord'?
anyone know how to fix that
i got it from the docs so. idk
You're either
- using an old version of discord.py that doesn't have that class
- using a newer version of discord.py that removed that class
im on 2.0
soo..
I got removed
so how do i use webhooks then
Does the channel have a webhook already?
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
ah tyvm
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
:")
...
i dont understand why u have the same imports like 3 times
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 ^
even discord.py has slash now ig
discord.py has slash commands
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
my answer is still same even if u get help from other ppl @slate swan :")
getting help for stuffs like these but not learning python properly.. isn't a good for long run :")
yo
hi
hi
delete everything that has nextcord
:>
can u help me with liste compre
sure
and everything that's darker blue cuz you don't use it
for reaction in msg.reactions:
if reaction.emoji == "\U0001f389":
for users in reaction.users():
like json or content from sympy
this is not complete
would be more helpful for list comprehension if u show what you're doing next after that

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
hehe good point
:>
right*
LMAO

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

i didn't know there is a order like this.. but thanks, i'll try to remmeber lmao
your welcome
xD
you're*

:>
f i hate lag in coding!!!!
lag? brainlag?
Guys I make a role command but when I call it, i get error: Missing permissions. How to fix it?
lovely
bot doesn't have perms or u don't have perm
the perm is: Manage roles @narrow grail
give the bot permissions
the bot cannot change anything on the owner
How do i make the embed sent with the 2 buttons?
it's my server and he is admin
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
I already tried it on a other server but it didn't work too, which not was my server
@paper sluice
lag in ide
@slate swan
u shure u want that in one line?
discords documentation is a pain ngl
no is it right?
not dpys discords developer portal
oh lol
pain
;-;
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 
am i doing right??
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.
ya ig, hold on
..
you can always ask in the DAPI/DD server for help 
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.
i just read it until i figure it out like a puzzle
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 ..
im making a lib so thats really why i said the statementπ
ew
more what?
[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]```
uh
If the endpoint documentation is hard, then you need to understand how basic REST API work.
How do i make the buttons be next to each other under the embed?
thats not how you run 2 for loops in a list comp?
this is where all my private information is stored instead of an env π
Add 2 buttons to your view
don't make 2 views
Attach them to one view
wdym?
Oh hi there Krypton. Long time
How you doing?
make it two lines
all you had to do here was delete the second view = View()
no?
pip uninstall discord.py
pip install discord.py
yes?
no?
yes?
okay three lines, but the last line has 25 lines content
well I for sure wouldn't look into that
am i doing right appending the users
That fixes the issue
did u try out what i sent
not yet
(β―Β°β‘Β°οΌβ―οΈ΅ β»ββ»
Also run pip uninstall discord @slate swan
tbh i rly didnt test my own cmd
you wont ever, it has my bot token π spotify creds π imgflip creds π movieDB creds π some other functions that I dont want others to see
is it possible to create a role trough a bot?
no more view2
!d discord.Guild.create_role
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...
@slate swan can help you better then. I never used the module
thx
two instances of bot open π π
!d discord.Message.views
No documentation found for the requested symbol.
oh wait
bru i have more options
Ask Eito, not me
U have used py-cord
he has experience with py-cord
the code u sent only supported option 1 π€·ββοΈ
gr
no?
!d discord.abc.Messageable.send
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**.
I swear I've never written py-cord in any terminal of my device
Uh
I only have 1
it has views I swear
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.
is discord.py better or should I start using pycord
i mean two views
do you also know what I have to write at permissions if I want a admin role? @slate swan
pycords src is garbage so start with dpy
ye thats why should i use my code?
pycord trash, either use discord.py/hikari or some good fork
damn it then
wait what r u trying to do?
giveaway check
why are you using reactions, just use good ol buttons
dpy
you gotta pass in an overwrite for the role at the same time
I thought dpy isn't being maintained anymore?
its back
ohhh
- create view
- add items
- send
does anybody know how to do slash commands in dpy?
uh..
buttons also need that logic
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"])
smh
discord.ext.commands.Bot()
not really, u can label them and add callbacks its pretty simple
nah,buttons can have their own callback, you may use a persistent view
and you have to add slash commands to the tree, not the bot
TypeError: View.add_item() takes 2 positional arguments but 3 were given
that's pycord, not discord.py
tbh reactions look cool
Won't work
yea they are same size :/
oh this is really confusing rn
ye
sorry I haven't done dpy development in a while
view.add_item(button)
view.add_item(button2)
is there a list for permissions=...?
reactions are coller
they are painful to work with π€·ββοΈ
np ill find a way
and ADD THE BUTTONS BEFORE YOU SEND π
me?
ye
like a week ago
@little ivy I swear you are just copying code
how original
or following a tutorial and just fully copying it
euh no?
discord.js, blushes
oh sry
@slate swan can u suggest me something about my giv cmd
thankfully somebody agrees
only one thing matters to me
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)
voice receiving
I've never seen an actual use case for voice receiving
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
Making a personal assistant π
Yess, this works. Thank you very much. The only usefull person here.
π³
I just love it how u say that to anyone who helps u successfully
i like node
I hate Node's errors
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
its not in the class
I love programming
its in the init
Yea
sigh
c++ is good
are they so bad
I was serious....
Move this debate civil argument to an OT channel before I use the command
Her saying uwu means really bad for others, soooo
yes
uwu = negation operator in eito language
Since her IQ is more than ours
I'm a self-diagnosed genius
djs moment
bruh mee6 uses python
they dont use discord.py, they have their own private wrapper
Yea
That's mad
The endpoint works, tho it's undocumented
π©
I just LOVE it how people get access to undocumented endpoints by using the dev console
I want voice receiving π
You do know I saw that, right?
Same
But EQ isn't free from college and classes to work on the wrapper
your eyes are yours, mine are mine, I cannot see whats behind yours
deep
Stop acting as if you dk what u wrote
I forgot

But mods don't forget π
.topic
Suggest more topics here!
BRO
feature to delete this embed
Smth the big bots won't copy and distribute in their names
I just said it like 4 times
Idc
views are 2.0
π
uh u didnt replied to me?
pip install git+https://github.com/Rapptz/discord.py
the big bots
he wants pycord
Hunter can u help
no?
dont pycord have views or smth like 2.0 already
py-cord is bad with Views iirc
pycord is bad overall but not the point
i was literally going to say that, just took time finding an emoji
sheesh
pycord uses discord.py views except for modals
how to define the permissions in permissions=...?
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
dunno
But u r using DPY
pycord uses dpy namespace
Uh, do u know about ternary statements and list comp?
pip install py-cord
make sure you pip install py-cord not ``pip install pycord`
Yes but low
i used think i used discord.py 2.0 but then realized it was pycord πΆ
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....
π
π€‘ i feel pity for you
uh ok
anyone ?
i already gave u the list comp ..
But i have option 2
change the 1 to 2
sheesh
like the python version that's used when you run the code
uh
the amount of 3rd party libraries there is frightenin
how add thumbnail YOUTUBE VIDEO to discord EMBED, with youtube-dl ?
!ytdl
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)
python 2
Ok ill try tmrw
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:

Why pycord is everywhere :?
my nightmare
a1 = random.choice([user.id for reaction in msg.reactions for users in reaction.users() for i in await msg.guild.invites() if reaction.emoji == "\U0001f389" and option == 1 and i.inviter == users and i.uses < number]) β
because its a garbage overrated fork
my nightmare
make it a one linerπΌ
uh and i want n number of numbers
N num of number gen
Well ill do it myself nvmd
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
? I took the code of whatever was there.
i have 200 libs installed πΆ
not bad 
what does this do?
Mine is still my url regex
how to define the permissions in permissions=...?
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
i got only disnake flask aiohttp
how to define the permissions in permissions=...?
(lambda x:print(*x))(["H", "e", "l", "l", "o"])
permission object takes kwargs discord.Permissions(speak=True)
You can also use permission code.
!e
print((lambda x:print(*x))(["H", "e", "l", "l", "o"])β)
@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
Mobile code
can you send example for what I need to write for kick members because permissions=kick_members doesn't work
!e print("".join(["H", "e", "l", "l", "o"]))
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
Hello

nah
!e print("Hello")
@cold sonnet :white_check_mark: Your eval job has completed with return code 0.
Hello
tru
kick_members=True
Well the same as my example but with 
!e import hello
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
Hello world!
!e import antigravity
@slate swan :warning: Your eval job has completed with return code 0.
[No output]
what
sad
isnt it an external lib though?
no
stdlib
@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'
!e
with open(getattr(__import__('this'),'__file__')) as file:
print(file.read())
@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
How to display such an avatar in thumbnail?
I'm really confused. permissions=kick_members=True wouldn't work?
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").
discord.py version?
I really recommend catching up on some Python syntax.
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
show the part of code you wanna do this in
property default_avatar```
Returns the default avatar for a given user. This is calculated by the userβs discriminator.
await guild.create_role(name='test', permissions=...)
π’
For some reason it doesn't work for me
!d discord.Guild.create_role
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")
I already read it but how to put the permissions in?
!d disnake.Member.avatar
property avatar```
Equivalent to [`User.avatar`](https://docs.disnake.dev/en/latest/api.html#disnake.User.avatar "disnake.User.avatar")
avatar = member.avatar or member.display_avatar
!d discord.Member.display_avatar :)
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.
it returns None if the avatar is a discord default
well panda said it
Also pretty sure avatar returns an asset object.
:>
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?
!d disnake.Asset
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.
try resetting your bot's token
permissions=discord.Permissions(kick_members=True)
k
Have you checked task mng?
right?
ohhhh, yea. Thanks you
guys, how i m supposed to load_extension in discord.py 2.0 now that its asyncronous?
have you guys ever tried making a discord api wrapper because ws and gw are a pain
Yep you can also use this calculator to input permission codes https://discordapi.com/permissions.html#8589934596
!d discocrd.Client.setup_hook
No documentation found for the requested symbol.
ooooh thx
!d discord.Client.setup_hook
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")...
currently on a macbook cuz away from home so idk on mac how to access that without screwing up laptop
theyre a pain
yes
ty
I did it in a command
@ashen perch ur banner is working as a light for me with full brightness
on_ready sucks
q=lambda a:a and[l:=[],g:=[],p:=a.pop(len(a)//2),[[l,g][i>p].append(i)for i in a]]*0+q(l)+[p]+q(g)
one liner quick sort
NICE
lol
@slate swan make an interactions API wrapper for discord, theres not many out there and most of them aren't maintained
True, Discord.py's current implementation is a good concept but lacks structure.
that's not what I meant
im down
I mean an API wrapper only for interactions so no gateway stuff involved, the bot is gonna respond/listen through HTTP requests
but i need your guys style of implementations!
Danny want's you to sync slash commands using a command_prefix Bot. Meaning you still need message intents, design flaw.
but i use discord.ext commands, then my code is kinda different so i dont know how to make it here
sorry for it
None
Because they are hard to make an hard to maintain.
ill check other slash command wrappers and ill make it better
where do i need to put this function?
Saw this one on #esoteric-python
How to make drop-down menu?
uh
Now I cant focus on my game
@slate swan so, i can change into dropdown also?
Kind of have to agree.

I want to convert this script into dropdown@slate swan
My bot script
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")```
can u show me the code?
Like discord.ui.SelectMenu ?
please WHAT THE FUCK IS THAT
welcome :)
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")```
enjoy
language
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")```
!d discord.Client.setup_hook 
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")...
yes
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...
Thanksss
anything is possible if you try hard enough
i think it's fine as long as it's not directed towards anyone but okay π
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?
!d discord.InteractionResponse.send_modal you need this
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.
!d discord.ui.View.add_item
add_item(item)```
Adds an item to the view.
This function returns the class instance to allow for fluent-style chaining.
Thx
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")```
!d discord.discord.ext.commands.on_command
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.
Have you loaded the cog?
ya
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
def __init__(self, bot: commands.Bot):
self.bot = bot
self.last_msg = None```
Use the event inside the cog.
Hm?
Could you provide a bit more info, also please don't repeat questions.
Yes
on_command is the same but when a command is about to run.
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>
I know π
Is there any best and free hosting website or app?

What is the question then?
On_command it wonβt run the command if a condition is met
sad why nobody is helping me
!d discord.ext.commands.Cog.cog_before_invoke
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.
could you give an example of how to use this?
!d discord.ext.commands.Context.invoke
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...
I'd need to know specifically what you want to do, so you want to run a certain command if x == True else ??
yep
your issue?
So you want to block certain people from commands, on what condition if I may ask.
uff
Yeah
!d discord.app_commands.check Could this work out, saves the hassle of before invoking etc since that is for pretty advanced stuff.
@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...
... don't make one :")
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?
i want to make one
learn basics first
example please
help
don't go for discord bot at start @random quail
no
bruhh
!d discord.ext.commands.Cog.cog_check you can also have whole cogs to have the check.
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").
i want help
ok what help
Could i have an example π
:")
On? Single commands or cogs?
how to delete a role?
Commands
making a bot for discord
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!')
do u know python basics? or u want to go for bots, directly?
idk what python basics are
also i want to go for bots direectly
do you also wanna go for a train wreck directly
learn python first
how
you cant code a dpy bot without knowledge of py itself
youtube
H O W
im using replit
basically spoonfeed
and your basically using a noose around your bots neck
This should get you started, a strong will is required to jump in directly to bots tough.
what
w h a t
@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
you arent making any sense
how do you print a message in python
then idk
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
what π
ik
he doesn't know how to print messages
So? If you don't want to help let it be.
ok sorry :(
If anyone copy my code is there any option like copy right?
GITHUB TIME
can u stop?
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...
That's a start, it's good to copy paste, I recommend copying some code and play around with it. An example of a basic bot-> https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py
LMAOOO
If anyone using my bot script is there any option on discord we report him/her or copy-right claim?
wheres code for chat bot
Well just have a GitHub closed sourced repo.
Sourced report?
If you have a copyright notice or a "no license" you can file a DMCA takedown when someone uses it without permissions
You can have it open sourced with a GPL license if you want but you need to claim it yourself.
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}>.
Generally if you donβt want someone using your work, youβd use a no license
On GitHub or discord?
Not permissive in the slightest
Hmm
I don't see the point of having an open sourced copyrighted code.
Transparency
Besides that.
Is that not a valid point?
It is don't get me wrong.
It's just that people will copy it anyways.
Ok, and if you really care then go through via a DMCA takedown
Okay sure but how would you prove it if they'd copy a part of the code.
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
this is some interesting convo.. nice
add little "easter eggs", they used this to catch alot of theifs
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".
Thatβs up for the courts to decide
Note βwithin licensesβ
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.
features and code are two different things
How?
how can i bypass a character in a re.sub("[^0-9]", "", versions)?
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"
You can't.
ok
The presentation of information is not patentable
I thought features are the behaviour of the application and code is the root to it π

swastik is so helpful when you try to make a discord bot
Glowstik Calculator vibes
swastika*
oh nvm
NVM
π
That's a good way of explaining it yeah.
you have to import the stuff with
from discord_components import *
from discord_slash import ButtonStyle, SlashCommand
does the code work?
what how i don't see
π π
That's the joke
yes
** **
Copy paste that
yep and install the pip package wait I send it
who uses discord_components anymore
pip install discord-py-slash-command
!d discord.ButtonStyle
class discord.ButtonStyle```
Represents the style of the button component.
New in version 2.0.
GLOWSTIK
how to use pycord ?
Syntax of the code above is invalid.
i just burped so fucking loud
congrats
May I ask, why?
and how to do something if the condition is not met?
!d discord.app_commands.CheckFailure
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")).
discord slashes are ew
Hey, i'm not magic, an example would be great
if the condition isnt met, it simply raises a CheckFailure, which you can handle in the error handler
not what i meant π
You can't import top level packages.
wait, message commands and slash commands have the same error events for dpy2? like disnake has seperate error events
Use relative imports.
hm alrighty
If a person knew what this meant, they would've fixed it themselves.
Well you don't get errors with slash commands in d.py you need to code the response. afaik
I mean if you google relative imports you get tons of examples and tutorials and definitions.
hell
Why doesn't the banner of a person show up? If what he has
Member.banner is none
first of all the member doesnt have a banner, second of all you are setting the Asset object of the banner
!d CommandTree.on_error
No documentation found for the requested symbol.
still awaiting on that example π
!d discord.app_commands.AppCommandError
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...
And how to just display the picture (banner) then?
It does have it but it's not really clear it does lol

you gotta first get the banner, check it isnt None and then set it using, member.banner.url (dpy 2)
!d discord.User.banner
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").
Thanks you
I recommend reading the docs, it's an optional Asset.
Okay, thanks
It's a on_command_error event, have you got one of those yet?
Not in my discord.py prime, forgot about a lot of stuff after having a huge break
Someone motivate me to code today, up to 3.5k lines of code and spacing out 
Please search relative imports, if you still need help please provide your project structure and what you are trying to do.
"It's not how many lines that count it's what the code does and how efficient it is"
What did you make?
I'm definitely being fairly efficient compared to my first bot
It's a game with images and tons of stuff
Oh yeah def, really like seeing progress by making new bots every couple months.
Using pillow
async?
I didn't even know there was an async version of pillow
I could also help you read the docs, if you understand the docs you can basically code anything.
There isn't that's why I asked how you tackled that issue π
How would it be an issue?
I know how to read docs, I prefer having examples because it gives a better understanding of what something does and how to use it
Pillow is really heavy sync code, it's only an issue if you got lot's of traffic tough.
The image generation takes 100ths of a second if remember right, the saving of the image to disk is the slowest
Okay well on_command_error is the event name, and ctx and error gets passed by default.
So error will be the exception object containing what was the issue.
ctx will be the command that has gotten an error.
async def on_command_error(ctx, error): ?
Yep
ok thankyou
@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.")
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").
time to rewrite all my commands 
Ive handled errors and shit that i can handle there in each and every command one by one
You just defined manual labor.
i know
atleast my commands wont look like a sloppy peice of shit anymore
triggers my ocd when ive rushed a command :(
do what pandabear said

what he said
on mac we need to install this on the terminal to import it then idk why
if I don't do it I can't import the package
I don't really understand if you didn't understand the question or being sarcastic
Input a gif
embed.set_image(url="gif_url")
Command
Thx
Not u
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
Api
saves bandwidth of uploading every single time
pip install --upgrade --no-deps --force-reinstall git+https://github.com/Pycord-Development/pycord
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - GitHub - Pycord-Development/pycord: Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API
Why not just add them locally?
i honeslty dont know
@slate swan are you using pycord or discord.py?
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?
set gif_url to an actual gif url though π
Try uninstalling discord.py or reinstalling pycord
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")
^
@slate swan
having to upload every gif doesn't sound great
no
Then?
embed.add_field(name=f":flashgun:| **add now:flashgun: **",value="desc")
embed.set_image("https://cdn.discordapp.com/attachments/960814524187938816/967838916814209084/standard.gif")
Ohh
the image will appear at the bottom of the embed above the footer and such
or gif at this example
Ok thx sir
uh
bad reason
Assuming no one would ever delete the server/ message
could i get an example button made with disnake? i forgot how they work
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?
missing url kwarg
embed.set_image(url = "https://cdn.discordapp.com/attachments/960814524187938816/967838916814209084/standard.gif")
Ok
quick question
@severe rampart
how to show all roles in discord.py
Roles of what
the server
!d discord.Guild.roles
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.
@client.command()
async def roles(ctx):
await ctx.send(discord.Guild.roles)
Like that?
indentation error right
Anyone?
No
How then
Yes
your indentation is wrong
I just want it to return a quick list of the roles nothing special
!d discord.ext.commands.Context.guild is your guild object
Returns the guild associated with this contextβs command. None if not available.
no
Yes
Same thing
no
Potato potato
π€¨
The end result is the same thing
Please tell me how to solve it
!indents
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
your wording is trash
@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
Because it's old ass code that you didn't write
copied?
client.delete_role() π€£

yeah I just wanted a quick code lmao
I cba to write something
just need something quick to work xd
what
Not working
Nitro ded
no
Bro be quiet
3rd line is function body
so whats the client.delete role thing
What are you trying to do
or function declaration π³
Just delete a role like .delrole @role
