#discord-bots
1 messages · Page 660 of 1
yes basically
Yeah i assumed as i saw super()
check what children returns
What to do? Interaction error!
Code:
https://media.discordapp.net/attachments/343944376055103488/917823921200443413/unknown.png?width=299&height=138
# Выдача ролей при помощи select menu
@bot.command()
async def rolesp(ctx):
await ctx.channel.purge(limit=1)
give_roles = discord.Embed(
title = 'Автоматическая выдача ролей',
description = '**Вы можете самостоятельно получить роль выбрав ее название в меню. \
\n При выборе своей гендерной роли вы будете выделяться ее цветом. \
\n Роли доступные для получения в данный момент:** \
\n:female_sign: — <@&864246807353884722>\n:male_sign: — <@&864246881667383336>',
color = 0x36393E,)
give_roles.set_thumbnail(url='https://media.discordapp.net/attachments/865681789493051423/917820894234169454/static.png?width=172&height=172')
give_roles.set_footer(text=':zap:Cascade:zap:')
await ctx.send(
embed=give_roles,
components = [
SelectMenu(
placeholder = "Выберите гендерную роль",
options = [
SelectOption(label = "Девушка", value = "Девушка:female_sign:", description = "Вы получите гендерную роль женского пола!", emoji = ':female_sign:'),
SelectOption(label = "Парень", value = "Парень:male_sign:", description = "Вы получите гендерную роль мужского пола!", emoji = ':male_sign:'),
]
)
]
)
interaction = await bot.wait_for("select_option")
# member = ctx.member()
# await member.add_roles(interaction.values[0])
await interaction.send(content=f"Роль {interaction.values[0]} была вадана!", embed=embeds)
bot.run(TOKEN) ```
Why exactly?it disables the button but im just trying to know how to change a color when its disabled
this is the problem. you currently dont know what you are exactly doing.
self.children is basically View.children as it is a subclass of View
it returns, discord.ui.Item. It means it can be any of these:
discord.ui.Button
discord.ui.Select
as is in the docs of Item
what you get are the instances of the buttons you created and the Select menu instances if you have any
what you do next is that, you change the things of the instances like disabling it by doing
Button.disabled = True
Yes i do not know much on childrens
its all OOP and python classes
never think its any special thing of python specially added by python for this lib, it confuses
Yeah i should go by that advice 😭
Im always thinking new stuff are really different when its all oop😭
no its all just classes
Thx bro😅
Yeah i just think its different when its not
its all objects™️
Hahaha
i = 1
rankings = pstats.find().sort("MMR", -1)
embed = discord.Embed(title=f"6Mans Rank {rank.upper()} Leaderboard:", color=0xE74C3C)
for x in rankings:
print(x)
try:
print(f"0.1 = {x}")
temp = ctx.guild.get_member(x["id"])
print(f"0.2 {temp} = {x}")
temprank = x["Rank"]
print(f"0.3 {temprank}= {x}")
tempmmr = x["MMR"]
print(f"0.4 {tempmmr} = {x}")
tempwin = x["Wins"]
print(f"0.5 {tempwin} = {x}")
temploss = x["Losses"]
print(f"0.6 {temploss} = {x}")
embed.add_field(name=f"{i}: {temp.name}", value=f"MMR: {tempmmr}\n Rank: {temprank}\n Win Ratio "
f"{round(tempwin / temploss, 2)}", inline=False)
print(f"0.7 = {x}")
i += 1
print(f"0.8 {i}= {x}")
except:
pass
if i == 11:
await ctx.channel.send('i=11')
break
only 1 embed field is being printed out?
and i only = 2 on the 10th iteration of the for loop
I'm having some trouble adding text colour to embed and keeping it all on the same line.
if green in newone: green1 = '$' + currentprice + '** '+ change + '**'"```css\n"+ newone + "```" embedVar = discord.Embed(title=f"{companyname}", description=f"{green1}" f'{volume}''% from NHOD', color=0x00ff00)
The {newone} correctly gets turned green, but it's put on a different line when I want it all on the same line. I believe it's because the \n added to css\n"+ newone +"... the problem is, as far as I know, you need to add \n if you want to change colour.
I want the green text to be on the same line
You can't.
whats the best way to reload cogs?
Unload and load again
That's a shame
That's how code blocks work
Is there an alternative way to changing text colours in embed that would allow me to put it on the same line?
No

You could always just put everything in the codeblock
Just have the whole line green text? I suppose so. Is there a way to make green text bold and not bold on the same line?
What's the difference?
I’m on mobile, is the text before the - highlighted? I can’t remember if it does that```diff
Text -decrease
No
does bot.reload_extension() not work?
Unloading it and loading it again is what it does
ah kk
when using bot.reload_extension() what do i need to feed it? just the cog name?
What to do? Interaction error!
Code:
https://media.discordapp.net/attachments/343944376055103488/917823921200443413/unknown.png?width=299&height=138
# Выдача ролей при помощи select menu
@bot.command()
async def rolesp(ctx):
await ctx.channel.purge(limit=1)
give_roles = discord.Embed(
title = 'Автоматическая выдача ролей',
description = '**Вы можете самостоятельно получить роль выбрав ее название в меню. \
\n При выборе своей гендерной роли вы будете выделяться ее цветом. \
\n Роли доступные для получения в данный момент:** \
\n:female_sign: — <@&864246807353884722>\n:male_sign: — <@&864246881667383336>',
color = 0x36393E,)
give_roles.set_thumbnail(url='https://media.discordapp.net/attachments/865681789493051423/917820894234169454/static.png?width=172&height=172')
give_roles.set_footer(text=':zap:Cascade:zap:')
await ctx.send(
embed=give_roles,
components = [
SelectMenu(
placeholder = "Выберите гендерную роль",
options = [
SelectOption(label = "Девушка", value = "Девушка:female_sign:", description = "Вы получите гендерную роль женского пола!", emoji = ':female_sign:'),
SelectOption(label = "Парень", value = "Парень:male_sign:", description = "Вы получите гендерную роль мужского пола!", emoji = ':male_sign:'),
]
)
]
)
interaction = await bot.wait_for("select_option")
# member = ctx.member()
# await member.add_roles(interaction.values[0])
await interaction.send(content=f"Роль {interaction.values[0]} была вадана!", embed=embeds)
bot.run(TOKEN) ```
help pls
help
error: ```py
C:\Users\HiTech\Desktop>python hhh.py
Traceback (most recent call last):
File "C:\Users\HiTech\Desktop\hhh.py", line 2053, in <module>
from discord import ui
ImportError: cannot import name 'ui' from 'discord' (C:\Users\HiTech\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_init_.py)
even tho i have dpy 2.0
https://cdn.discordapp.com/attachments/381965515721146390/917843491407663105/unknown.png
yea it is, im trying to use a for loop to get only the name part but it wont let me open the file
!d json.loads
json.loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)```
Deserialize *s* (a [`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") or [`bytearray`](https://docs.python.org/3/library/stdtypes.html#bytearray "bytearray") instance containing a JSON document) to a Python object using this [conversion table](https://docs.python.org/3/library/json.html#json-to-py-table).
The other arguments have the same meaning as in [`load()`](https://docs.python.org/3/library/json.html#json.load "json.load").
If the data being deserialized is not a valid JSON document, a [`JSONDecodeError`](https://docs.python.org/3/library/json.html#json.JSONDecodeError "json.JSONDecodeError") will be raised.
Changed in version 3.6: *s* can now be of type [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") or [`bytearray`](https://docs.python.org/3/library/stdtypes.html#bytearray "bytearray"). The input encoding should be UTF-8, UTF-16 or UTF-32.
Changed in version 3.9: The keyword argument *encoding* has been removed.
returns list ig?
waiting for another newbie to post their token here
that doesn't happen usually
:(
hey guys what's your token, lemme know so I can promote your bots on my new website
👍
Wait what
Wym
How can I check if any word in a string is in a message?
Bet
if keyword in message.content
that would actually need a for loop
a list? I know it uses any, but how?
any word in a string in a string
No?
that's what he said
They just wanna check a single word
no
a word in a list
Ohhh
nws
if word in message.content:```
how do you use any for that?
I was dumb
My bad
that would be something like
if any(word in message.content for word in my_string)
no?
ODAwOTc4NTQyMjI1MzkxNjU2.YAZQ.r-9fRpJ-dbZmN4T
lmao
thank you
I had it the wrong way round xD
That's a fingerprint not a token
I'm not sure about that statement bruther
?
I know more about the dpy library than normal py
Same
No just misread it
I tried working on a mass DM bot, failed horrendously
🤣
Creating discord accounts and getting tokens from them within the script
wait what
that would be interesting
even tho I didn't understand that
is that against ToS?
👀
Absolutely
fawk
Haha
It won't even work cause discord now locks tokens. You can't get them
I learned it all
I mean how it works
Ig delete it before a mod deletes it
It doesn't work neither is going to work
Okay
0x2ecc71 what is the color type of this and are there any color picker extensions that help with this color type?
It’s a hex color code
Just look up color picker on google and you’ll find a nice tool
html color codes is a website
Heres a list of them you can .bm if you want:
default = 0
teal = 0x1abc9c
dark_teal = 0x11806a
green = 0x2ecc71
dark_green = 0x1f8b4c
blue = 0x3498db
dark_blue = 0x206694
purple = 0x9b59b6
dark_purple = 0x71368a
magenta = 0xe91e63
dark_magenta = 0xad1457
gold = 0xf1c40f
dark_gold = 0xc27c0e
orange = 0xe67e22
dark_orange = 0xa84300
red = 0xe74c3c
dark_red = 0x992d22
lighter_grey = 0x95a5a6
dark_grey = 0x607d8b
light_grey = 0x979c9f
It’s not necessarily HTML color codes, they’re just hexadecimal representations of RGB that can be used in websites
ty
#fcba03 so should i edit it to 0xfcba03 to make it work in python?
What is the best way to create a handler for dropped messages eg connection issues for a bot? Say if there is a momentary lapse, send a retry rather than leaving the task unresolved?
The issue I am facing at present is that I have a script sending messages on an interval but if it encounters a connection issue it simply stops like dropping the ball while juggling rather than having an error that can be excepted and handled
Is it possible to have custom presence activity? Instead of the default watching, straming, listening .etc
so i have something like
role = message.guild.get_role(id)
await ctx.author.add_roles(role)``` but i dont know if ive done the right attributes 😬
No bots dont have access to custom statuses
member.activity.ActivityType.custom
well technicallyyyy

See they dont
ActivityType.custom is an str of member.activity.type
@maiden fable bots dont have access to custom statuses right?
hi guys
i mean what i can imaging would be something like
f'{member.activity.type}'.replace("ActivityType.custom", f'{member.activity.name}')
i love python & discord.py & joelang
@slate swan ^^
is it possible ?? 😄
Afaik no
just use this
await bot.change_presence(
activity=discord.Activity(type=discord.ActivityType.custom, name='XXXX'))
it works fine for me lol
OHHH to put custom status on a bot
well no not that i know of
What were you thinking
getting members status 
Yeah i figured
Because bots cant access statuses
how can i see the data/message type from a bot, e.g. card game bot when it shows u a random card?
Thanks for the quick reply guys 🙂
having an issue with my verification
@bot.command()
async def verify(ctx):
def check(m):
return m.author.id == ctx.author.id
msg = await bot.wait_for('message', check=check)
role = message.guild.get_role(917654915311099944)
embed = discord.Embed(title=f'Verification', description=f'You have `1` attempt to verify. If you fail, you may be re-evaluated by executing the command again', color=clr)
failbed = discord.Embed(title=f'Verification', description=f'You have failed the verification process! Please try again', color=clr)
passbed = discord.Embed(title=f'Verification', description=f'You have passed the verification process! Enjoy your stay', color=clr)
captcha = random.randint(1, 4)
if captcha == '1':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283179843452970/wickCaptcha.png')
await ctx.send(embed=embed)
if msg.content == 'KZEXEH':
await ctx.send(embed=passbed)
await ctx.author.add_roles(role)
else:
await ctx.send(embed=failbed)
elif captcha == '2':
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283141130006578/wickCaptcha.png')
await ctx.send(embed=embed)
if msg.content == 'SXOXMM':
await ctx.send(embed=passbed)
await ctx.author.add_roles(role)
else:
await ctx.send(embed=failbed)```
not sure if ive used the right attributes for `get_role()`
for starters you are checking if captcha is equal to a string when it is actually an int
not necessarily an error but you are using f-strings when they are not needed
Can anyone give pointers or help
on creating a channel with a command but only allowing the author to use it
create channel then set channel permission
Can you send the docs for the permission part please
i always use f strings, ive never seen reason not to cuz it never really causes issues when i dont, unless im using things like .join or .replace or .format ect
f strings is fantastic
there's no point in using f-strings if you are not formatting them
just use a regular string literal

well then, considering i get no errors, lets not focus on something thats not actually going to affect the outcome. is message.guild.get_role and ctx.author.add_roles the right way to go about it
iirc message.guild.get_role does not exist
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
when you hover over text, how can you add more text?
ok i was wrong
so would it be ctx.guild or just straight up discord.Guild... considering its not invoked
discord.Guild is the class itself, you want the instance of it, E.g ctx.guild
that's a timestamp
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
oh, but how do you make it so when you hover over
look at the link
eh
If you're using discord.py v2.0.0a you can use format_dt as well
!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.9)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
cl(ear) [filename:lineno | bpnumber ...]```
With a *filename:lineno* argument, clear all the breakpoints at this line. With a space separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation).
role = ctx.guild.get_role(917654915311099944)
await member.add_roles(role)```
`AttributeError: 'NoneType' object has no attribute 'id'`
on line 2^
Does anyone know how I can make my bot use emojis that require nitro on any server?
get_role is returning None
For roles though, I usually find it easier just to use snowflakes
await member.add_roles(discord.Object(917654915311099944))
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
you need to use the full package name
How would I set the permission
to make the author of the command to be able to read the channel
Use the delete_after kwarg on the send() method
await channel.send("message", delete_after=15)
me^
just a simple question, if i get a bad request 400 from sending a message and it says invalid body form not snowflake or something like that, does that mean that the message is over 2000 characters?
It could also mean that something else in your request body isn't correct
'Bot' object has no attribute 'send_message'
anyone know why im getting this error code?
Show code
async def help(ctx):
author = ctx.message.author
embed = discord.Embed(
colour=discord.Colour.orange()
)
embed.set_author(name='Help')
embed.add_field(name='ban', value='Bans someone!', inline=False)
await bot.send_message(author, embed=embed)```
How do I save the channel ID
Or just ctx.author
Where the command is used
send_message is deprecated in discord.py
https://discordpy.readthedocs.io/en/stable/migrating.html#sending-messages
Try this
ive switched over to await member.add_roles(discord.Object(917883065362161684)) but now it says unknown role, yes the role exists, yes the bot has perms in the server the roles from, yes its the right role id
i cant find it in the docs
is it
what did it change to
channel.delete?
This was a while ago. If you're following a tutorial, it might be old
how can u define a specific person to .mention
No need
You can try this
Or ctx.author
Or declare a variable for ctx author
member objects have a send method as well
await bot.send_message(author, embed=embed)
That is deprecated, use the send method
await author.send(embed=embed)
what is the equivalent of self.bot.owner.mention, but for any specific member
member.mention
in disnake?
the send_message method is not the send method

member.mention doesnt work
can you send your code?
@bot.command()
@commands.is_owner()
async def oops(ctx, *args):
channel = bot.get_channel(ID)
await channel.send(f"{member.mention} {args}")
await ctx.send("Sent!")
Is it possible to read the content of a hidden message?
u mean one with spoilers?
I mean only one you can see
confused by what u mean on that but seems possible if u can access it
ephemeral messages?
I attached a button to it, need to read its title
As ctx.origin_message & ctx.message returns none
What are you trying to do?
what command are they using to make the title
still got no fuckin idea on this btw
you never define he member variable. Who are you trying to mention?
Then you need to get a member object, and get the mention attribute of it
What member are you mentioning?
How are you getting the ID?
Disregard my question, found another way
its a specifc ID that I'd rather not share so ppl here dont go bugging that person
ID is the same each time
Oh, then you don't really need to fetch a member object, just write the mention yourself
f"@pastel pike {args}"
yes, 0x always denoted a hexadecimal number following it, be it a color code or some other hex number
thats what I said
Ty
HAI ROBIN

I can get your ID, but I cant bug you with that ID
||or maybe I could||
I mean u could send friend requests to that person etc
Problem with this is that sometimes it's <@ID> and sometimes it's <@!ID> so I prefer to get the member object so you can have that abstracted away from you
@596428514895593472 (args)
thats what it returns
trying to use await member.add_roles(discord.Object(917883065362161684)) but now it says unknown role, yes the role exists, yes the bot has perms in the server the roles from, yes its the right role id. ive defined member as ctx.author, discord.Member was not invoked however, just ctx.
or ill try again
https://stackoverflow.com/questions/53026087/how-to-get-id-of-a-mentioned-user-discord-py you can try this
just use guild.get_role(id)
how do u get member object
add_roles takes in a discord.Role not a Snowflake
or maybe not
do i just put guild or ctx.guild
bot.get_member(id)
bot.get_user(id)
guild.get_member(id)
and probably many other ways to do so
right
The ! just tells discord wether to show the mention with a nickname or not, it dosen't affect the actual mention
@sick birch <- Without
@sick birch <- With !
hm i see
How do I delete the channel where the command is used

hmm
as long as it mentions who cares haha
Oh well, that's just what they say in the docs
ctx.message.channel.delete()
or is it just ctx.channel.delete()
just that
nice, note it's a coro so await it
member = ctx.author.id
guild = ctx.guild
print(member)
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
member: discord.PermissionOverwrite(read_messages=True),
}
channel = await guild.create_text_channel(f"{str(member)}", overwrites=overwrites)```
trying to do this but I get this
AttributeError: 'int' object has no attribute 'id'
that's just discord
can you send the full error?
Traceback (most recent call last):
File "C:\Users\fish\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\fish\Desktop\..\test.py", line 29, in create
channel = await guild.create_text_channel(f"{str(member)}", overwrites=overwrites)
File "C:\Users\fish\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\guild.py", line 948, in create_text_channel
data = await self._create_channel(name, overwrites, ChannelType.text, category, reason=reason, **options)
File "C:\Users\fish\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\guild.py", line 844, in _create_channel
'id': target.id
AttributeError: 'int' object has no attribute 'id'
ah
trying to make a channel but the name of it with there ID
the member key in the overwrites dict has to be a discord.Member object, not an int
Assigning roles using the select menu. How? My initial code, how do I make it give out the selected role in the select menu?
async def rolesp(ctx):
await ctx.channel.purge(limit=1)
give_roles = discord.Embed(
title = 'Автоматическая выдача ролей',
description = '**Вы можете самостоятельно получить роль выбрав ее название в меню. \
\n При выборе своей гендерной роли вы будете выделяться ее цветом. \
\n Роли доступные для получения в данный момент:** \
\n ♀ — <@&864246807353884722>\n ♂ — <@&864246881667383336>',
color = 0x36393E,)
give_roles.set_footer(text='CASCADE')
await ctx.send(
embed=give_roles,
components = [
SelectMenu(
placeholder = "Выберите гендерную роль",
options = [
SelectOption(label = "Девушка", value = "Девушка♀", description = "Вы получите гендерную роль женского пола!", emoji = '♀'),
SelectOption(label = "Парень", value = "Парень♂", description = "Вы получите гендерную роль мужского пола!", emoji = '♂'),
]
)
]
) ```
so then I can have a delete command where it only works if the channel is there ID name
You get me?
Yeah i see what you mean
though there's no reason to make a seperate member variable
ctx.author provides you with one
str(ctx.author.id) should be the channel name, in your case the user's ID would be the channel name
ctx.author.id: discord.PermissionOverwrite(read_messages=True),
}
channel = await guild.create_text_channel(f"{ctx.author.id}", overwrites=overwrites)
like that?
then inside your overwrites, instead of having member: ... you should have ctx.author: ...
mmhm
help me pls
I dont know..
testing now 😄
still won't work until you fix the overwrites
What is wrong with them
this
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
ctx.author.id: discord.PermissionOverwrite(read_messages=True),
}
channel = await guild.create_text_channel(f"{ctx.author.id}", overwrites=overwrites)
ah
overwrites should have a discord.Role or discord.Member key, and have a discord.PermissionOverwrite as their value
it worked!!
awesome!
How would I get around with deleting a channel with its name
using discord.utils.get(...)
channel = discord.utils.get(ctx.guild.channels, name=given_name)
Then name would be ctx.author.id?
Are you trying to delete the channel you just created?
how can we separate commands into different files?
Using cogs?
extensions
Extensions?
that's what they're called yes
!d discord.ext.commands.Cog
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
channel = discord.utils.get(ctx.guild.channels, name=ctx.author.id)
await channel.delete()
returns AttributeError: 'NoneType' object has no attribute 'delete'
ah ok Thanks
probably means it didn't find the channel
Unless you are talking about load_extensions
try str(ctx.author.id)
That worked holy this channel is a blessing haha thank you so much
Why are you even doing utils.get?

