#discord-bots
1 messages Β· Page 40 of 1
Cuz it would give a straight error of no definiton but it's not
So it has alr been defined
ayo
?
one sec??!! I just reran it and it's working wtf π
well... there are a lot of things those could be organised, for example: speed and memory (using ['hey'] instead of {0: 'hey'} is faster), repeating code (could with a function or classes) and OOP stuff
Whatever, At least it's working unlike mine π’
lmao
Ye same here π€
braaah
ayo π
I mostly using classes
you are using pycord right?
Disnake
i copy pasted your entire code on my test bot token and it works
How can I fetch a image from message in dpy?
idk what the fu
!d discord.Message.attachments
A list of attachments given to a message. If Intents.message_content is not enabled this will always be an empty list unless the bot is mentioned or the message is a direct message.
ye
Ok
The frick is this
hm, im not sure but probably it's required in disnake for arguments to have a description
same error
pass a valid token
well, I thought like that like... 6 months ago, and now i understand what trash was that
skill issue
try it with a new app
There is a description
create a new bot and see if it works
too hard xd
not for an argument
ah π
Ill try pycord maybe..
perhaps u are redefining it somewhere
i've copied his entire code and tried it and it works
Classes not really good
nooo
that doesnt change a thing
He his..
Wooot
use discord.py or hikari 
that's literally the only difference between me running it and him
^^^^^^^
d.py dosent work brah
wdym? π³
more like u not able to make it work
Wrong one bruh
why? they are good, very good
if used properly
nice
how are u gonna make pycord disnake or nextcord work u just change the name for same code and it works 99.99% of the time
why error
so if u fail dpy nothing else helping u
Alr.
if arg > str(13):
await ctx.send("You are old enough for this server.")
member = ctx.message.author
role = get(member.server.roles, name="Verifyed")
await bot.add_roles(member, role)
my bad

Verified*
str(13)
you've been looking at outdated documentation
someone need to pin this
and how are you
i was getting an error ab that so i had to change that
it shouldn't be a string
or just !readthedocs it 
bruh i need to change this too
well it doesnt have that so it wont work either ways
Client.add_roles() has been deprecated and removed for a long time, the equivalent now is Member.add_roles()
https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.add_roles
i don't understand how you're getting these errors when i can run the exact same code
BRUH
I REINSTALLED DISNAKE
IT WORKED

π
da universe changed for me

New bot also not working
sometimes i hate python..
Frikin improper token my ass
i've installed disnake maybe 4 times and never had that issue
erm
idk, disnake goin crazy with me
skill issue then
have you tried printing the token to make sure its what you expect it to be?
print it just before the run statement
rule 1 of python
print the shit out
i can't imagine you're able to do this without a different error, but is your token in quotes? @flat swallow
i like the attitude 
yessir
Β―_(γ)_/Β―
u mean here right
ima pea
if its not printing shit correctly that means u messed up rule number 1 of any coder
token is working i printed it its correct
Debug ur program :D
and your token is from the reset token button here
back
π€¦πΌββοΈ
that name..
ye bruh
uhm
client secret
Uhhhhh ye imma dip rq

make it quick, gotta make the bot work
must drown in a glass of water at this point
What do you guys think is the best vps for discord bots? and cheap and just easy to use
yes
imagine trying with application I'd instead
uptimerobot
digi ocean maybe
hell never
does no one here use AWS?
no
IS ohvcloud good?
get me a cc
i use railway no matter what they say
application name
2gb for 3 euro a month
cz i dont give a f
1 year free when you sign up on AWS and it's literally the fastest connection you'll get
-13 year ol me who dosent have a credit card-
if u unverified PPL like me no cc nothing not a dollar in pocket use heroku or railway app
railway best ngl'
ty guys so much for putting up with my dumbass π i got it to work now tysm
fake credit cards-
either ways, I use my brother's 
but railway is good for only 1 month, after that emotional damage
sedly me the older brother
my bro is 4 ;-;
so lifehack fail
same
elder brother perks
have fun while u can everything gonna become 50:50 soon enough
but well i make money from rblx gfx' and game dev'ing
bro its 90:10 rn, i have no powers
well lets keep it on topic for now
me only still poor π
π
no work nothing
imagine
shush
what imagine living it rn
Asians 
im done with this girl rn
smh
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
thats it
still fine food in foreign only salt and pepper Asia still best
dubai even better ;)
Dubai better coz no taxes 
im still confused that by asianns do u mean people living in asia or japanese/chinese
who even likes food in 2022 
kek my country not even named πΏ
wa-
i don't live in China or japan
then.
oh yea lol
India, yes we know asher
India
i ain't even talking to u π
me indian π
imagine being so rude 
i kinda knew cz ur pfp
me
my pfp look Indian π 
indians keep anime pics
emo anime pics πͺ
Please keep this chat civil.
π
Also keep it on topic.
Alright
yes sir
skill issue
indian look-alike no.2
!ot bruh
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
?
use ot channels π
Can someone tell me some bot ideas
Lke cmd ideas
trackers 
what.....
a bot that deletes itself
.
a command that adds a listener to check if a member/message was updated and send a message to the user until the user/message is ever untracked
u expect me to do that
never
lol--
I did that, so can you
OH shit i just pinged him
ashley still into voyerism i see
make some games
peace.
I never got any thing in which i could use classes
what the hell
3 indians in a row :)

