#discord-bots
1 messages Β· Page 1022 of 1
no
hmm, it's something like this
Bot role
------
Owner
-----
Admin (me)
-----
Vote role (the role that should be added)```
cause im interested in the member_id
a webhook will be triggered
and send their ID to a certain channel
the bot will take that ID and pass it to the function
Sadge i don't work with roles a lot in discord
well i have a decent knowledge about them so that's why i find this very odd
thats really confusing, because with all those conditions you mentioned bot should not face any issue in adding the roles
true, yet here i am facing it
what i am curious about is
it says Missing access instead of missing permissions
i updated my discord.py version to 2.0.0 and i dont think my on_member_update event is working anymore, why is that?-
hmm? mine works fine
send the code please
wait a sec
nvm! it had an error so it didnt work XDD

wait actually what does this mean
TypeError: on_member_update() takes 2 positional arguments but 3 were given
i only did on_member_update(before, after)
is it in a cog?
nope
!d discord.on_member_update
discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.
This is called when one or more of the following things change...
hmm
!d
send the full event
What
What?
what?
q, do you put events in the class in v2.0.0
whts wrong here ?
Traceback (most recent call last):
File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 979, in on_message
await self.process_commands(message)
File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 976, in process_commands
await self.invoke(ctx)
File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 943, in invoke
await ctx.command.dispatch_error(ctx, exc)
File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 422, in dispatch_error
await injected(cog, ctx, error)
File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 77, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: fact_error() takes 2 positional arguments but 3 were given```
```py
@fact.error
async def fact_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
em = discord.Embed(title=f"Slow it down!!",description=f"Try again in {error.retry_after:.2f}s.",color=0x2F3136)
em.add_thumbnail(url='https://cdn.discordapp.com/attachments/969178492002500678/971001114046627900/stopwatch_1.png')
await ctx.send(embed=em)
hmm no
How
idk it wont give any errors and it wont send the message
Is that in a cog?
If so you need to put self in the parameter
they said no
if possible can you send the entire code in the file in a link
ofc hide the token and etc
yes
Add self as the first argument in the parameter
ok
oh then you need to put in the class
it still shows the same error
Show code
@xkcd.error
async def xkcd_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=0x2f3136,title="Invalid Argument",description=f"β’ Please put in a valid option! Example: `{prefix}xkcd <number> `")
em.add_thumbnail(url='https://cdn.discordapp.com/attachments/969178492002500678/971001114046627900/stopwatch_1.png')
await ctx.send(embed=embed)
by mistake
oh okay
still dosent wrk
A different error handler?
fixed it ty
https://paste.pythondiscord.com/udukatokev
it gives an error
Ignoring exception in on_member_update
Traceback (most recent call last):
File "/home/runner/modmail-4-carrd/venv/lib/python3.8/site-packages/discord/client.py", line 375, in _run_event
await coro(*args, **kwargs)
TypeError: on_member_update() takes 2 positional arguments but 3 were given
Self?
its there
discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.
This is called when one or more of the following things change...
2 positional arguments?
Shouldn't it be 3
Since there's self now
Unless that's an outdated error
how do i write the number of text channels?```
!d discord.Guild.text_channels
property text_channels```
A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
!d discord.Guild.text_channels
property text_channels```
A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
thx
And i've started typing after 
I was going to the docs to check if text_channels was right
lol
will this work ?
@xkcd.error
async def xkcd_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=0x2f3136,title="Invalid Argument",description=f"β’ Please put in a valid option! Example: `{prefix}xkcd <number> `")
await ctx.send(embed=embed)
@xkcd.error
async def xkcd_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
embed = discord.Embed(color=0x2f3136,title="Slow it down buddy",description=f" Try again in {error.retry_after:.2f}s")
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/969178492002500678/971001114046627900/stopwatch_1.png')
await ctx.reply(embed=embed)
error for missing argument and error for cooldown
(self, ctx)
remove error