You have the channel just barely created assigned to channel already,
Just do await channel.delete()
Unless you are deleting in a different command
^
How would I catch the error this creates channel = discord.utils.get(ctx.guild.channels, name=str(ctx.author.id))
if the channel does not exist?
That works, thank you
You used golang error handling? shit is a dream
await member.add_roles(ctx.guild.get_role(917883065362161684)), failed, AttributeError: 'NoneType' object has no attribute 'id'
Role does not exist
it does
917883065362161684
thats the role id, freshly copied
from the role itself :/
maybe the member does not exist
AttributeError: 'int' object has no attribute 'add_roles'
do str(ctx.author.id)
Are you sure the role is in the same guild the command was invoked in?
And maybe the role isn't cached
you might need to fetch
nothing happens
not discord.Guild, discord.Role, nor discord.Member were invoked. that would have to make me pass them as arguments and considering im using a verification command arguments are the last thing i need
I need some help 😳
???
wth
whats the issue
DMS
just send it here
It won't let me
!paste
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.
The command, it was invoked in order to have ctx
so whats the problem
Unless your not in a command, if so I must've been confused
so i have to invoke them?
go look at it
Well, you already have ctx, so you must've invoked the command
lmao if u cant help me, i cant help you
learn python, thats your best bet
You already invoked the command, I'm just saying if your sure the guild where you invoked the command, E.g !command has the role
Otherwise, it may or may not be cached, so you would need to fetch
would it help if you saw the source?
No, I can already tell the problem is because either those two things I said
get_role returns None if not found inside of the internal roles cache of the guild
the role exists though
and that is infact the correct id
So then it isn't cached
ive tripple checked
probably not cached like he said
ok what about this then
member = ctx.author
role = ctx.guild.get_role(917883065362161684)
await member.add_roles(role)```
it is just not staying online
not in the cache then
Your'e not changing anything here with what you had earlier
not a problem with the cog
Can you print ctx.guild.roles and show us the output
how do i cache it
fetch it
wdym?
omg. learn python dude im not gonna rewite your whole bot
Sad part is discord seems to have no endpoint to fetch a specific role? Only all of the roles per guild
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
is there any way i can add the role via name?
ah, i thought fetch_role was a thing
too much to ask haha
First can you print out ctx.guild.roles and see if you can see the role in there
its there omg, look ill show you
I'm not saying if its there or if it isnt there, nor trying to disprove you
I simply want to see what discord thinks
You still haven't printed out the roles of the guild
roles: [<Role id=890306563565305866 name='@everyone'>, <Role id=917231994251927653 name='Quarantine'>, <Role id=917231993593421905 name='Muted'>, <Role id=917284127701598250 name='Member'>, <Role id=917226561697103972 name='Bots'>, <Role id=917285027421769749 name='Crew'>, <Role id=917284786471596035 name='Staff'>, <Role id=917134314091728907 name='Developer'>, <Role id=917134069953855539 name='Owner'>, <Role id=890319379919691848 name='Acrella'>, <Role id=917226385171419167 name='Wick'>, <Role id=890319185580793927 name='*'>]
the role would be Member role
so this.. 917284127701598250
@slate swan Invite me to ur server Ima test it out
That should work
new problem, i get timeout errors ¯_(ツ)_/¯
@bot.command()
async def verify(ctx):
member = ctx.author.id
def check(m):
return m.author.id == ctx.author
role = ctx.guild.get_role(917284127701598250)
embed = discord.Embed(title=f'Verification', description=f'You have `1` attempt to verify. If you fail, you may be re-evaluated by executing the command again', color=clr)
failbed = discord.Embed(title=f'Verification', description=f'You have failed the verification process! Please try again', color=clr)
passbed = discord.Embed(title=f'Verification', description=f'You have passed the verification process! Enjoy your stay', color=clr)
captcha = random.randint(1, 4)
print(f"roles: {ctx.guild.roles}")
print('worked3.0')
if captcha == 1:
print('worked3.1')
embed.set_image(url=f'https://cdn.discordapp.com/attachments/910579746205745283/917283179843452970/wickCaptcha.png')
await ctx.send(embed=embed)
msg = await bot.wait_for('message', check=check, timeout = 15)
if msg.content == 'KZEXEH':
await ctx.send(embed=passbed)
await member.add_roles(role)
else:
await ctx.send(embed=failbed)```
output:
worked3.0
worked3.1
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TimeoutError: ```
tried thrice
m.author == ctx.author
check your check. - no pun intended
idiot ¯_(ツ)_/¯
Who?
me 
I dunno
You fixed the problem with your bot?
I keep forgeting how to start it up
Send me the main file, the one containing the run for your client
Don't include TOKEN!!
Worked?
trying it lol
role = ctx.guild.get_role(917284127701598250)
await member.add_roles(role)```
`AttributeError: 'int' object has no attribute 'add_roles'`