ur commands on bots don't exactly respect privacy
i still remember that last snipe command thingy
back to topic
I never made a snipe command lmao
before we are oted
Guys anyone give me a idea how i can make help comand easily . Is there any way i can get all comamnd names and it's aliases?
I don't object about the trackers
subclass HelpCommand
ghost pong
We have a guide on it in our site. I donβt know if itβs merged yet. I should know because im the project lead for it, but I donβt hahaha
im having an issue with permissions.
im trying to get my bot to change users nicknames, but everytime it tries to it has an error saying forbidden permissions. but my bot has administraitor and its trying to change my alt accounts nickname who has no permissions? does anyone know whats going on?
w-w-what site? π π
If your alt is above your bot in the role heirarchy, it canβt change their nickname
oh π³ kay
but its not. the bot is at the very top and my alt only has @ everyone
o-o-o-ff top-ic?
i mean gif is too much
lmao
π
does message.edit have a rate limit of about 5 edits per 5 seconds?
looks too short for a whole game
If so, is there a way to avoid that? I want to make text animations by editing messages
But I get rate limited (I think)
50 per second global iirc
5 per second per guild
dynamic but u will get ratelimited for sure
i tried making marquee text before
why am i getting this error\
horrible results
don't do this
@bot.command()
async def create_role(ctx, whatrole):
await bot.add_roles(whatrole)
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
uhm... woops, i guess i just remove this command so i have no problems
i am trying to create roles
well that's depressing
if you have to animate something then you're gonna have to send gifs
Gifs suck ngl
I'd rather have it text based
is there a way to create roles?
no they don't 
use a gif of discord font with transparent background then?
!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/latest/api.html#discord.Role "discord.Role") for the guild.
All fields are optional.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/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...
thx
combine flour, water and yeast, let it rise and then bake for about 25 mins at 180c
what recipe is this no saltπ
salt makes everything better
no salt no sugar
use monosodium glutamate
add a tablespoon of marmite
no i use hydrogen proixide combined with oxygen with a little heat then BOOM
@commands.command()
async def aping(self, ctx):
id1 = 813824599522541628
id2 = 574217755692236803
if ctx.message.author.id == id1 or ctx.message.author.id == id2:
await ctx.send("Admin ping sent!")
link = await random.choice(self.ctx.guild.text_channels).create_invite()
channel = await self.client.fetch_channel(1009396408345964655)
embed = discord.Embed(title=f"Admin Ping!", color=0xff0000 )
await channel.send(f"<@{self.ctx.user.id}>")
embed.add_field(name=f"Latency:", value=f"{round(self.client.latency * 1000)}**ms", inline=False)
embed.add_field(name=f"Server Name:", value=self.ctx.guild.name, inline=False)
embed.add_field(name=f"Server ID:", value=self.ctx.guild.id, inline=False)
embed.add_field(name=f"Owner Name:", value=self.ctx.guild.owner, inline=False)
embed.add_field(name=f"Owner ID:", value=self.ctx.guild.owner_id, inline=False)
embed.add_field(name=f"Membercount:", value=len(self.ctx.guild.members), inline=False)
embed.add_field(name=f"Invite:", value=f"{link}", inline=False)
await channel.send(embed=embed)
``` I'm confused, also self.ctx.user.id is not correct idk
im still having this issue
i just dont get it
bot is administrator, its role is the highest in the hierarchy, yet it cant change my alts nickname that is at the bottom of the hierarchy because of a 'permissions error'
aping 
?

:this
code?
why are you using self

π

same
replit = bad

i used to use replit
point in correct direction u giving misdirections π
thats why i added that
π
master32 gps system broken π

replit, nah repbad 

has it ever been up? π
@client.event
async def on_message(message):
content = str(message.content)
keyword = content.split(" ")[0]
if keyword == "!nick":
new_name = content.replace("!nick ", "")
await message.author.edit(nick=new_name)
problem is too many PPL use replit for hosting and then they go get their neighbours bots ratelimited

yes
i see no process_commands
?
PPL who use on_message for commands ....
i used to get rate limited all the time 
i am saying in wrong place
i think... he is using... discord.Client π
Local variables vs global variables? Which take more CPU ? If i use more global variables is it ok ?
i don't think so
yes i do cause i have things like simon says and stuff.
yt tutorial always do client = commands.Bot
they never really want you to use global variables
...
I always get yelled at when I mention them π
client = commands.InteractionBot()```
there is diff between global variables and global keyword
Who they ?
i dont see how this is relevant since it is a permissions error
that's not dpy π
yet the bot has the highest permissions and my alt has the lowest
i never go and say PPL don't use global vars use globals vars no problem don't use global keyword to edit global vars
could you show full traceback please
ahh
both have diff roles in diff cases
u need constants use global variable u need for temporary storage then use functions functions have a local env where local variables are utilised
is it possible to delete roles on command
inbuilt ones
yes
wth is TYPE_CHECKING used for in making bot? (saw it in RDanny)
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\user\Desktop\mc db\main.py", line 1111, in on_message
await message.author.edit(nick=ign)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 681, in edit
await http.edit_member(guild_id, self.id, reason=reason, **payload)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
How to get the ID of someone in a cog of the user executing the command? its self.user.id right?
Has anybody else tried making animations through editing text
i believe if iirc and am not mistaken that you don't have permissions
iirc?
you don't have the right permissions
u fetch the role then delete
there's literally no other reason that error would happen
!d discord.Role.delete
await delete(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the role.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this.
@dull terrace ig
strange i checked docs guild has create role but no delete role πΏ
this is the bot:
one line extra to delete
and my alt is only @ everyone
?
i made gifs 
are you trying to edit your own nick as the server owner?
no, my alt
is Bot your bot's official role?
gifs are so buggy sometimes. Sometimes they'll play, sometimes they won't upon viewing and if a user scrolls or does something in the meantime they'll stop or restart
and your bot actually has the correct permissions in the channel?
yes, its the intergrations thing
Is there no better alternative
there is
why would channel permissions forbid nicknames? it has permission to all channels anyway
u read it out in a voice channel
omg ive listened to this 3 hours str8
thats what i always do
at this point ur ears not even processing the song
yes
oh own nickname 
ok nvm im actually an idiot why did it take me 20 minutes to realise it wasnt trying to edit the person who ran the commands nickname, it was always trying to edit mine (server owner)
sorry for wasting everyone time π¦
they only hear "we dont sleep at niiight"
it be like this noise from last 3hrs i don't even care anymore
...
alright so it didn't have the right permissions
i have met people who tried to make bot kick owners this is nothing
i have no clue how i did not, genuinley. this has been such a waste of time on my part
sorry
smol mistake
literally happens with everyone dw
how can I make my autocomplete like this? (I use disnake)
I myself tried to unban a bot that is in the guild
command_name.autocomplete("param_name")
async def(self, inter: discord.Interaction, param: typing.Any) -> list[app_commands.Choice]:
for slash?
yes
not how I made autocomplete
now I feel like I switched the world, not a song in background
app_commands in disnake?
new question: how get a discord.Member from a 'User' object
fetch_user returns a user object but i need a member
async def butthole(message, options: ["asdfasd", "sdafasdf"]):```
pretty sure thatll do
what ever equivalent
!d discord.Guild.fetch_member
await fetch_member(member_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.
Note
This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
Changed in version 2.0: `member_id` parameter is now positional-only.
thanks
or get_member
I am not asking how to make an autocomplete, I want users to select their argument from autocomplete only
oh you have to do this too
options = commands.option_enum(["asdfasdf", "asdfasdf"])
then options: options
too lazy to open and see
open what
the code for rdanny
cogs/utils/context.py lines 3 to 13
from typing import TYPE_CHECKING, Any, Callable, Iterable, TypeVar, Union, Optional, Generator
from discord.ext import commands
import asyncio
import discord
import io
if TYPE_CHECKING:
from bot import RoboDanny
from aiohttp import ClientSession
from asyncpg import Pool, Connection```
typing.TYPE_CHECKING```
A special constant that is assumed to be `True` by 3rd party static type checkers. It is `False` at runtime. Usage:
```py
if TYPE_CHECKING:
import expensive_mod
def fun(arg: 'expensive_mod.SomeType') -> None:
local_var: expensive_mod.AnotherType = other_fun()
``` The first type annotation must be enclosed in quotes, making it a βforward referenceβ, to hide the `expensive_mod` reference from the interpreter runtime. Type annotations for local variables are not evaluated, so the second annotation does not need to be enclosed in quotes.
what is a robodanny
bot in dpy server
the bot in dpy server
yall need to upgrade to disnake
ya need to upgrade to discord.py
Yes
but that would be a downgrade
My previous code is something like ```py
Options = ["Option 1", "Option 2"]
async def xyz(inter, string: str) -> List[str]:
return [monkey for monkey in Options if string.lower() in monkey.lower()]
@bot.slash_command(name="monke", description="monkeys are nice")
async def monke(inter:disnake.CommandInteraction, options: str = commands.Param(autocomplete=xyz)):
...```
it don't matter as long as u can make discord bots and u don't use pycord 
no, your brain is downgrading thinking like that
How to delete the authors message again
await ctx.message.delete()
ty
beat me to it π
well, true, py**-**cord is q-q-quite not good
Options = commands.option_enum(["Option 1", "Option 2"])
@bot.slash_command(name="monke", description="monkeys are nice")
async def monke(inter:disnake.CommandInteraction, options: Options):
...```
imagine coding in python and not using di snake
imagined
result: very nice
is there a c# discord api wrapper
lolmao
Hoow can we get command user avatar?
ctx.author.avatar_url
better display_avatar if you are using dpy 2.0
Avatar url
if you are using 2.0 then ctx.author.avatar.url
there is display_avatar.url also
yeah, for 2.0
its used when you want to avoid circular imports and still use the classes for type annotations
# foo.py
from bar import Banana
class Apple:
banana: Banana
``` ```
# bar.py
from foo import Apple
class Banana: ...
``` this will raise an import error
but you can avoid that by ```py
# foo.py
import typing
if typing.TYPE_CHECKING:
from bar import Banana
class Apple:
banana: "Banana"
Apple.banana 
tf is going on 
How can i make it so a button opens up a modal and without sending any messages?
!d discord.Interaction.send_modal
noway
π
!d discord.InteractionResponse.send_modal
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.
ohkay
so it is possible π±
yes it is
its mainly used to import classes for annotations and stop the problem of 2 files to depend on each other(both of them are mutually imported), its just a constant thats values is False on runtime but not when editing your code, mainly used for ides to know types etc
How could I make application commands dpy 2.0
TYPE_CHECKING is nice, but I would almost always prefer forward referencing, only if it weren't for the fact that if I did forward reference I would still need TYPE_CHECKING to make the type-checker know it's defined....
Any idea?
Doubt: How do I get the content the user has entered in their dms
I am making a hangman function
you'll most likely want a wait_for
Guessing this isn't very correct then
I should
But I have come so far that i am very lazy to change this
instead of checking for certain strings in the on_message event
that'll be very messy
you also want this
https://discordpy.readthedocs.io/en/stable/api.html?highlight=wait_for#discord.Client.wait_for
then you're basically all set
Hope this looks in order
Can you have two async def on_message(message) in the same script, or does your code need to be consolidated to one on_message() function?
With listeners, yes. Events, no
What is the difference?
event overrides the built in functionality of that ws event whereas listener appends our function to an internal list and doesn't override anything
that reminds me of that song for no reason
So is my code right?
Hey @flat swallow!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
If the song is right, so is the code
async def on_ready():
print('{0.user}'.format(client))
print('Is Online')
print('-----------')
await client.change_presence(
status=discord.Status.idle,
activity=discord.Game(
name=f",help | In {len(client.guilds)} servers, {len(list(client.get_all_members()))} members. ",
),
)```
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
can someone tell me why it doesnt say in status the correct amount of members
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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
i have intents
intents.members = True
initial_extensions = []```
ur intents are to make ur code work π
no way really
Why can't I tick all lol
did u pass the intents to yr bot constructor?
discord dev portal?
what do i do with that?
get_quoteid a blocking function, make it non-blocking by using aiohttp instead of requests- keep your imports at one place, you're importing
datetimerandomly anywhere - create another test file to test things out, don't do it in the main file
- Unnecessary try/except in the
on_messageevent - it's
bot.commandnotbot.Commandin the command decorators - hard-coded help command
- The
memecommand is blocking, use aiohttp instead of requests - The
hangmancommand will never work because of the wrong usage ofstr.startswith, that ismessage.authorwhich is a Union of Member and User object, andstartswithis anstrclass method and the use ofstartswithis wrong too
How can i make a command to let my bot leave the server?
I want to make a command like !leave so the bot automatically leaves, because kicking, then confirming it annoys me...
can u help me pls dude
!d discord.Guild.leave
await leave()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Leaves the guild.
Note
You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.delete "discord.Guild.delete").
robin can u help me
oh thnx
My next class is about to start, so no, unfortunately
oh okay its fine
This correct?
add it after your prefix
you dont really require intents in a Bot
doesnt work still
still says ,help | in 48 servers, 48 members
WHY ARE MY COMMANDS NOT WORKING π
wait im lost, whats your goal? I only saw u asked what u have to do with that intents=intents
im trying to get my bots status to say
,help | in 48 servers, {number of members}
it says the amount of server and help but the members of serv is 48 even tho its in 1k+ member servers
members = 0
for guild in client.guilds:
members += guild.member_count - 1
and then
something something(In ... servers, {members} Members)
should work if im not wrong
async def on_ready():
print('{0.user}'.format(client))
print('Is Online')
print('-----------')
await client.change_presence(
status=discord.Status.idle,
activity=discord.Game(
name=f",help | In {len(client.guilds)} servers, {len(list(client.get_all_members()))} members. ",
),
)```
is what i have
len(bot.users)
@client.event
async def on_ready():
print('{0.user}'.format(client))
print('Is Online')
print('-----------')
members = 0
for guild in client.guilds:
members += guild.member_count - 1
await client.change_presence(
status=discord.Status.idle,
activity=discord.Game(
name=f",help | In {len(client.guilds)} servers, {members} members. ",
),
)
try this, i used it long ago so it should work
idk if that works
but I do
never used it before
works thanks man
hi, iβm trying to make a server lockdown command, so far i have this but it will just send the embed and not change any of the permissions, im confused as this should work, right? what am i doing wrong?
iβm running this in a cog
Hey, I would like to publish my bot on github. I dont want to inculude files like TOKENS, which are private, how should I do that? The token is stored is in .env file and I know that there is something called gitignore, with which I should be able to ignore this file, but I have very liitle knowledge of git and I dont. want to mess it upπ
Just add your .env file to your .gitignore file
Or should I not include it at all?
like not publish .env file
Easier to just add to gitignore because all it takes is a slip up
yeah
How can i make my bot send the responses of the Modal into a channel or to me?
tried
id = (the server id here)
await interaction.id.send(response)
and some more things...
add *.env to your gitignore
okay and can you please help me how should i do that with git cli?
gitignore file
there should be a file called .gitignore
alright, ill ty that, thanks :)
How do you set a backslash as your command prefix in discord.py? I tried escaping with /\ but it took the prefix to be the literal /\. using just \ leads to an escape error
if not, make the file and put it in the root directory of your project
i donβt think you can
File "main.py", line 23, in <module>
from discord_components import *
ModuleNotFoundError: No module named 'discord_components'``` i randomly got this error
have to wait for someone to come up with a solution
itβs not an intentional ignore
could I host a bot on a old pc by just leaving it on running the code?
epic
anyone know answer
Anyone know why this is returning none? https://femboi.best/cSEwAZwt
remove from discord_components import * from your code
no guild with taht id
there is tho lmfao
make sure there is
if there wasnt the bot wouldnt even start
because seems like there isntit would
as it wouldnt be able to sync cmds
maybe not in bot's cache?
oh
ohkay
so it does start?
is that an http only bot?
well yes???
i fixed it dpy has a bug lol
loop starting before bot loads
not a bug but still
pain lol
learn python basiiics
not a bug, a feature
i have one more question, i'm implementing slash commands and i pip installed pip install discord-py-slash-commandand i put from discord_slash import SlashCommand and slash = SlashCommand(client, sync_commands=True) in my code and it gives me an error saying ```Traceback (most recent call last):
File "main.py", line 21, in <module>
from discord_slash import SlashCommand
ModuleNotFoundError: No module named 'discord_slash'
just learn python basics please
bro please
I know how, you know how to learn right?
so you are
man if you don't wanna help someone, just don't answer, there's no point of telling them to learn
i have a issue pushing my repo to github, it says "fatal: Authentication failed for" even tho my password is right, i even tried changing password but it doesnt help
this is a help server, people don't come here to be told to learn
Um, actually, how can anyone help him if he doesn't understand basic elif and indentation 
btw he's already been helped with saying that he needs to use elif
most of the time just to be spoonfeed if we are going to be honest with itπ
tbh ig yeah
oh
go read the documentation
lmao
use dpy 2.0
aight im gonna try to explain one thing
Could we please keep to civil folks
If i want to have a list of IDS and prevent two users from pressing a button each time a command is used, what's the ideal way?
is there any documentation on that
You are using if argument == "something": and inside it you do if argument == "something other", do you understand that both they would never be true?
we have a good gist on how to make Slash commands using that
Better helping someones future than spoonfeeding them.
Use the interaction check
thanks
You did that for some reason, you have to understand what that is for and what do you want to do, and that way you code... I could've told you to use elif instead of second if and move it one indent lower, but if you are not understanding the code you are writing that is a problem
Where should I define the list to compare to?
In the button subclass itself?
how are the users decided upon
yes, do you understand how that works?