is ActivityType not a thing now on 2.0 ? since
if act := [activity.name for activity in after.activities if activity.type == ActivityType.custom and req_act in activity.name]:
NameError: name 'ActivityType' is not defined
``` it gives this error
how are you importing ActivityType?
wait its supposed to be imported?
from discord import ActivityType
or
discord.ActivityType```
π«
Hi ashley
it does not send missing argument msg it sends the cooldown msg
Make it only 1 error handler
Just make a elif statement
Why do you have 2 error handlers
ok
because u have 2 functions wiht the same name
Been awhile since i seen you here
yes
Hello
When I'm using slash commands it usually works fine, but whenever I try something like this the command either won't load in at all, or the arguments won't show up. Anyone knows why? ```py
@slash_command(guild_ids = ids)
async def add_autorole(self, ctx, role: discord.Option(discord.Role, "Test")):
It used to work in my other bot, I don't know what changed. π€·ββοΈ
Hi, Skev
hey guys anyone know how can i send stickers in discord.py
This is pycord for anyone helping
cant you do it like a normal argument and typehinting rather than using Option
It really looks confusing when it's named discord
@slash_command is inexistent in dpy anyways
!d discord.ext.commands.Context.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
This works similarly to [`send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.
For interaction based contexts this does one of the following...
@gaunt herald
ty
There's a sticker keyword
Yeah but if you don't look at it and see discord.Option first
Gets pretty confusing
That doesn't have like max_input things tho
well, no comments then py-cord is the most hated fork here, idts you'll get much help
so i have to use
await ctx.send(stickers=sticker_id)
?
no who says that, pycord is love pycord is life
you need to get the sticker first iirc
I have no clue but i know you use the stickers keyword
!d discord.Sticker
class discord.Sticker```
Represents a sticker.
New in version 1.6...
!d discord.Client.get_sticker
get_sticker(id, /)```
Returns a guild sticker with the given ID.
New in version 2.0...
ayo i never tough bot could send stickers
Same
ok
I mean the overall view, i love pycord too
Client?
Bot inherits Client, so its pretty much there
Did you just use that to shorten it
Yeah i know
yes cause im not gonna type .ext.commands.Bot
if I make a site not in python, will I be able to manage bot commands from it?
for example in html
Yes, you just need some way of communicating between the site and the bot, for example an API running on the bot
- you have to make your site in HTML, websites can't be written in Python
@commands.command()
async def ping(self, ctx):
embed = discord.Embed(
title="Ping",
description="(url='https://cdn.discordapp.com/avatars/961156905689038878/377996723423ea055fcc9f96e5c80880.webp?size=1024')"
)
embed.add_field(
name=f"**Latency is**",
value=f"``{round(self.bot.latency * 1000)}``**ms**"
)
msg = await ctx.send(embed=embed)
Is this correct?
can be simple on the django library
Means the description one
but thanks anyway
It still produces HTML as output
bot = commands.Bot(command_prefix=getprefix, intents=nextcord.Intents.all())
@bot.event
async def on_ready(bot):
await bot.change_presence(activity=nextcord.Activity(type=nextcord.ActivityType.listening, name=",help"))
print(f'Logged in as {bot.user} (ID: {bot.user.id})')
setattr(bot, "prefixdb", await aiosqlite.connect("prefixes.db"))
async with bot.prefixdb.cursor() as cursor:
await cursor.execute('CREATE TABLE IF NOT EXISTS prefixes (prefix TEXT, guild ID)')
setattr(bot, "afkdb", await aiosqlite.connect("main.db"))
async with bot.afkdb.cursor() as cursor:
await cursor.execute('CREATE TABLE IF NOT EXISTS afk (user INTEGER, guild INTEGER, reason TEXT)')
await cursor.execute('CREATE TABLE IF NOT EXISTS afkrole (role INTEGER, guild INTEGER)')
if not hasattr(bot, 'uptime'):
bot.uptime = nextcord.utils.utcnow()
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Akai\AppData\Local\Programs\Python\Python38\lib\site-packages\nextcord\client.py", line 417, in _run_event
await coro(*args, **kwargs)
TypeError: on_ready() missing 1 required positional argument: 'bot'
but thanks anyway
field
you can set inline=False when adding the field
yes with inline=False
anyone know the docs for attaching a file via ctx
oh sorry I misread, if they're already inline there's nothing you can do to make more on one line
its constrained by the maximum width of the embed
π
^
on ready doesnt take a bot as a parameter
what then
Since it doesn't take bot as a param you need to remove that param from the function definition
r u sure?
yes
use the <a:emoji_name:emoji_id> format
NOTE: Emojis can only be used in the embed description and values of the fields of the embeds
what dont you understand?
I just told you...
Embed(description="<a:emoji_name:emoji_id>")
add_field(name="uwu", value="<a:emoji_name:emoji_id>")
embed.add_field(name=..., value=":emoji:")
does that work for animated emojis huh?
sure.
just use the name of the emoji between colons as sift suggested
you can use the discord.utils.get method ```py
emoji = discord.utils.get(bot.emojis, name="emoji-name")
I use this in one of my cogs since I don't have nitro
+
@commands.command(name='gemoji', description='This Command Returns a list of Emojis for the Guild(Server) it is Run within.')
async def gemoji(self, ctx, optional_arg: int = None):
guild = int
print(f"Guild output before check ++ {guild}",tag='Debug', tag_color='blue', color='cyan')
if guild == None:
guild = ctx.get_guild()
print(f"Detected None", tag='Debug', tag_color='blue', color='cyan')
ctx.send('Debug: Guild is equal to None', delete_after=5)
await ctx.send(ctx.guild.emojis)
print (ctx.guild.emojis)
You will have to use it in a cog or remove the self and change commands. To bot.
Can ctx.send(file="") attach files via Urls or do I need to have the bot download and attach it via that?
!d discord.Embed.set_author
set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style
chaining.
thx
@commands.command()
async def ping(self, ctx):
embed = discord.Embed(
title="Ping",
embed.set_thumbnail=(url='https://cdn.discordapp.com/avatars/961156905689038878/377996723423ea055fcc9f96e5c80880.webp?size=1024')
)
embed.add_field(
name=f"**Latency is**",
value=f"``{round(self.bot.latency * 1000)}``**ms**"
)
msg = await ctx.send(embed=embed)
``` is this correct sir? @slate swan
definitely not
Do you want the image to render in the embeds thumbnail or image field?
Hello, how can I import a function ( command ) from a sub-file to the main one? or it doesn't matter?
I was gonna say something but idk what he wants
Thatβs the thumbnail
What for?
I didn't understand, I mean I want to classify different command to different files, like moderation.py will contain mute, ban, timeout ...
Look into cogs
how to change a server logo from the bot?
They're discord.py's implementation of modules
!d discord.Guild.edit
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., afk_channel=..., owner=..., afk_timeout=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the guild.
You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission
to edit the guild...
Because bots can own guilds as well
Thatβs how it transfers ownership to another member
It signifies that all of the arguments are keywords
does anyone know the rate limit for changing server logo?
They donβt usually publish quantitative data on rate limits
Because then people try to get around them
its 30 min
yeah just like how my bots pfp changes every 30 min lmaooo
thanks for helping me on AWS btw
yeah you can still figure it out just by observation
working great
anytime
Mostly just because they are dynamic. Stated before by a developer. If you want to see the ratelimit just read the response headers
is there a way to like give a role to someone from another server to another one like example:
server1: the user will type in a command "give role etc (guild id)"
server2: the member will be given the role from what has been stated from the other server
sure, but the bot has to be in both the servers
yes its in servers and the member aswell
well, you can actually use fetch_guild/get_guild method of the Bot class and get the other guild, then using that Guild object returned, you can use the get_member/fetch_member method on the Guild_object and get a Member object of the member from the other server, then you can use the add_roles/remove_roles method on the Member object to add/remove roles from the Member
The event is also triggered when someone is timed out
thats the stable branch docs, check the master version
@command
async def foo(ctx: commands.Context):
other_server = bot.get_guild(id) or await bot.fetch_guild(id)
member_in_other_server = other_server.get_member(ctx.author.id) or await other_server.fetch_member(ctx.author.id)
await member_in_other_server.add_roles(Role_obj)
@copper gulch an example
hmmm alright thank you
<a:emoji_name:emoji_id:>
emoji = iscord.utils.get(guild.emojis, name="emoji name")
emoji.id
@client.command()
async def giverole(ctx):
userid = ctx.author.id
otherserver = ctx.get_guild(691544501277163591)
roleid = 691548465372725288
await userid.otherserver.add_role(roleid)
ok now im confused xd
I gave you the code
I explained
its alright
D;
Really I don't want to use cogs yet, but as I remember there was a method to load functions
Hi
!d discord.ext.commands.Bot.add_command ?
add_command(command, /)```
Adds a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") into the internal list of commands.
This is usually not called, instead the [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.command "discord.ext.commands.GroupMixin.command") or
[`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.group "discord.ext.commands.GroupMixin.group") shortcut decorators are used instead.
Changed in version 1.4: Raise [`CommandRegistrationError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandRegistrationError "discord.ext.commands.CommandRegistrationError") instead of generic [`ClientException`](https://discordpy.readthedocs.io/en/master/api.html#discord.ClientException "discord.ClientException")...
iscord
New library
same thing
but what i do to load it in main?
import discord as iscord
cna u give me an example?
I tried using it, but it's somehow hard for me xD
Use bot.load_extension("file name")
from discord import commands
@commands.command()
async def haha(ctx):
await ctx.send("haha")
from somefile import haha
bot.add_command(haha)
?
I'll try, thank you all
discord.ext
@slate swan forgive me if its a dumb question.....but how do i get a message π cant find anything in the docs
bot.cache.get_message
or get channel then fetch message
oki thanks
bot.cache? seeing this for the first time
for cached onces, for others you need to make an fetch req
Itβs hikari
uh
and bot.rest.fetch_message for api req wise
ah k
um
ah thanks a lot, was gonna cry cz I couldnt find that too lol, anyways, tysm uwu sarthak
ew
lightbulb
they using lb iirc
no one uses tanjun ;-;
@client.command()
async def giverole(ctx):
otherserver = await client.fetch_guild(744550186998562937)
userid = await otherserver.fetch_member(466528033638055936)
roleid = 744784021783052429
print(userid)
await userid.add_roles(roleid)
error:
Command raised an exception: AttributeError: 'int' object has no attribute 'id'
get the role with roleid
yeah, if you want to make you already stressful hikari code more stressful, use tanjun
oh
lmao
get the role
i remember when lightbulb used to be same as discord.py
π
I'm low-key liking hikari with lightbulb than dpy and its forks π
uh what's lightbulb? π‘
otherserver.get_role(roleid?)
!pip hikari-lightbulb
yes
I remember that too. I asked thommo or whatever his name is if he took inspiration
command handler for hikari, kinda similar to .ext.commands
but save it to a var
No
yes?
yeah thommo
and yes the handler was made based on discord.py's ext.commands
Nvmd
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
Changed in version 2.0: `role_id` parameter is now positional-only.
!d datetime.datetime.strptime
Lol
classmethod datetime.strptime(date_string, format)```
Return a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") corresponding to *date\_string*, parsed according to *format*.
This is equivalent to:
```py
datetime(*(time.strptime(date_string, format)[0:6]))
``` [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") is raised if the date\_string and format canβt be parsed by [`time.strptime()`](https://docs.python.org/3/library/time.html#time.strptime "time.strptime") or if it returns a value which isnβt a time tuple. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
Thatβs probably why you set in so fast since you were already used to dpy sarthak
Delay
When I learned tanjun it was just so different. How converters worked. How arguments are supposed to be added. Plug-ins/modules
why would u sue a function 

well i started using the library and lowkey liked it before discord,py was shut down
π
pls laugh π
π
this emoji always reminds me of Hunter rather I think of his face as this emoji
cause u never saw his face
right
..
my github is empty π
mine's shitposted
sameeee
What the names
all names have been derived from animes and anime characters except two
Yes
cs project
and Bobert
Pokemare rip
thats a fork idk if that counts
Nightmare + pokemon = PokeMare
In my github I started a website in which I recreated windows 7 on brow
But I stop it
After I started my dc bot
If u don't mind can u show me SelectVeiw class
Just edit the message and pass None for the view kwarg
discord.Client, any idea what this is?
Idk on what condition you want it to remove the select menu.
It's the base Client for Discord.py
!d discord.Client
class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord.
This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
Ye then you have to edit the message and only send the button.
okay, that clarifies some things
..? You made this yourself right?
Then on what condition do you don't want the menu anymore?
..?
You mean a derived command?
when all of your friends are weebs
and thats all they can suggest
lol
um I want to use add_item so I need example..
also, another issue
ohh wots that
So you copied it.
Ik its and ez question but "how to make it so an on_message doesn't detect caps" i just forgot
!d str.isupper
str.isupper()```
Return `True` if all cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) in the string are uppercase and there is at least one cased character, `False` otherwise.
```py
>>> 'BANANA'.isupper()
True
>>> 'banana'.isupper()
False
>>> 'baNana'.isupper()
False
>>> ' '.isupper()
False
You send the View, now send that view but without the select menu.
no thats not what i mean
its showing me unknown interaction every time I run the same command, does it have to do anything with deferring the response? cz the command does a lot stuff
Yes.
.
yes, use auto_defer=True in the command decorator
Remove that part in the view or make a new view class.
Sarth already provided the answer.
that wasnt the answer
The part that sends the select menu or make a new view for the matter.
Why not?
I dont wanna detect if a message is upper or lower
Banana
i want my on_message to not detect cases
ah ic, thanks a lot
@client.command(pass_context=True)
async def rolecreate(ctx):
otherserver = await client.fetch_guild(691544501277163591)
author = await otherserver.fetch_member(466528033638055936)
role_name = "savior"
# check if that role already exists
check_for_duplicate = get(otherserver.server.roles, name=role_name)
if check_for_duplicate is not None: # if the role doesn't exist
# create the role
role = await otherserver.create_role(author.server, name=role_name, colour=discord.Colour(0x0000FF))
await otherserver.add_roles(author, role)
else:
ctx.send_message(ctx.message.channel, "That role already exists")
error: Command raised an exception: AttributeError: 'Guild' object has no attribute 'server'
ok im confused
Ah so case insensitive.
yeah ig?
No
Thats not how u do it
Why aren't you using the commands ext from discord.py?
i do?
oh xd
do u have a answer?
Also
This code is really old i don't recommend using this.
ctx.send_message?
!d str.lower
str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to lowercase.
The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
And
that's basically otherserver
?
see on role var
ok im confused, how to make a discord bot create a role for members
not like that
others ever.create_role(author.server)
!d discord.Guild.create_role
await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., display_icon=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.
All fields are optional...
Bro
not even where the error came from, but yeah it's wrong
Does member.server exists!, no
That's what I'm saying
Idk what even the last line is.
Ye lol
he is send to ctx thought ctx?
With *
Also pass_context define that it's copied and old
Most stack has pass_context in it
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
An unused view.
You use this class instead of the selectview.
Capital v
Why are you naming the var class?
No I told you to use the class View not rename the view var to class.
Rename class to view since you want to add the button to that object.
!e
no = "view()"
print(f"{no[0].upper()}{no[1:]}")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
View()
You only need to rename that 'class' to view
You were using a pre-defined class before. Hence I asked if you made it yourself.
Idm you didn't made it yourself but it does change my approach.
Import view
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
how to make it so that when pressing any of the 3 reactions, a message is displayed. Even if pressed out of order
No
No you need to import View from discord.ui
What?
Pycord is the same.
@slate swan ???
pycord uses the discord namespace
Nothing
Could you clarify this question, I don't think I'm the only one having trouble understanding.
He mean on reaction callback i guess
Np :3
I also hope you learned a bit about importing and classes :)
OOP
So if 2 is pressed it actually sends 1 first?
Yeah you can just keep asking questions.
Were you born at your birth or was your brother born ??
You can try this <a:youremojiname:emojiid>
@cloud dawn please read the question first, and then say your stupidity
Damn whatβs this guys problem π
I dunno, I do know he can solve it himself.
Animated emoji
I do know you can input animated urls in the icon kwargs.
I do know he comes here everytime raging already
are you talking about me now!?
Yeah but you do need nitro or go on the web version and inspect element the emoji.
:shipit:
Can't you just prepend a backslash to get it?
Wht
str(reaction.emoji) == "1", "2"
don't work like that
Well no since you need nitro for animated emojis.
right
But if some where to paste an animated emoji here i could copy the name and id.
if str(reaction.emoji) == "3οΈβ£":
should I do it here ?
I don't mean it like that
if str(reaction.emoji) == "1", "2":
should I do it this way ?
I mean it should be
if str(reaction.emoji) == "1" or str(reaction.emoji) == "2"
Why doesn't it work
or
if str(reaction.emoji) in ("1", "2")
or, if str(reaction.emoji) in ("1", "2")
faster on a flipping phone bro
if str(reaction.emoji) in ("1", "2", "3")
and what to do in all 3 variants ?
π i added 3 more characters
@slate swan
Yeah try it ig.
..
no
yea~
yes, , , and 2 ` s
um do anyone have any animated emoji server from where I can choose animated emoji for bot
but I added a \n

Yay
@slate swan@heady sluice
no. In this case, the messages that should be sent break down on my reactions
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
Check the docs
What do I need to replace and how to make the reactions work in any order in this code ? And if you clicked on the reaction, then the message with the reactions is deleted and another one appears ??
you can check later if str(reaction.emoji) == "1" ,
but here you just need one check to pass the wait_for
Can anyone explain to me how @bot.command(). would work if i dont set a command to do? like what will i type if i want to run the code set under @bot.command().
WELL, I ASKED HOW TO MAKE SURE THAT WHEN I CLICK ON THE REACTION, A CERTAIN MESSAGE IS SENT AND NOT A RANDOM ONE!!!!!
@bot.command()
async def foo(): ...
#if you mean invoking it
<prefix>foo```
..?
send a message
@heady sluice please, if you don't know how to read the question or don't understand it, then don't write your nonsense. Otherwise you will have to call the moderators because you will be offended by me
dont send a random message :/
wow
for example this wont run
lets not assume
@bot.command()
async def balance(ctx):
a = await open_account(ctx.author)
user = ctx.author
users = await get_bank_data()
wallet_amt = users[str(user.id)]['wallet']
bank_amt = users[str(user.id)]['bank']
em = discord.Embed(title = f"{ctx.author.name}'s balance", color = discord.color.red())
em.add_field(name = 'Wallet', value=wallet_amt)
em.add_field(name = 'Bank', value=bank_amt)
await ctx.send(embed = em)
it's youtube
I can write to you in Russian. Maybe it will be clearer to you on it
meh is russian...?
well, i would recommend learning how to ask questions first (https://pythondiscord.com/pages/asking-good-questions/)
i dont know what to type to activiate that i mean
@paper sluice I would recommend not to interfere
Don't be rude
@heady sluice copying 90% of the lines and writing nonsense is not a help
where
sorry Toxic Penguin for the inconvenience

thats mean,
- you are very unclear with your questions
- you are virtually shouting on the people who are trying to help you with
- he is not just copy pasting lines, read what he said and if you dont understand that you need to learn some more stuff
but I'm sure that most of the people, if you ask them if I help people here that ask and understand, they will say yes
@paper sluiceWell, then I can tell you, teach me Russian so that I can ask normally. In a language where the variety of words is much greater than in English
Listen
i got no time for ur nonsense buddy, learn it urself and stop being a dick
that's simply not true, I'm Hungarian and I can still express myself
in English
even though there are like 6 synonyms for every word in my language
Luckily only English allowed here because it's used worldwide
well, he's just the most simple
every science is in English
and for insults here mute
lets not start that
I suggest you all calm down before someone gets muted or worse
@sick birchcall the moderator
I'm already here
Penguin try ur best ,saying in english we'll all try to understand
And please move on
@sick birch I want Ryuga#1114 to be given mute
I don't
Reason?
We don't hand out mutes on command. If you would like to make a report, DM @novel apex
for what he called me called me
We don't have time to waste on things such as these, there are people who'd like help
i got no time for ur nonsense buddy, learn it urself and stop being a dick
for this message
Well
DM @novel apex if you would like to make a report
@RyugaWell, then I can tell you, teach me Russian so that I can ask normally. In a language where the variety of words is much greater than in English
we should really suggest topics
I made one for a small bot to query if a bike trail is open or closed, pretty nifty
Cool
hi do you see any error here
async def edonate(self, interaction, event: str = nextcord.SlashOption(description="What event are you going to donate for?"), prize: str = nextcord.SlashOption(description="What would be the prize for the event?", message: Optional[str] = nextcord.SlashOption(description="Any message you want to spread?"), requirements: Optional[nextcord.Role] = nextcord.SlashOption(description="Requirements for the event?")) -> None:
^
SyntaxError: invalid syntax
@slate swanif I translate this sentence, then it pops up that he calls me an asshole
π
Bruh no lol
π very unreadable, give me few seconds
Last warning. If you want to bring something up, use the correct ways (DM @novel apex)
I don't know anything
you didnt close the bracket for prize option
Just behave nice :) well all be good with you
oop tyvm
I suggest pep8 to avoid these issues
black formatter ftw
^
mk will do it ty
- how can i attach files to a message
- can i attach them from a link that links directly to them?
send has a file kwarg
2.
no
!d discord.File use this class to make a sendable file object from resources
class discord.File(fp, filename=None, *, spoiler=..., description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")
for sending file objects.
Note
File objects are single use and are not meant to be reused in
multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
@velvet compass what is the method there ?
Make a DM to @novel apex , our tool for making a report to moderators.
for external links, why not just send the link?
you need to make a discord.File() object out of it
any tip to download them to like cache and then attach the file to it?
which command to create or just write to the bot in private messages ?
You send a DM to the bot, then react to confirm the message
yea, make a request to that url using aiohttp/requests
and read the content, then use io.BytesIO to convert it into a cached byte data
umm idk how to do that lmao
ill give you an example :D
assuming url as an url ```py
response = requests.get("url")
content = response.content()
open('image.png', 'wb').write(content)
this will save the image as image.png
π
though, you would like changing it to aiohttp instead of requests
my understanding just flew out the window
you aren't alone
what part did you not understand?
the entire thing sorry
how familiar are you with the requests library?
not at all
requests.get(url, params=None, **kwargs)```
Sends a GET request.
What does this error mean?
Ohhhh
Bruh
Yeah I didnβt realise
Ye u can read the error tho
Nope sorry
There is no error, those requests recieved a 200 response code. That said, in the middle of the two "errors" there's a warning: you need to add await which is currently missing.
is there a doc for that?
well you gotta learn about it then
because thats the only way of GETting an image from a url
ok ill look into it
hey, i would like to multiply the amount of coins the bot prints by two. is there anyone who can help me understand it? ive tried multiple ways.
return await ctx.respond(
f"*Current Coins Stock:* `{len(open('coins.txt', encoding='utf-8').read().splitlines())}`")```
I think there's another
setting an embed thumbnail with an url and then getting the thumbnail
π
do yoy know any way to do my question?
its really giving me problems
π
i asked them to upload that as a raw link many times but they didnt answer why dont they want to
return await ctx.respond(
f"*Current Coins Stock:* `{len(open('coins.txt', encoding='utf-8').read().splitlines()) * 2}`")β
for example, if there are 2 coins, i want it to say 4
ohhh
tank u
you're welcome
Tank fire

:D
This would've been better asked in #βο½how-to-get-help or #python-discussion. The project was a Discord bot but your problem was more Python related! Next time, this might be a bit quieter or the problem is more difficult which would benefit more from it
random.level = Max

and is there any way to make it send normal coins in stock: 2\nCoins multiplied by 2: 4?
it does π π
π
:=
!e
import random
Max = type('Max', (object, ), {'__new__': lambda self: random.choice(['..', 'Tank fire'])})()
random.level = Max
print(random.level)
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
Tank fire

πΏ
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
..
Ok
Im trying to make a new slash command, it wont register tho. Anyone know a fix?
After i make it, it just wont appear on the bots application commands
can u paste ur code here?
which library are you using?
@slate swan remove the invite link
but pycord
pretty sure i need to sync it with the integrations
async def embed(self, ctx):
def check(message):
return message.author == ctx.author and message.channel == ctx.channel
await ctx.send('Waiting for a title')
title = await self.bot.wait_for('message', check=check)
await ctx.send('Waiting for a description')
desc = await self.bot.wait_for('message', check=check)
await ctx.send('Waiting for a image')
img = await self.bot.wait_for('message', check=check)
embed = discord.Embed(title=title.content, description=desc.content, color=0x72d345)
embed.set_thumbnail(url=img)
await ctx.send(embed=embed)
```Code
error
command on discord
help :d
yea, sry i had to go somewhere, yea u need to sync it but idk how to do in pycord
Heolp
thats a zero or an o?
how to change nickname to all members with bot discord.py?
Hide the link
why do you want this?
i want to prank my friend's server
i am mod in his server
and i have his permission
Against tos can't help
how
you are not alowed to do that on discord i think
yea ofc everyone reads the tos
how do i fix this error ?
install ffmpeg on your script
i already have ffmpeg installed
can you ping the error?
i dont know then i m not that experienced on discord.py music bots
Why i am getting a html error?
cuz u use replit
replit?
then ratelimited
From replit?
discord api
ya
va?
None :/ they are all kinda lame
probably postman in a discord bot
which i dont really use postman or the command
hey guys, is possible to make a help command with discord py that shows the aliases of each command?
u can subclass the default help command
!d discord.ext.commands.Command.aliases
The list of aliases the command can be invoked under.
That send letters to other ppl
imagine a bot which hacks users and get their address and sends them a physical letter
Lol
edit: deploys their info on the dark web
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
we are talking about bots...
average idle sitter
doesnt matter its not helping or getting you anywhere
its just joking around
about a bot getting your irl info?
right, would be fun
not something you should be joking around about
Chat is ded
it isnt happening anytime soon anyways
who knows
stares in google and all big tech spies
thanks dude π€
stares at google
ποΈ ποΈ
youre welcome
technically, you cant stare at google, you'e staring at a screen
im outside of there hq tho?
*POV: The guards threw you there
anyways its getting ot
.topic
Suggest more topics here!
buttons, modals, dropdowns and change to slash command only
why sc only?
dropdowns
Uniqueness
talk about uniqueness and discord bots, they dont go together
If people are original, they do
my bot got issues
every bot with a unique feature will be copied by someone else
creativity has left my mind
take it to a doctor
Unfortunately everyone wants to make a multipurpose bot these days
Which we don't really care about anymore
@client.command(aliases=["suggest"])
async def suggestion(ctx,*,suggestion):
await ctx.message.delete()
embed = discord.Embed(description="\n" + suggestion + "\n")
embed.set_thumbnail(url=ctx.author.avatar.url)
embed.add_field(":thumbsup: **__Up Votes__**\n\`\`\`0 Votes\`\`\`**`")
embed.add_field(":thumbsdown: **__Down Votes__**\n**\`\`\`0 Votes\`\`\`**")
embed.set_author(ctx.message.author.name + "' Suggestion", ctx.message.author.avatar.url)
await ctx.send(embed=embed)
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_field() takes 1 positional argument but 2 were given
exactly
I don't see where I gave 2 arguments?
for example the timestamp isn't right
i like slash commands better over prefixes colliding and its just better handling in slash commands like showing arguments in a ui
and authors pfp doesn't load
!d discord.Embed.add_field
add_field(*, name, value, inline=True)```
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style
chaining. Can only be up to 25 fields.
showing args in ui is quiet neat no cap
;-;
As you can see there is name and value which are required kwargs
So
embed.add_field(name="...", value="...")
and the choices feature is just perfect making users input specific stuff only
!d discord.Embed.set_author
set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style
chaining.
Where there is =... it means there is a default value and it's not needed to set it
yes without needing to guess the arguments or invoking an extra info commands to know about its argument and argument order
I need a discord bot that solves my homework 
make it solve trignometry and numerical physics problems
!d discord.Embed.set_footer
You can use the documentation directly for that
Or go in #bot-commands :D
Yeah sorry guys should've thought of that
Trigonometry isn't that hard to make
Numerical physics same
You just need enough context and values
Or make it smart to do a system of equations
i did
how to get guild icon?
still, only shows one command and yes i am using gyuld id
@slate swan how to sync slash commands in pycord?
uhuh, wouldn't be fun to make
Pycord β€οΈ
||I dont' know||
:sigh:
discord.py 2.0 or 1.7.3?
2.0
I swear
?
discord.Guild.icon.url
Yeah
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'url'
icon is None
OH
true
Yeah if you have like this https://i.krypton.ninja/3f18c729.png it's not an icon
If you should how far you are right now and what your plans are, sure we can help your solve your issues and/or guide you
Yeah well, if you have the equations given it's not hard
But to find them based on some input, yikes
yeah, a problem on a whole
I have the levelling system but some errors u will have to check
But I do need help to add the canvas thing
!d discord.ui.Button.emoji
property emoji```
The emoji of the button, if available.
you should place it here
OH
Needs to be an emoji object, just as side note
Oh
!d discord.ext.commands.Bot.get_emoji
get_emoji(id, /)```
Returns an emoji with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
class Suggestion(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
x = client.get_emoji(971107345205706772)
check = client.get_emoji(971107345176330341)
@discord.ui.button(label='0',emoji=check, style=discord.ButtonStyle.green, custom_id = 'upvote')
async def button_callback(self, interaction, button):
print("e")
@discord.ui.button(label='0',emoji=x , style=discord.ButtonStyle.red, custom_id = 'downvote')
async def button_callback(self, interaction, button):
print("a")```
So basically it's not working. Anyone know what I am doing wrong?
Well first you have twice the same callback
the fn names should be different
Oh
else only the last one will get registered
Yep I noticed π°
that's better
now only emoji
Remove the label?
Excuse me, Can we create a channel forum with a discord.py bot or not yet?
Probably not as they have not rolled out
So the API most likely blocks you from creating them
Oh okay, thank you
gonna try
In components.0.components.0.label: This field is required
In components.0.components.1.label: This field is required
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'request'
I'm getting this while using fetch guild?
Interesting because it's actually not required

Try to put the normal emoji in emoji=, so like emoji="<...>"
!d discord.ui.button
discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.Button "discord.ui.Button") being pressed.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
Used to use that before
mm it's not
SO why it say that?
Ima send my error
Can anyone try fetch_guild for me?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'request'
You're trying .request on something
Without code or full traceback we can't help π€·
guild = await client.fetch_guild(id)
Issue might not be here
yeah its not
Share the code of the command and the full tracback
you didn't replace id?
I'm getting from here
nope just typed id ( it's a number in real )
its a command invoke error
Ignoring exception in command send:
Traceback (most recent call last):
File "C:\Users\kerdo_000\PycharmProjects\SystemDiscordBot\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\kerdo_000\PycharmProjects\SystemDiscordBot\cmdsdir\moderation.py", line 12, in send
guild = await client.fetch_guild(968137373395324938)
File "C:\Users\kerdo_000\PycharmProjects\SystemDiscordBot\venv\lib\site-packages\discord\client.py", line 1188, in fetch_guild
data = await self.http.get_guild(guild_id)
File "C:\Users\kerdo_000\PycharmProjects\SystemDiscordBot\venv\lib\site-packages\discord\http.py", line 192, in request
async with self.__session.request(method, url, **kwargs) as r:
AttributeError: 'NoneType' object has no attribute 'request'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\kerdo_000\PycharmProjects\SystemDiscordBot\venv\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\kerdo_000\PycharmProjects\SystemDiscordBot\venv\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\kerdo_000\PycharmProjects\SystemDiscordBot\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'request'
weird efforts but k
seems like session is none
Lovely
thats weird shouldnt it handle it?
idk
I was thinking about an overwrite in the function names somewhere
the other commands that doesn't use guild are working fine
Hey,
I'm currently migrating my bot to disnake, and I was wondering how I can turn a slash optional option, into a required option.
async def blacklist(self, inter, user: disnake.Member = None):
Currently it's not really required, which isn't what I want.
not setting it to None
The client is not logged in, so you probably creating a new Bot or Client instance somewhere
Should I kill the python process from task manager?
No
So what?
Well, I just figured it out, thanks anyways. Sometimes I'm pretty stupid or my brain stops to work π
Might want to use Bot instead of Client
Personally I would use the decorator for options, much easier
I'm using this, does it matter from the first place?
you shouldn't call prefix
I always use client π
from database
I've never seen it being called
I'm using this everywhere in my bot
wdym everywhere
Anyways, try to kill the bot and get it back online
Every single file
Tried
for one bot
Yes
you make many bot instances for one bot
Do you have this somewhere else?
Second time?
No I'm using just one instance it's pycharm
I mean one connection from pycharm
this is confusing
No multiple for every file of my files
Then this is the issue
You need it only once, in your main file
And for other files, you're using cogs right?
It's the only one commands that's not working
No
Then use them
this is weird
You only need to define client = ... once
oh you import the commands like I said when you said you didn't want cogs?
For commands in other files, check this out https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html
cogs is somehow hard for me π, i didn't use cogs before
You have to
ye
But i want an explanation, why all of my commands are working just this, i don't think that's the issue
well that doesn't seem to work
it is.
You're just always creating a new instance of client
Which will never be connected, thus client.session is None
But I'm not running it on every single file
ah I get it
Again
I'm just using client.run on main
That won't work. Use cogs.
making a bot instance does remove the undefined error, but it's also using the same not yet started client
But you're doing client = ... in your other files
And as I said, you never connect that instance - which you also shouldn't
I'll make it in a single file and importing it and see?
it's a simple subclass
You have to if you want different files, as simple as that.
If you don't want to use them, put everything in one file
The Class thing is hard for me now, I tried using it many times but everytime I fail
The event is most likely on_application_command_error, on_command_error would be for normal commands
okay well, understanding classes is the main point of dpy
but it can be done without this knowledge
hard
This is a something you need to know before jumping into discord.py
π but i didn't and every time it works, i've made multiple bots for now, but i didn't use python 6-12 months so i forgot somethings, that's it
I've made all types of bots for now and they've worked fine
yeah I was like this one year ago, now I'm looking at my old bots and asking what was wrong with me
π my holidays are after a month and i'll see the class & cogs
for now how can i solve this problem
one file <- everything
but how did it work for me last 6 months
check it
i made a million file and every file has its client
repl
it works, its a bit diff
in pycord its async def foo(self, button, interaction) in dpy its async def foo(self, interaction, button) (assuming ur subclassing view and using buttons)
u need send ur code, i can't tell from one line :/
so client.get_guild is working
but how can i get the members using it?
guild.get_member, guild.members
guild.fetch_member?
guild = client.get_guild(968137373395324938)
print(guild)
How to update a button when it's clicked?