add_role isnt it
Nah
member = ctx.author.id
That is clearly an integer.
Your variable member is now an int containing the ID of the ctx.author
Which means... 'int' object has no attribute 'add_roles'
its author.id 😭
ima try it
https://oml.wtf/kWu1vt19 god bless lol
that took me way too long
You just needed another view...
me? 😳 (sorry I have some bad memory)
Only if you want me to help you, because I believe you mentioned that your bot is not working.
Meaning I need the main file containing the run for your client
bet
just dont include token...
Dms?
I don’t do DMs, just send it here
A custom help command ? You should watch some videos online on it— it can get pretty hard depending on how complex you want it to be
1 sec
Hey @slate swan!
It looks like you tried to attach file type(s) that we do not allow (.zip). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
!paste
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.
uhhh there is alot of coding.
You only need to send the relevant part, E.g the starting code
Trust me.
The whole issue is you forgetting how the start the bot is it not?
that seems quite simple
I saw how the python bot ran code in discord after a command, how could I replicate that in my own bot
not asking for the code to be handed to me necessarily just want to be pointed in the right direction as I cant find results online.
Here. I cannot
Discord.py commands extension has a built in help command, you need to remove that before setting your own
In your bot's constructor, E.g commands.Bot(...)
You can pass help_command=None
And to make the help command I recommend subclassing the HelpCommand class
!customhelp
Custom help commands in discord.py
To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000
Heres a guide you can read
client = commands.Bot(command_prefix='!', help_command=None) ```
I will give you some sources that helps.
https://www.youtube.com/watch?v=6-SawgAtiro
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=help_command#discord.ext.commands.HelpCommand
In this video, we learn how to use the built in help command and create our own custom version of it.
If you have any suggestions for future videos, leave it in the comments below.
GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/
OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN...
That removes the help command, he wants to customize it.
main.py is the only file I need to help you fix the issue
Is it possible to do ctx.channel.history(limit=10) instead of channel.history(limit=10)
so that i don't have to manually enter the channel object
it should
okay
import os
from keep_alive import keep_alive
from discord.ext import commands
bot = commands.Bot(
command_prefix="TN",
case_insensitive=True
)
bot.author_id = 795811559456768010
@bot.event
async def on_ready():
print("I'm in")
print(bot.user)
extensions = [
'cogs.cog_example'
]
if __name__ == '__main__':
for extension in extensions:
bot.load_extension(extension)
keep_alive()
token = os.environ.get("DISCORD_BOT_SECRET")
bot.run(token) ```
There is Main.py
And the problem is your bot is not running correct?
Like at all.. it doesn't even start?
Yea.
Does it print ("I'm in") on console?
So you are not processing commands, thats the problem.
Commands don't work at all right?
yea.
your variable name should not be tuple, as that is a type.
also worked on the README.md file, So, it came out as,
# TNLmusic
Hi there! Name's TNLmusic I am a 14 Year Old Developer
### Music
I create music and put them on spotify.
### TNbot
TNbot is an In Progress Discord bot Created By, TNLmusic#5027
### End
Have a great day!```
and that works.
OH FUCK
I JUST REALIZED
I GOTTA GO FIX IT
Is this a typehint you have somewhere
Ok, so maybe your python is a lower version that doesn't support typehinting like that
Or you can just do, ```py
from future import annotations
This will turn all annotations into strings
are there any major differences between hikari and pycord?
HIkari is it's own discord API wrapper, pycord is a fork of discord.py
anybody have ideas for a bot?
Hey I got an issue with pip?
Pretty much, I'm tryna install disnake, a fork of discord.py and whenever I run pip install disnake it throws an error that says this:
ERROR: Failed building wheel for yarl
Failed to build multidict yarl
ERROR: Could not build wheels for multidict, yarl, which is required to install pyproject.toml-based projects
There's a bunch more text above it but idk what it is, it's red and says stuff like:
running build_ext
building 'yarl._quoting_c' extension
creating build/temp.linux-aarch64-3.10
creating build/temp.linux-aarch64-3.10/yarl
aarch64-linux-android-clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fstack-protector-strong -O3 -fstack-protector-strong -O3 -fPIC -I/data/data/com.termux/files/usr/include/python3.10 -c yarl/_quoting_c.c -o build/temp.linux-aarch64-3.10/yarl/_quoting_c.o
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang": cannot locate symbol "__emutls_get_address" referenced by "/data/data/com.termux/files/usr/lib/libclang-cpp.so"...
error: command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed with exit code 1
``` for example.
I can install packages that aren't this, but anything discord related doesn't install. Anyone know a fix?
I asked in [#help-bagel](/guild/267624335836053506/channel/696840434462228480/) and got nothing.
Hmm, a joke bot maybe?
Make a bot with lefi
try deleting dpy and installing disnake idk if its gonna work i just know that its not recommended having dpy and disnake bot downloaded
🧠
I don't have dpy installed, because it gives the same errors.
release it thats what you should do
is it fully released?
Try pip install --upgrade pip
No, it's under alpha but it has some converters now
Allowing for a bot to work at the very least normally
I'm talking about the commands ext*
I did, still didn't work
You upgraded pip then tried pip installing disnake?
How are you invoking pip?
Wdum?
🧍♂️
python -m pip ...?
@commands.command()
async def play(self, ctx, *, url):
player = await YTDLSource.from_url(url, loop=self.client.loop, stream=True)
ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
play1 = discord.Embed(title=">>> MUSIC 🎵", description="► Now playing: {}")
play1.timestamp = datetime.datetime.utcnow()
play1.set_footer(text="☆ Creator LL#0884 ☆")
await ctx.reply(embed=play1)
await ctx.reply('Now playing: {}'.format(player.title))
@play.before_invoke
async def ensure_voice(self, ctx):
if ctx.voice_client is None:
if ctx.author.voice:
await ctx.author.voice.channel.connect()
else:
play2 = discord.Embed(title=">>> MUSIC 🎵", description="► You are not connected \nto a voice channel.")
play2.timestamp = datetime.datetime.utcnow()
play2.set_footer(text="☆ Creator LL#0884 ☆")
await ctx.reply(embed=play2)
raise commands.CommandError("Author not connected to a voice channel.")
elif ctx.voice_client.is_playing():
ctx.voice_client.stop()
Any who xan help my play command dont work
pip install disnake
Try python -m pip install disnake
What's your python version?
Maybe its an andriod specific issue?
I'm running arch linux as my main driver and I'm installing packages fine
I'm able to install other packages fine
Like I can install something like python-dateutil perfectly fine
^
A joke bot? Like a bot that tells jokes?
Useless
Not exactly, some people would use it
Not really....
Have a bot that communicates to a SQL database to store data such as XP for example
Have a bot which you can interact with on a website. E.g send a message on the website, and the bot output it in a channel. Obviously this can expand way more into a "hub" of sorts
Nah not really related to my bot
Good idea tho
So you mean commands?
Ig so
- games
- image manipulation
- Reddit scraper (e.g get random post in subreddit)
What do you mean on the second option and ive dine 3rd with asyncpraw
For example, doing a custom rank card
So doing ?rank would output that
The image manipulation is placing the avatar on the image
Or applying a filter to an avatar, etc
Oh lol
Hi
why is the Member not disconnected when they are deafened?
@bot.command()
async def isDeafen(ctx,member: discord.Member):
if(member.voice.self_deaf):
await member.disconnect()
AttributeError: 'Member' object has no attribute 'disconnect'
but I can't find any other function to disconnect a member.
https://discordpy.readthedocs.io/en/stable/api.html?highlight=edit#discord.Member.edit
Changed in version 1.1: Can now pass None to voice_channel to kick a member from voice.
await member.edit(voice_channel=None)
that makes more sense, I had another command where it would mess up and move the user to None and they would get disconnected.
thank you
trying to make my first slash command bot but upon inviting to my server the slash commands arent showing up. im guessing this is a common thing but i dont see anything because I'm using the applications.commands scope and I verified that my cog is being loaded in the bot
I used the example straight out of https://github.com/goverfl0w/discord-interactions except that I put cog in cogs/cog.py and loaded it with bot.load_extension("cogs.cog")
hm, based on the library's quickstart looks like the github is maybe outdated
Hello, is there a way to download all messages in a channel?
What's the field code?
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = client.get_channel(885464532959526913)
Myembed = discord.Embed(title= f"Welcome",
description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)")
Myembed.add_field(name = 'Account created:', value= {member.created_at} inline = True)
await channel.send(embed=Myembed)
roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
for roles in roles_list:
role = discord.utils.get(member.guild.roles, name=roles)
await member.add_roles(role)
```
could someone tell me where i can find the docs for slash commands
My bot uses MySQL is it possible to store such data like an entire channel message history on there?
best error 2021
what lib are you using
try not putting the description kwarg in another parenthessi
How do i make it say like this?
dw it works like this
hm
like to where itll say how many days the member has created the account or month or year
<t:37322662> this?
!d discord.Member.created_at
property created_at```
Equivalent to [`User.created_at`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.created_at "discord.User.created_at")
why not
i dont like it like that
^
or maybe ill put that in another embed field
i mean <t:1995535233:R> looks cool
🤣
replit being replit
just another normal day in replit
nice
yes thats what i was trying
to get out off
No but u did month day year and time
just use what i said earlier and use the timestamp attribute
@jade tartan
No but i want the same as this one
using this function
@bot.event
async def on_message(message):
if message.author.id == 890318171817537577:
return
purgeChannel = bot.get_channel(917289006335680592)
await purgeChannel.purge(limit=1, check=checkk)
await bot.process_commands(message)```how can i prevent the bot from deleting its own messages?
:D
how do i make one of these
!d discord.Member.created_at convert it
property created_at```
Equivalent to [`User.created_at`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.created_at "discord.User.created_at")
epoch timestamp
check if the author is the bot
cringe variable names
ig
property created_at: datetime```
Returns the user’s creation time in UTC.
This is when the user’s Discord account was created.
:D
i wanna do
if user type 'rpm area 1'
area = 1
if user type 'rpm area 2'
area = 2
if user type 'rpm area 3'
area = 3
how do i do
i need bot.group() one by one?
it is
They do
in the check, make it so that it returns False if the author is the bot
async def abc(ctx):
#can i do class here? i wanna do dropdown
#dpy 2.0
Are you sure?didnt they not have access to it and only have watching listen and others?
you can define a class inside a function however its not recommended, dont do it
but can i do it?
read my message again
!d discord.CustomActivity wanna bet a nitro?
class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.
x == y Checks if two activities are equal.
x != y Checks if two activities are not equal.
hash(x) Returns the activity’s hash.
str(x) Returns the custom status text.
New in version 1.3.
it won't work for buttons and stuff if thats what they're talking about
@boreal ravine Are you sure its User?
You that broke you need nitro lol
Ill bet you a big mac tho
Hmmm
So your telling me this is possible?in a bot
The activities that the user is currently doing.
Note
Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.
Just loop through them and use isinstance
I sweat a bot couldn't do that
The bot can surely get the status
Myembed.add_field(name="Account Created at:", value=f"{User.created_at(datetime)}", inline=True) Is that right? because it wants me to define User
No i didnt mean get a status i ment the bot setting a custom status
!d discord.User.created_at
property created_at: datetime```
Returns the user’s creation time in UTC.
This is when the user’s Discord account was created.
Ah
how do i add someone to groupchat with discord.py
It can't
Not possible with a bot
Yeah i know lmaooo
Have you defined it?
Tried it, but it doesnt work still
Let's see the code
ok hang on
i wanna do
if user type 'rpm area 1'
area = 1
if user type 'rpm area 2'
area = 2
if user type 'rpm area 3'
area = 3
how do i do
i need bot.group() one by one?
async def on_member_join(member, User):
guild = client.get_guild(730651046459998218)
channel = client.get_channel(885464532959526913)
Myembed = discord.Embed(title= f"Welcome",
description=(f"Welcome {member.mention}, You are member {guild.member_count}. \n Please enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)"))
Myembed.add_field(name="Account Created at:", value=f"{User.created_at(datetime)}", inline=True)
await channel.send(embed=Myembed)
await member.send(embed=Myembed)
roles_list = ["Unverified","•.¸¸.•:Colours:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Verification:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Age:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Gender:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Sexuality:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•:Distance:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Ethnicity:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Hobbies:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Relationship:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Location:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•",
"•.¸¸.•::•.¸¸.•`Seeking`•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:DM:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Levels:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•","•.¸¸.•:Games:•.¸¸.•``•.¸¸.•``•.¸¸.•``•.¸¸.•"]
for roles in roles_list:
role = discord.utils.get(member.guild.roles, name=roles)
await member.add_roles(role)```
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
TypeError: on_member_join() missing 1 required positional argument: 'User'```
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
If you already have member why do you need User?
no? I said member, I was just going along with what you said
How do I make an error handler for key errors?
Like my old handler for another command is
# Handling error if no games are available to leave from
@report.error
async def report_error(ctx, error):
if isinstance(error, commands.CommandInvokeError):
pass
but the error I want to catch is KeyError
^^
just check for a KeyError
like you did with CommandInvokeError error
so is it just error, KeyError?
yes
nothing before KeyError?
to define user in add field
ok cheers
just use member?
Can I put an argument that was in the original command into the error handler
Yea... I said that afterwards. Misunderstood the question
o
you mean like to see what the keyerror was?
Well Im wanting to use the value that gave the keyerror so I can put it in the embed reply
hi, im still new to making discord bots and python in general and I am looking for some help.
I am trying to make a discord bot that will take information from a game's api to list useful information. and to update every few minutes.
I have the basic embed down and stuff but I cant figure out how to show the data from the api the way I want it too.
I basically want to turn data from https://www.toontownrewritten.com/api/fieldoffices to something that looks like this https://cdn.discordapp.com/attachments/884885863048286288/917784613890449568/unknown.png
where I am at currently is I have the data from the api in a variable called myJson. and I can pull information from there fine but its raw data
i just dont know how to make it look much more readable
much more readable*
Hi guys. Please tell me how to implement the command - take the last USER_ID message from the CHANNEL_ID and place it in the current channel?
Wym place in the current channel
so else:
...?
channel.purge
accepts a predicate, if it returnd false, it won't delete the message
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting bot’s messages...
wdym accepts a predicate
you can google that
alright
the checks kwarg
it will pass message to the check iirc
unless the author of the message is the bot, it should return True otherwise False
i wanna do
if user type 'rpm area 1'
area = 1
if user type 'rpm area 2'
area = 2
if user type 'rpm area 3'
area = 3
how do i do
i need bot.group() one by one?
rpm is prefix
make the integer an argument of the area command
how


are you using the commands extension
yes
do you know to make a command with it
im using this one
from discord.ext import commands
yes
i just wanna ask
is there another way instead of
@bot.group()
every argument of the function will be passed the content, the command was invoked with
why do you want to make a group
@bot.command(name = 'profile')
@commands.cooldown(1, 5, commands.BucketType.user)
async def profile(ctx: commands.Context):
here
@bot.command()
async def my_cmd(ctx, arg)
print(arg)
now if I do
my_cmd 1
it will print 1
The name will default to the function name
but is the 1 int or str
if you dont pass the name, it will use the name of the function
oo ok
you can typehint it to int
ok
by default it will be str
ctx: commands.Context has been depreciated is is not needed. ctx will work just fine
ok
arg: int
That method is used to convert something into a int
arg: typing.Union[int, str]
this will first try to convert it to int
and if it fail it will try to convert it to str which will never fail
hmm
Yeah
but i only want the user to type in 1-14
if statements
Now I finally understand how to use Union[]. You learn something every day
so i dont think its necessary
normally its just something to let the IDE know what it does, discord.py powered it
When you say powered it what do you mean by that?
it try to convert it to every type the user passed to Union
i mean one by one
if the current one fails
Discord.py reads the command signature, and its annotations. They do this to internally call the corresponding converters E.g member: discord.Member would call MemberConverter
In normal python typehinting is only for you and other people who may read your code to know what the arg type is expected to be. This can be checked with type checkers such as pyright, mypy... Etc
arg = round(arg)
```this will round off the number to int right?
no
If the arg is a float it would round it off
its the default value
Otherwise if its an int it would be the same
oo ok
where is it?
!e ```py
print(round(1))
print(round(1.5))
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
!e import flask
@sinful barn :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'flask'
was curious
#bot-commands <=
for sure
@bot.command(name = 'area')
@commands.cooldown(1, 5, commands.BucketType.user)
async def area(ctx, arg: int):
userid = ctx.author.id
highestArea = db[userid + 'highestArea']
if 1 <= arg <= 14:
if arg <= highestArea:
db[userid + 'area'] = arg
await ctx.send(f'**{ctx.author.name}** has moved to **AREA {arg}**')
else:
await ctx.send(f'**{ctx.author.name}** fight more bosses :D')
else:
await ctx.send('404 area not found')
Your trying to add userid which is like the error suggests, an int whilst 'area' is a string
That can work yes
🤦
the db must be looking ugly
LOL
my area variable name
757508305256972338area
userid + 'area'
Might be good to change that into something easier to use
!source eval
Run Python code and get the results.
And add ctx.author.id to it?
!source pypi
Provide information about a specific package from PyPI.
#bot-commands
Has pypi got some kind of api?
Oh thanks
Does npm have one too?
No clue, do a google search
Hmm
Anyone who code bots for free dm me
Oof
I can't understand how that is python related
Learn coding yourself
Go on fiverr
what db are you using
json ig
Prob the replit's database
!e
db = {}
db["92828"+"area"] = "huh"
print(db)```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
{'92828area': 'huh'}
^^ replit's db
Json isn't even a database, its a file format
You can use it for stuff like databases though
yeah exactly.
Such as a JSON document database, like mongo
😬
🥶
🥵
yes, JSON is good as a configuration file and what not
why are we all discussing about databases and JSON
because chat ded
Agreed
You can but you should never, it's terribly bad practice and you're probably going to end up losing all your data down the road
?
So, what happens to json document databases such as mongo
🤔
someone sent something earlier, but it got deleted
this isn't #databases
mongo isn't json, sure it's similar but they run completely differently
^
true dat
Mongo uses the JSON format
but it's JSON like anyways
FILE FORMAT
the format/syntax is
is mongo just a better version of json
yes
hmmm
Wdym
it's a full fledged database, while, json is only a file format that wasn't meant for storing persistent data
he means database :_:
🤔
Replit has a db?
Ya
You must've misunderstood what I meant when I said "it could be used for databases"
dang i wonder how terrible it is haha
I was speaking upon the format, E.g json document
nah, i know it can the real question is do you want to
I could've phrased it better
main py
nah its good haha
I mean it's just raw dictionaries but it isn't ephemeral
i only know basic sql and thats it :c
apparently replit's files are ephemeral? at least that's what i've been told
Yes they are
something about system-written changes that disappear after a restart