that's the most important part... ig
If you understand how it works why do you question your solution and ask for someone to prove that youre correct and then doubt yourself because of the basics of indentation in python?
details π 
im not being rude, its just odd to me
that like me after 5 mins of thinking regex pattern
should I ask in server or not 
gosh i hate regex patterns
i am no expert in slash command but i think that argument param typehint is causing error
typehints are converters in discordpy.
i think that's because channel is typehinted as TextChannel and being None by default
it's too much usage of brain cells but satisfying after getting it right
uhm, no? typehint channel as Optional[TextChannel]
btw make sure to import Optional from typing
wth is Union[] in a function?
that's not the problem, TextChannel = None is automatically converted as Optional[TextChannel]
its used for parametization of one type or another as a union
i used = None before no problems for me
means arg can be either A or B in here arg: Union[A, B]
arg may only be one of those args?
π³ ok
That is so.
A, B are types
but don't typehint Union in slash commands it dosent work with union iirc
what's your problem, I've arrived now
yes it does not
is that the full error
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
either way union really shouldnt be used as the built in union operator (bitwise or/pipes) are a thing
is Literal[] for choices?
wth
only time you should use it is when your package or code needs to be in python 3.5
i wonder why
words of truth 
you can always use it in 3.7 with future.__annotations__
who are u explaining so much for
im currently in pain as im taking physics this year
you should understand what is wrong
ah ic sed
literally the hardest class in my school lmao
it's good to relax by talking π
!d discord.app_commands.Parameter you could use, I think that your error is related to Literal not 100% sure
i probably would've explained but that's too long
class discord.app_commands.Parameter```
A class that contains the parameter information of a [`Command`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Command "discord.app_commands.Command") callback.
New in version 2.0.
If i want to have a list of IDS and prevent two users from pressing a button each time a command is used, where would I store the list to compare it, and append to it?
it depends
hmmm... do i respect my schedule and go to bed or stay here until 1 AM and fall asleep and then wake up at 6:30 cus of an alarm clock
if you want it bound to a view, instance variables, if you want it bound to multiple views, global variables
Cloning https://github.com/Rapptz/discord.py to /private/var/folders/ph/kx_6fd713312kg0lv_rqhflr0000gn/T/pip-req-build-mank_kwh
error: subprocess-exited-with-error
Γ git version did not run successfully.
β exit code: 1
β°β> [2 lines of output]
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
Γ git version did not run successfully.
β exit code: 1
β°β> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
``` im getting this error trying to download dpy 2.0, i have a mac
is this for me?
@glad cradle
That is so.
π³π³π³, they're different links, btw what a shitty documentation
honest to god nextcord is the one y'all should be using but i'm not gonna force my opinion on anybody
ππ
hm, they are, but mine is with 2 examples btw
π©π
and pycord is shitty itself btw
not really, i would prefer to make a lib myself
always True
go ahead make your own discord bot library 
pretty easy non the less
anyone??
your option?
make a good one i beg
so it would be ```py
class MyNutton(Button):
self.clicked: list[int] = []
async def callback(...):
if interaction.user.id in self.clicked:
return
self.clicked.append(interaction.user.id)
in a command
view = View()
view.add_item(MyButton())
await ctx.send(content, view=view)
Would this use the list per-command usage? meaning it prevents two users from pressing a button each time a command is used
Im not making a library thats gonna take me weeks just to make good enough models with modular abstractions and good codebase
Youre better of making the lib yourself and knowing every corner of it
i guess
should look like this
argument: str = Option(str, description="argument options", choices=["option 1", "option 2", ...])
but he is doin it for argument
not for channel, channel is separate arg
wasn't channel the argument?
I think he copy pasted some example code
argument: choices, channel: Channel = None
im pretty sure channels annotation isnt correct
fixed
^
i guess ill go sleep, i hate waking up with feeling that my eyes are not with me
who craes
Good night buddyπ
Your linter does
uhm, same
mypy lsp 
what does this mean
its the thing in your IDE which does syntax highlighting stuff
that's related to some embed obj
nice
mypy acts like a child, screams and cries about everything
can it highlight him with red for me?
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
btw what's the class modal 2
yea lol
ok lemme read the docs
you didnt see his subclass, and I'm predicting noone wants to see it
you can make it do that 
yeah
can someone help?
how do you make this:( i want it
so everyone would see im not doing shit when im doing shit
@slate swan you need to use inter.response.send_modal(modal)
true, I won't read it
there is no discord presence
some plugin is there just type discord and search
that's for vsc no?
error
wdym?
delete sys32 or bin
there is one for all ides
I can't understand, it should work if there aren't errors in your modal2 class
gn guys phone at 2% for me now
π©
bye
that is literally the plugin i tried to install
and it gave me an error
no
ok
what error?
this
- it's a coroutine you should await it
await coroutines 
- in your case is interaction
any1 know how make a bot pokemon? like poketwo 
can't really see the error, can u scroll down to the good stuff
is it wrong? π³
ohkay, ill install it again
wait WHAT, it installed?
@slate swan
β¨ magic β¨
ryuga magic dance
guys how can i send the modal inputs to the bot owner or into a channel?
it's interaction in your case πππ
Inter is an abbreviation of interaction like ctx is an abbreviation of context
π
go to the plugin settings and configure it
where? i dont see them
Are you trolling or being fr?
that gear is uninstall or disable
maybe he's trolling
lets head to #ot0-psvmβs-eternal-disapproval
I don't like to do spoonfeeding, it's
await interaction.response.send_modal(modal) in your case
Yeah, a definite troll. Just ignore them.
^
to be more precise and cause less confusion you should use UpperWord for class names in your text so people can differentiate
it was an example, I'll do it ππ©
ok
what is your current code
line 292
^
related to your Modal class
do you know OOP in python?
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
learn it before creating a discord Bot (you should also learn other things)
Could we see the Leave class?
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
π
except:
return
Hey i try to make a command to change the highest role of a user. How can i set that the arg should be the color?
@bot.command()
async def c(ctx, arg):
print("check 1")
member = ctx.author
roles = member.roles
roles.reverse()
top_role = roles[0]
await top_role.edit(colour=discord.Colour.arg())
print("check 2")
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
can anyone help me?
you can use discord.Colour which has factory classmethods to get specific colors (e.g red, blue, blurple, etc). Or you can use hex colors if you want a specific color that isn't available in the Colour class
But i want to set the color by the command
!d discord.ext.commands.ColourConverter you can use this converter then
class discord.ext.commands.ColourConverter(*args, **kwargs)```
Converts to a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour").
Changed in version 1.5: Add an alias named ColorConverter
The following formats are accepted...
No I just want to write e.g. -c purple to set the role color to purple
that's what the converter does...
sup
And how can i use this ColorConverter ? Can u show me that?
color = await commands.ColorConverter.convert(ctx, argument_to_convert)
Colour π
!d discord.ext.commands.ColourConverter.convert
await convert(ctx, argument)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The method to override to do conversion logic.
If an error is found while converting, it is recommended to raise a [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError") derived exception as it will properly propagate to the error handlers.
discrimination
bri'ish bot
But I cant use this variable
i still need help sending the modal answers to a channel or me in dms...
hi guys is there a way i could check if people are spamming too many commands and tell them to slow down or somehow stop them from ratelimiting the bot
any hikari users?
make cooldowns for each command or make a custom one
!d discord.InteractionResponse.send_modal
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.
await interaction.response.send_modal(modal)? I meant if the user finished the modal that the bot sends the answers to me
what do you need from them?
dont get you, do you want an input inside the modal?
How can i set the color to arg?
@bot.command()
async def c(ctx, arg):
print("check 1")
member = ctx.author
roles = member.roles
roles.reverse()
top_role = roles[0]
await top_role.edit(colour=discord.Colour.arg())
print("check 2")
how can i convert my bot's gateway id to username
Like after the user finished to fill out the modal it should send the things the user filled in there into a server or into my DMS.. kinda hard to tell what i want for me
typehint arg to discord.Color
and pass it as is
will it work like !c yellow?
check ColorConverter doc
ohkay
But i dont know how i can use the the color converter
.
just typehint the arg to discord.Color
await top_role.edit(colour=discord.Colour.arg())
please listen to what im saying π
await top_role.edit(colour=arg())
so? I dont get it?
arg: int
this is typehinting arg to int
@bot.command()
async def c(self, ctx, arg: int):
print("check 1")
member = ctx.author
roles = member.roles
roles.reverse()
top_role = roles[0]
await top_role.edit(colour=discord.Colour.__init__())
print("check 2")
Like that?
oh my god
please read this, maybe you'll understand
Is there a nice little guide or gallery floating around showcasing all the ways possible to style embeds and normal text messages beyond just raw function documentation? Specifically for discord.py
do you understand how to use a typehint
Yes ig
so
typehint the parameter to discord.Colour
discord.py will convert the parameter to that type before it is passed to the command callback
Okay but i dont know what i have to do
Ah okay i know
@slate swan opportunity for another gist
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Colour' object is not callable
I get this error
code?
@bot.command()
async def c(ctx, arg: discord.Colour):
print("check 1")
member = ctx.author
roles = member.roles
roles.reverse()
top_role = roles[0]
await top_role.edit(color=arg())
print("check 2")
so why are you calling arg
What else should I call?
don't call anything
any1 have a code pokemon
This channel is for discord bots, you may want to ask and elaborate your question in an OT channel or #python-discussion
Can someone put me out of my misery please.
I am using cogs for the first time today, and while adapting my code I have noticed my old code such as client.fetch_user(id) no longer runs past this point.
I believe this to be because having cogs means i need to change all my client.command() etc to commands..command, but when i change client.fetch_user(id) to commands.fetch_user(id) it stops running, no errors displayed either.
Does anyone know why this is?
Code:
for amt in total:
id_ = leader_board[amt]
print('a')
member = await commands.get_user(id_)
print('b')
name = member.name
pres = users[str(member.id)]["prestige"]```
Entire Output:
```py
>>> Logged in as: AgriCult BETA#2797
>>> a
>>>
since youre in a cog you would need an instance of your bot to use those methods, so you would an the instance which gets passed into the initializer of the class(__init__) which then you can just make an instance variable with that instance passed so you would do self.bot_instance depending on your instance name
class Statistics(commands.Cog):
def __init__(self, bot):
self.bot = bot```
I have this, if this is what you mean?
yup, use self.bot as its your bot instance
Do you have any error handlers? Your client isn't defined, but you're not getting any errors
What is the best way to 'separate' iterations while still maintaining output in one single embed while using a for loop? I tried embed.add_field(name='a', value= "\n\u200b") -> but I don't want a title and it doesn't really add a space in the way that I want (which is to break up each iteration by a horizontal space or, better yet, some dashed line indicator)
For error handling I have:
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('Please pass in all required arguments.')
if isinstance(error, commands.CommandNotFound):
pass
if isinstance(error, commands.CommandOnCooldown):
msg = '**Woah! That\'s too fast!** Please try again <t:{}:R>'.format(int(time.time() + error.retry_after))
await ctx.send(msg, delete_after=5)
if isinstance(error, commands.MissingPermissions):
await ctx.send('You do not have sufficient permissions to use this command!')```
Perhaps .join()?
like separate iteration values with other values?
so instead of client.fetch_user i use self.bot.fetch_user? I don't quite understand
!d str.join | is probably what youre looking for
str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
well because of instances lol
Right, okay. You need to have:
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
to print out all other exceptions
Currently all other errors are silently ignored, and that's a big no-no
So I'm putting this where sorry?
First thing inside of your on_command_error because errors should always be logged
Oh, and make sure you import traceback from the stdlib
No, Iβm talking more about the layout of a modal itself
Like so
Inside a single modal
so
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
# rest here```
also saying `"sys" is not defined"
I have `import traceback`
A modal as in.. an embed that shows up in chat or the little popup?
Oh sorry yes an embed
Ah okay. You want sort of a table sort of deal going?
My current one outputs everything scrambled and not in an easy-to-read layout
Yes exactly
It's going to be a bit difficult, because things look really weird on mobile, and on different computers zero-width characters will look really strange
I think you might want to re-consider how you want them displayed
Hm, okay, thanks
Oh and also import sys, that's on me, sorry
Do you have any other error handlers? If so, do the same things there
Global error handlers can come bite you in the arse if you're not careful
no I just have all the error handlers in the one function and cog
It's now outputting
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.ext.commands' has no attribute 'fetch_user'
There we go, we're getting errors now
this has been an issue since day one for me
Now you can do what noid suggested
I've never had errors so I never knew what was the issue
Bind the bot instance to the cog, then use it as self.bot
idk what an instance is I'm sorry lol
bot = commands.Bot(...)
this is your bot instance
is it possible to get a users about me section with a discord bot
!d discord.Member.activity
property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.activities "discord.Member.activities").
OHHHH
this?
#bot.py
client = commands.Bot(command_prefix='!', help_command = help_command)```
So something similar
class MyCog(commands.Cog):
def __init__(self, bot: commands.Bot, ...) -> None:
self.bot = bot
...
@commands.command()
async def my_command(self, ctx: commands.Context, ...) -> None:
# you can use self.bot to reference the bot instance here
def setup(bot: commands.Bot):
bot.add_cog(MyCog(bot))
That's traditionally how it's done. If you don't want to do all of that, you can also just use ctx.bot
so then after this I would do bot.fetch_user()
Whenever you need to do that, you would do await self.bot.fetch_user()
yeah
All non-@staticmethod, and all non-@classmethod will have the instance passed as the first variable to them
what's the difference?
Between..?
staticmethod and classmethod
Not relavant for our usecase, but the more you know the better. Static methods are methods that are part of your class but don't really need an instance. You can just call them like this:
class MyClass:
@staticmethod
def static_method():
...
MyClass.static_method()
Class methods let you construct a class from some given information:
class MyClass:
@classmethod
def class_method(cls):
return cls(...)
ah, alright
But your regular function:
class MyClass:
def regular_method(self):
...
must always take self as the first argument
Same thing with cogs: self first, ctx after
that I've to be the most annoying
adapting my whole bot for cogs and then not knowing why they dont work
because i didnt include self
Well, now you know why they don't work
The thing is, if you don't include self as the first argument, and instead have ctx, then your ctx will actually be self
You expect your context to be of type commands.Context but it's actually the instance
something I had an issue with hours ago suddenly makes so much sense...
But we've got your errors fixed so now you should know why something's wrong
You'll also have one extra argument, and you probably gotten an error for that
TypeError: Admin.bot_dev() missing 1 required positional argument: 'ctx'
I had this about 2 hours ago
I didn't add self, so ctx would have become self right?
and that's why it errored?
Exactly
robin with the member.activity and user.status it always returns as None and Offiline even when there online and i can see there activity
π€¦ββοΈ I'm an idiot
i have intents enabled
Both in the dashboard and in your code?
yep
as it is written here it can be none if the user is listening to something on spotify with a title longer than 128char
You need the presences intents enabled
it is
u mean this