i guess they made their own database for it
A local database is impossible on replit if you want persistent data
I think that means whatever you use in the shell is ephemeral, everything else isn't
Unless replit's builtin database goes past that
serverless computing i guess
Otherwise the only choice would be a cloud hosted database
i'd assume replit's database is as terrible as their service itself
e
i mean replit isn't terrible; it's the people that use it is terrible
oh dont even get me STARTED
Replit is a fine on the go environment, it isn't good for discord.py although
why do people use replit for bots actually
hiiiiiiiiiiiiiiiiiiii
@client.event
async def on_message(message):
if message.channel == 'suggestions':
channel2 = client.get_channel(883635075743375361)
author = message.author
await channel2.send(message + ' by ' + f"{message.author.mention}")
Can anyone tell me what's wrong with this code?
why do people use replit for anything
for me it doesn't make sense to use replit
yay
its rlly good for bots but not for complex projects
What if I'm mobile and had to do some testing?
What if I didn't have my workstation with me?
lmao
why
i mean u can still do it
but itll prolly be laggy
i suppose you could but i never like to code when i'm not at my workstation
typing code on mobile must be ugh
well u cant make any application or test application for short time use bc replits console isnt complex enough to display those
Only you know, what's the error say?
it uses shared ip, if one guy that uses replit gets ratelimited, everyone else will
You would need a terminal emulator on your phone. Much less effective than just to spin up an online REPL
for me it does
like i m a beginner and need others to review my program
Off the top of my head you're comparing a discord.TextChannel to a string
yeah itll take a lot more to use mobile
okay.. I used replit once - didn't like it - deleted account
use name attribute 2 compare it to a string
also its just a chunk of code from the bot
it could be like smth from the other code thats not being shown
there's no error
just the bot aint posting in the other channel
^^
okk
lines up with what i said
well then theres obv smth wrong with the code then
i'll try that
you're comparing an object to a string
why not do an if message.channel.id ¯_(ツ)_/¯
When comparing two objects its not good practice to use ==, rather you should use is
yep you can have multiple channels with the same name i think
:troll:
!e
class B:
def __str__(self):
return 'B'
if B() == 'B':
print(True)
else:
print(False)
``` this is what your doing ^^

