#discord-bots
1 messages · Page 911 of 1
Is there any good cheap bot hosting site?
you can try aws or heroku but they are not that good
i think google also does hosting
Like anything <= 1$
There are a some but you need to give some credit card information to
I know one that does vps for 0.50$
Tell me about it
What is that?
Code:
@client.command()
async def factorial(ctx, number):
n = int(number)
if n > 20:
await ctx.send("Error")
if n <= 1:
await ctx.send(n)
else:
n = n*factorial(n-1)
await ctx.send(n)
the function in which you are doing stuff in
why change it to int if u could just get the arg like number:int
def funcname():
funcname()
this too just typehint to an int and let dpy convert
ye
how do I correctly annotate a User | Member? Do I always have to write the union?
What?
I don't really get what you're asking
yes, you need to do Union[Member, User]
is there even a difference?
iirc if you put User first then it will always be coerced into a user
since members are valid users
but users may not be valid members
ok
How to fix this?
Code :
@client.command()
async def factorial(ctx, number):
if number >= 20:
if number <= 1:
await ctx.send(number)
else:
number = number*factorial(number-1)
await ctx.send(number)
else:
await ctx.send("Error")
you need to typehint number as an int else discord.py will treat it as a string
so number: int
also that function won't work properly when you get further in since you're calling it recursively but you call it with the wrong parameters and it doesnt return a value, you may want to take a look at
!d math.factorial
math.factorial(x)```
Return *x* factorial as an integer. Raises [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") if *x* is not integral or is negative.
Deprecated since version 3.9: Accepting floats with integral values (like `5.0`) is deprecated.
Ok
hi
async def Help(ctx):
await ctx.send(
"Click below to get help embed",
components = [
Button(label = "Yes", custom_id = "button5", style=ButtonStyle.green),
Button(label = "No", custom_id = "buttons123", style=ButtonStyle.red)
],
)
interaction = await client.wait_for("button_click", check = lambda i: i.custom_id == "button5", timeout=120)
await interaction.send(f"{helpEmbed}")
interaction = await client.wait_for("button_click", check = lambda i: i.custom_id == "button123", timeout=120)
await interaction.send("Not sending help embed!")```
this is my code k?
thebot runs without errors
the command works
but upon clicking the buttons
interaction failed
no errors in console
like to check if theres any resources for discord sales bot?
Which library are you using & where did you get the event name "button_click" from?
from discord_components import DiscordComponents, ComponentsBot, Button, ButtonStyle
ah I'm not familiar with discord_components sorry
anything else which can make this button interaction work?
uh v2 of most libs (discord.py, nextcord, disnake, etc.) support a construct called 'Views' which allows you to neasily manage components, I can link the documentation for that if you want
👀
yea sure
how do u use slash commands in a cogs
sorry I went to get food; https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.ui.View
which library you using?
nextcord
I actually just wrote something about that; https://tutorial-alpha.vcokltfre.dev/tutorial/intermediate/nextcord/11-cogs/
A tutorial to help you make better Discord bots.
are there like any examples with images so u can see what all those are looking like?
the code or the actual things in discord?
There's a bunch of examples on https://discord.com/developers/docs/interactions/message-components, you can ignore the code blocks since they're for the raw api, but the images are helpful
ty
so I'm syncing my d.py 2.0 command tree during on_ready, is it possible to do that during the setup_hook or does it require the guilds cache to be filled in (I'm thinking it does)
I don't think it needs the cache since it sends the data to the Discord API
okay
Any imports needed?
okay so either something is going really wrong or the tree doesn't get given the app ID until on_ready is calledpy Traceback (most recent call last): return future.result() File "C:\Users\Teagan\Documents\Coding\Zupie\bot\utils\services.py", line 162, in main await self.start(token) File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\client.py", line 655, in start await self.login(token) File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\client.py", line 521, in login await self.setup_hook() File "C:\Users\Teagan\Documents\Coding\Zupie\bot\utils\services.py", line 138, in setup_hook await self.tree.sync(guild=Object(id=default_guild))# File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\app_commands\tree.py", line 742, in sync raise ClientException('Client does not have an application ID set') discord.errors.ClientException: Client does not have an application ID set Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000192B116E680> Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 745, in call_soon self._check_closed() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed
Idk, try using a task
if I have a ```py
def is_modmail_channel():
async def predicate(self, ctx):
if not (await self.check_if_open_with_channel(ctx.channel.id)):
await ctx.send(disnake.Embed(description="This channel is not a ModMail channel", color=disnake.Color.red()))
return False
else:
return True
return commands.check(predicate)
how do I use this as a deco for a command?
If I just do
@commands.command()
@is_modmail_channel()
It'll say it requires ctx
but if I put ctx, it says ctx, isn't defined
what is that self?
the correct usage, for example, is this one:
def is_call_manager()->Callable[[T], T]:
def predicate(ctx: AnyContext)->bool:
result = db.field("SELECT WhiteListRoleID FROM Guild WHERE GuildID IS?", ctx.guild.id)
if result is not None and any(role.id == result for role in ctx.author.roles):
return True
else:
raise WhiteListFailure(message="This user hasn't the permission to manage calls")
return check(predicate)
with AnyContext equals to typing.Any(disnake.ext.commands.Context, dinsake.ApplicationCommandInteraction) if you use slash commands too
it is not usggested to create a check inside a cog, make a check folder where you put your check script, then import the function of that script and you can just use the decorator
my path for example is like this:
-My_bot
-Cogs
-my_cogs.py
-checks
-my_checks.py
then in my cogs script i import checks.my_checks.function_name and use @function_name before the command
it works, then you'll just call the function without importing it from an external file
take all checks inside a folder is more readable of course
yeah it's because part of my check uses a function that's in my cog file
if they are reliable to checks then is useless to declare them inside the cog file, otherwise you can create another external folder in your bot folder where you can create your script and then import them, like:
-My_bot
-Cogs
-my_cogs.py
-checks
-my_checks.py
-utils_script
-scripts.py
is there a way to view the cache? like to print it / export it to a redis session
in that utils folder you can declare function that will come always useful
i do have something like that
but here check_if_open_with_channel is a function in my cog file
!d discord.ext.commands.Bot.cached_messages this for example retrieves the message cached
property cached_messages```
Read-only list of messages the connected client has cached.
New in version 1.1.
i dunno if there is a member cache but i don't think so
i dunno if you can import a cog without having problems. You can try but most probably it will raise a circular import exception
i think there is, i just don't know if it's exposed
i have the docs opened and i don't find nothing related to members
most probably is because all the users that the bot can be already taken using Discord.ext.commands.Bot.users
where users is the list of user that the bot can see
and the same could be for the guilds
for channels instead they are stored in guild object, discord.Guild.text_channels and discord.Guild.voice_channels
wait in my cog file, not in the cog class, how do I access bot?
cogs are declared like this:
class myCog(Cog):
def __init__(self, bot):
self.bot = bot
def setup(bot):
bot.add_cog(myCog(bot))
the setup function is called by the instance of your bot (i don't know how, if you are curious you can check the source code) and the setup function create an instance of your cog with passing the bot instance in it
so you can access bot method by doing self.bot.method() in your cog
no not in the cog class
think you'd have to import the bot var from it's file, at least that's what I ended up doing
it will raise a circular import if you import your bot inside a cog file
in a cog file:
import disnake
from disnake.ext import commands
x = bot.something
class Cog(commands.Cog)
#code
it surprisingly doesn't
now here it will raise bot is not defined
already tried it and it does haha
how do I access it
are you importing the full 'main' file, or just the bot var from your 'main' file, bc I'm doing thispy from main import bot in one of my cogs and it works fine
my bot is subclassed lol
var is rude
yeah so is mine, but I'm importing the actual bot var not the class (that would cause some issues I guess)
so should I import the bot var?
yeah if you need to access bot attributes or property's outside of the cog class (or in deco like I am)
okay will try
uhm all those question racked my brains btw hahaha
yeah i'm importing my bot var here https://github.com/SnowyJaguar1034/Zupie/blob/master/bot/cogs/owners.py#L11 and then making use of it in a deco on line 41
why does this still raise TypeError: ModMail.is_modmail_channel.<locals>.predicate() missing 1 required positional argument: 'ctx'
code
anyone know which part of @unkempt canyon's source handles displaying GitHub code (you know when you send a link to a GitHub repo and the bot replies with a msg showing that file or a line of the file)
#imports
async def check_if_open_with_channel(channel_id):
async with bot.db.execute("SELECT modmail_channel from modmail_channels WHERE modmail_channel = ?", (channel_id,)) as cursor:
data = await cursor.fetchone()
if not data:
return False
return True
def is_modmail_channel():
async def predicate(ctx):
if not (await check_if_open_with_channel(ctx.channel.id)):
await ctx.send(disnake.Embed(description="This channel is not a ModMail channel", color=disnake.Color.red()))
return False
else:
return True
return commands.check(predicate)
#cog class ```
I'm using it as a deco in one of my cog commands like just `@is_modmail_channel()`
is passed
what??
thanks
whait why async def predicate?
wdym why?
because i'm using await
but I don't need to
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | TypeError: myfunc() missing 1 required positional argument: 'x'
!e ```py
def myfunc():
async def test(x):
print('test')
myfunc()
@spring flax :warning: Your eval job has completed with return code 0.
[No output]
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
How to make Discord commands?
As i thought there is no need to declare predicate as async function
how can i get a specific text of a string?
for example i want to get every user id and their xp
**#1 I usrid XP: `185`**
#2 I usrid XP: `180`
#3 I usrid XP: `91`
#4 I usrid XP: `83`
:sparkles: **More?** `#top text day`
if inspect.iscoroutinefunction(predicate):
decorator.predicate = predicate
else:
@functools.wraps(predicate)
async def wrapper(ctx):
return predicate(ctx) # type: ignore
decorator.predicate = wrapper
return decorator # type: ignore
this is a part of the check function in disnake.py source code
no i don't need self
i mean ctx
#in a checks file
def something():
async def predicate(ctx):
#code
return commands.check(predicate)
####
@commands.command()
@checks.something()
async def ...
lets try to stay a bit calm
SUGGEST ME
Bro he has the ctx in his check, that is not the issue
Wait, don't u need self in the something function?
def is_modmail_channel():
async def predicate(ctx):
if not (await check_if_open_with_channel(ctx.channel.id)):
await ctx.send(disnake.Embed(description="This channel is not a ModMail channel", color=disnake.Color.red()))
return False
else:
return True
return commands.check(predicate)
This is his check
not in a cog class
as you see, predicate has ctx, the problems is something else
Ah
Yea, the check is correct
first of all, the predicate function doesn't need to be declared as an async function
It can be
your fork will do it for you
!d discord.ext.commands.check
but im using await
@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").
These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`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") event.
If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`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").
Read the code that i sent from the source code
for the database operation
oh my god read this.
Bro, if he uses await inside a non async function, it will raise an error at his end
...
See
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | await
003 | ^
004 | SyntaxError: invalid syntax
Guys, this code here
cames from check function from the source code
Dude, that is for the backend, so call the check on the backend. You need an async function
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 5
002 | SyntaxError: 'await' outside async function
Well nevermind already tired to explain, the problem could be the decorator so @spring flax send the command
Bro you can't relate on the error code, it helps but it is not said that the issue is what you think, because if you read his decorator, ctx is defined inside the function
@spring flax can you share yr check code?
We don't talk about the mixedCase 🗿
the issue could be when he called the decorator
Can we please stop?
No
EXACTLY, when he used it, so we have to check when the decorator is called, you were telling him that he didn't declared ctx D_D
i arrived when drama again damn 
nvm just try to solve this issue
@slate swan @placid skiff can we please calm down?
Regex
.. note::
The function returned by predicate is always a coroutine,
even if the original function was not a coroutine.
Here it is a note from the source code btw
so is not necessary that predicate is async
That's how u should use the deco tho
^
But he wants the predicate to be async
How can you call an async function inside a normal function
well, there are various ways to do this anyway lol
.....?
@discord.ext.commands.check_any(*checks)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if any of the checks passed will pass, i.e. using logical OR.
If all checks fail then [`CheckAnyFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckAnyFailure "discord.ext.commands.CheckAnyFailure") is raised to signal the failure. It inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Note
The `predicate` attribute for this function **is** a coroutine.
New in version 1.3.
well in case of checks you can .-.
asyncio.run_coroutine_threadsafe() ?
I think I'mma go away before I lose my cool
good choice
i just don't understand why are you complaining it if even the documentation says that is not necessary D_D
What the living hell
Why using check_any
Okay seems legit but why not make the outer function a coro as well
you overcomplicated that shit so much
yea right
i totally forgot about that
simple answer
thanks
the outer function is the decorator function .-.
If there are not gonna be any other numbers
Ik but like coro inside non coro seems weird for me
can we seriously stop it now?
that's why declaring coro inside a check function is not necessary xD
Ok
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 5
002 | SyntaxError: 'await' outside async function
I mean you don’t really need the check_any. It’s designed to accept multiple checks and return if any of them return true.
Anyways who needs decorator checks when you have cog checks 😏
if inspect.iscoroutinefunction(predicate):
decorator.predicate = predicate
else:
@functools.wraps(predicate)
async def wrapper(ctx):
return predicate(ctx) # type: ignore
``` now read this code an tell me what it does .-.
What is the easiest way to just. Send a message in a server?
wtf? wdym?
await bot.get_channel(some_id).send(...)
ctrl+a ctrl+c ctrl+v 
(some_id) Is the channel id right?
or server
Yes but not including the brackets I hope yk python right
bro that is not a code of mine or something, that block of code is written inside the check function of discord.py, it checks if the predicate that you pass in the check is a coroutine function, if it isn't it turns the predicate in a coroutine. That's all, what is hard with that?
🤯
You guys are really talking about bots anymore. Might wanna chill before Hunter pulls out the ot-shit 👌
is related do d.py xD
This
Not really? It’s completely irrelevant
yup, is a code inside the discord.py
ok then
@slate swan :x: Your eval job has completed with return code 1.
001 | File "<string>", line 5
002 | SyntaxError: 'await' outside async function
ok example time. one sec.
is this a joke
!e
import asyncio
async def f():
print('hi')
asyncio.run_coroutine_threadsafe(f(), asyncio.new_event_loop())```
@vale wing :white_check_mark: Your eval job has completed with return code 0.
001 | sys:1: RuntimeWarning: coroutine 'f' was never awaited
002 | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Ok
You can't use await in a non async function.
Basic python 
It like literally.. doesn't work
It will raise an exception
Clear enough to me
!e
async def print():
print('hello')
def proof():
await print()
proof()```
@rocky trench :x: Your eval job has completed with return code 1.
001 | File "<string>", line 5
002 | SyntaxError: 'await' outside async function
^^
Will an exec command that can execute async functions be considered a solid proof, cause I have one
i mean
2 mins
Ive got time
This doesn't proof anything?
U didnt use await inside a function without async
Which is what they said that was possible
hey guys
name = random_sub.title
url = random_sub.url
likes = random_sub.score
comments = random_sub.num_comments
link = random_sub.selftext
button = Button(label="Next Meme", style=nextcord.ButtonStyle.green)
async def meme(self, interaction):
await interaction.response.edit_message(title = name, url = url, colour=nextcord.Colour.random())
view = View()
view.add_item(button)
em = nextcord.Embed(title = name, url = url, colour=nextcord.Colour.random())
em.set_image(url = url)
em.set_footer(text =f"👍: {likes} | 💬: {comments}")
await ctx.send(embed= em, view=view)
``` this my code for meme (there is more but its confidentional stuff)
Anyways, anyone knows how I can make my bot send tracebacks?
apparently when i click the button, it does not give me a new meme
Basicly, I don't know how to do it. Just if there is an error, so it sends it in chat
Um I can't get into github wtf
guys help
Cool!
I spent ages trying to figure out how to do that and couldn't find a way
!e
Like python bot:
def function():
list= []
print(list[0])
function()```
@rocky trench :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | File "<string>", line 3, in function
004 | IndexError: list index out of range
Like this
guys help
do you mean that that the predicate def cannot be an async one?
What's the point of pinging a random guy
Code brug
can you help?
this
I dont know your issue
well you're right
😅 i didnt read the complete chats so i got you wrong.
U ain't setting the call back anywhere
Yes
You're missing the nextcord.ui.button decorator
yeah just change name from discord to nextcord
thats for classes
@slate swan this is the exec command
The link is weird
assuming he subclasses view
Hmm. So it's like not possible?
Ok
your problem is most likely in the callback
I'll do it when I'm at home
In on_command_error it is None
So not even worth a try, already tried to implement such thing
Maybe we just need to catch more low-level stuff, like use on_error instead of on_command_error but I haven't ever tried that
Exception._traceback_?
it is possible anyway, i just don't remember how and can't find the discussion that i had with the guy who explained this to me. i'm getting C:\Users\giacomo.dimatteo\PycharmProjects\ZhagoBot\lib\bot\bandi_check\Checks.py:69: RuntimeWarning: coroutine 'is_me.<locals>.predicate' was never awaited wrapper(ctx)
As said above it is not possible within on_command_error
and the code is:
def is_me()->Callable[[T], T]:
def predicate(ctx: AnyContext)->bool:
@functools.wraps(predicate)
async def wrapper(ctx):
return predicate(ctx)
wrapper(ctx)
return check(predicate)
https://github.com/Rapptz/discord.py/blob/98a31cf2858bd8f7e00bbd2b9f8aa520ae8536da/discord/ext/commands/bot.py#L233 it is, the default one uses it
discord/ext/commands/bot.py line 233
traceback.print_exception(type(exception), exception, exception.__traceback__, file=sys.stderr)```
essentially what i am doing is converting the predicate function into a coroutine function,
it's not like predicate will not be an async function, it will be a coroutine function, but not a declared one
maybe just raise the error 
they want to send it on discord
Use the traceback library to get it
btw reading this The check functions for command 'stupid_command' failed is a little bit hilarious
raise error FTW!
They wanted to print it on discord
raise the discord 
My bad, sorry
Honestly printing errors to console isn't that great, instead you could probably send all your errors somewhere else, I know there are platforms for that for watching for errors, or set up an admin bot dashboard to view errors
make your own API and send your errors to the API using POST reqs
Yep that works just as well
Store the errors in database and make a web app using maybe next.js and use something like getServerSideProps to render the errors
What databases are able to properly store Exceptions?
You'd probably need to make a custom type, and an array for it?
async def embed(ctx):
experience = users[f'{ctx.author.id}']["experience"]
userlvl = users[f'{ctx.author.id}']['level']
embed = discord.Embed (description=('Your rank is: {userlvl}'),
set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed))```
why does this not work
This a level system. 🤔
no its not
its a command
What’s it meant to do?
display someones level?
Yes a embed level system
no its a command
Same thing.
it really isnt
Define the command
Its a command to find your level in the level system*
Its not the level system
That’s what I meant, 🤣🤣
Its not the same thing then
no?
if you don't see the errors means they don't exist 
pass```
be like
converting the Exception into a json and storing in a Mongodb database should be possible right?
That's pretty much a custom type
youtube tutorials be like
how to never get any errors in your console

I'm sure there are some databases out there with this data type builtin but my question was a bit too wide
but storing exceptions is just a great fucking idea
you can just look at them later and fix them as they're stacked up
what would authors url be
Wtf use logging
who
!d discord.Member.avatar.url
No documentation found for the requested symbol.
Ok
its ment to be author..
author is a member or user
Not sure but sentry.io can be used
probably wouldn't store the whole object, just the line, description, name of the exception
and some data about the command
!d discord.Asset.url | get the Asset with Member.avatar
property url```
Returns the underlying URL of the asset.
!local-file
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
What's wrong with writing to log files
ctx.author.avatar.url
whats this ment to be
# make a file object
file = discord.File("path to file")
await send(file= file)
I don't understand the question
what did I say against it
Why you storing exceptions in a database
cuz it's faster and better practice
No it's not
and it's easier to use in the future
yes, but the member should have a custom avatar here
Else you would have to use author.default_avatar.url
A local log file is faster
wym?
!d discord.Member.avatar read the description it can be None, so when you will use .url it will raise an attribute error
!d discord.User.avatar
property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/master/api.html#discord.Asset "discord.Asset") for the avatar the user has.
If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.display_avatar "discord.User.display_avatar").
The second paragraph here
discord.errors.InvalidArgument: file parameter must be File
you didn't do what I asked you to do...
I can also use a database from anywhere
Show code
ok i got it
so ctx.author.display_avatar.url?
yea that works
AttributeError: 'Member' object has no attribute 'display_avatar'
now I was thinking about this argument for a while, so appreciate it please 
What version of discord.py are you using
1.7.3
hm .avatar and other are for 2.0+
You may just use Member.avatar_url
Or update to 2.0 for using these properties
updating then 🤣
Great job 👏

it just dosent display the embed now
Code ?
actually no commands work now tf
there gonna be slash commands so thats useless
if yes, change the decorator from .event to .listen()
but the cmds dont work
you got that event or not?
what's going on here seems like an interesting issue
my commands dont work now
code of the command
you sure the bot is running?
when
it is
wut
it is on cause im getting xp feedback
code of the command which doesn't run
^
we need more context bruh
the commands dont work but everything else does
Hello chat
SEND THE CODE
What's going on
async def test(ctx,*, text):
embed = discord.Embed(description=text)
await ctx.send(embed=embed)```
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.
if it is in one file xD
cogs won't affect the commands in any ways tho
Yikes, JSON as a database
TEST DATABASE
What's the point of making a test database with JSON if you're just going to have to change all your code when you get out of the "testing" phase
- Remove process_commands from the listener
- Make sure you save the code before running the bot
- Check your internet connection and heartbeat latency( bot.latency)
Since it might take time to send the request to discord sometimes
thats the funny part im not gonna 🤣
Which means it's not a test database and it's your long term database
Which is a terrible idea
commands still dont work
Read this
.
Also something I have to add on is that you're eventually going to end up in JSON hell
to think about in the future not the present
so why do commands not work?
.
heartbreak latency might just be the best typo ever
i did all of these ...
still dont work
my bad
Jesus is proud of you
if not f'{user.id}' in users: wth is this shit?
I'll simply blame my keyboard's autocorrect for that and pretend that nothing happened

^
What was the latency?
its not my internet.
Latency is not related to your internet tho, just try printing it inside an on_ready event
1ms
probably trying to check if the string form of someone's id exist in a list/tuple/dict/any iterable
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
0.11692290000000005
😩 that's not the issue then
so nothing is
when does your commands stopped working?
Last question Are you running the correct bot?
what?
it just dosent work
I mean does your bot even get online
I asked you when it stopped working
How did you invoke the command?
it dosent work what?
oh as in time?
yes
ok when they stopped working?
Wait I know what happened
check asyncio last version please
!d discord.Intents.message_content
Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:
• The message was sent by the client
• The message was sent in direct messages
• The message mentions the client
This applies to the following events...
uhm so your bot now needs this even to execute commands? cool
and there's this https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120
correct
altho commands invoked with a ping still go through without the intent
Yea, messages which mention the bot and dm messages still provide the content
So I do from discord import intent?
so essentially if one of my bot exceeds 100 or more servers it will stop working entirely until they verify it
intents= discord.Intent.default()
intents.message_content = True
bot = command.Bot(...., intents = intents)
is it possible to import a event from an other file ?
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.
!d discord.ext.commands.Bot.add_listener
add_listener(func, name=...)```
The non decorator alternative to [`listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
what I should put in for args and kwargs?
you subclass the class
@slate swan also import discord.ext to this other file?
Essentially what the listener decorator does
discord/ext/commands/cog.py lines 523 to 524
for name, method_name in self.__cog_listeners__:
bot.add_listener(getattr(self, method_name), name)```
why is this so complicated? I only want to import the message.author to the other file, to put it in the list where I add random messages
never worked with cogs so that's the problem
make an event aka listener???
that delete is weird
where is count= and userid=
count=3 AND userid=?
It's literally just working inside of a class
Easy peasy
prob made cogs wrong
never worked with classes too
yikes

That's why you should learn python before making a Discord bot
Oh nvm
I understand many things when I already used them before
but I never needed cogs before
and classes too
Practice, practice, trial & error = python 👑😂
@narrow grailhere is a cog
class IRL(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener("on_member_join")
async def on_member_join(self, member : disnake.Member):
print(member)
def setup(bot):
bot.add_cog(IRL(bot))
but for me as a beginner is python the best program language I ever seen. It is easier to understand then other program language in my opinion
Why you needing them now?
for file in os.listdir("../utils/cogs/"):
if file.endswith(".py"):
verify_command = client.load_extension(f'verify.{file[:-3]}')
this gives me error no module named "verify"
👍🏼
@cerulean elbow
layout
why is it verify.file
its not verify.file it's in a f string
it is verify.{file[:-3]}
yes
why
it's in {}
what does init and IRL means?
because it's a f string
IRL is the classname, and init is initation of class lol basic python go google "python classes"
the for loop looks for all the files in that directory i specified and then if the file endswith .py it will strip out the .py and load the file name
but i need to do it from my cwd
which is what im trying to figure out and i need help with it
@slate swanit should be like this
for filename in os.listdir('./cogs'):
filename.lower()
if filename.endswith('.py'):
filename = filename[:-3]
if filename in botcogs:
try:
bot.load_extension(f"cogs.{filename}")
Ok I will try and return in 20 minutes I have to go out with my dog
lol
But thanks for the help.
it takes 1 second but whatever
hwy guys
i made meme command with button
but button not giving new meme
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
likes = random_sub.score
comments = random_sub.num_comments
link = random_sub.selftext
button = Button(label="Next Meme", style=nextcord.ButtonStyle.green)
async def button_callback(interaction):
await interaction.response.edit_message(nextcord.Embed(title = name, url = url, colour=nextcord.Colour.random()))
button.callback = button_callback
em = nextcord.Embed(title = name, url = url, colour=nextcord.Colour.random())
button = Button(label="Next Meme", style=nextcord.ButtonStyle.green)
async def button_callback(interaction):
await interaction.response.edit_message(nextcord.Embed(title = name, url = url, colour=nextcord.Colour.random()))
view = View()
view.add_item(button)
em.set_image(url = url)
em.set_footer(text =f"👍 {likes} | 💬 {comments}")
await ctx.send(embed= em, view=view)
this my code
btw kek
all code is not there, only important code
Did you import nextcord?
if button not give new meme its probally cause u dont recall the function that grabs memes
random.choice() only run once
when bot starts?
so per d.py's asycio changes I have this main func which starts my botpy async def main(self): async with aiohttp.ClientSession() as session:is there a way for me to access this ClientSession() elsewhere in my code (in one of my cogs)
obviously
?
no i remove code where theres confidential stuff
when is this runned ```py
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
likes = random_sub.score
comments = random_sub.num_comments
link = random_sub.selftext
button = Button(label="Next Meme", style=nextcord.ButtonStyle.green)
and how
??
I had to ask, sometimes it’s the simple things missing
@cosmic agatei guess no one can help u then
hmmmmmmmmmmmm
what's the problem
cause u dont show code that is part of issue
hmm wait
@bot.command(aliases = ['MEME', 'Meme', 'Memes', 'MEMES', 'memes'])
async def meme(ctx):
all_subs = []
subreddit = reddit.subreddit("meme")
top = subreddit.top(limit = 50)
for submission in top:
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
likes = random_sub.score
comments = random_sub.num_comments
link = random_sub.selftext
em = nextcord.Embed(title = name, url = url, colour=nextcord.Colour.random())
button = Button(label="Next Meme", style=nextcord.ButtonStyle.green)
async def button_callback(interaction):
await interaction.response.edit_message(embed = em)
button.callback = button_callback
view = View()
view.add_item(button)
em.set_image(url = url)
em.set_footer(text =f"👍 {likes} | 💬 {comments}")
await ctx.send(embed= em, view=view)
as i thought ur code
??
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
likes = random_sub.score
comments = random_sub.num_comments
link = random_sub.selftext
``` that gernerates memes is only ran once when so if u click buttons its same meme
simple way would be make a function that returns memes
and use that function on ur button too
hmm
i thought i did 😛 but i will try agian
have a function that generates memes
let it return the data u want to use
and button_callback recall that function again
that way it will rerun the generate_meme function
lol?
my_function():
return random.randint(0,10)
print(my_function())
print(my_function())
whats the use of "!r" python
!e
name="monkey"
string = f"{name!r}"
print(string)
no idea
so it sais same
yes
did u import Cog?
import cog?
pip uninstall cogs
from discord.ext.commands import Cog
ok
i dont even know what idu means
i don't understand
whelp
can u show ur imports
show code
prob forgot import Cog
hahaha i see now xP
42
'r' when read json file
it means read
!open
Opening files
The built-in function open() is one of several ways to open files on your computer. It accepts many different parameters, so this tag will only go over two of them (file and mode). For more extensive documentation on all these parameters, consult the official documentation. The object returned from this function is a file object or stream, for which the full documentation can be found here.
See also:
• !tags with for information on context managers
• !tags pathlib for an alternative way of opening files
• !tags seek for information on changing your position in a file
The file parameter
This should be a path-like object denoting the name or path (absolute or relative) to the file you want to open.
An absolute path is the full path from your root directory to the file you want to open. Generally this is the option you should choose so it doesn't matter what directory you're in when you execute your module.
See !tags relative-path for more information on relative paths.
The mode parameter
This is an optional string that specifies the mode in which the file should be opened. There's not enough room to discuss them all, but listed below are some of the more confusing modes.
'r+' Opens for reading and writing (file must already exist)
'w+' Opens for reading and writing and truncates (can create files)
'x' Creates file and opens for writing (file must not already exist)
'x+' Creates file and opens for reading and writing (file must not already exist)
'a+' Opens file for reading and writing at end of file (can create files)
oh ok tysm!
import discord
import pathlib
from json import load
from discord import app_commands
from discord.ext import commands
with open("../config/config.json", "r") as f:
config = load(f)
intents = discord.Intents.all()
client = commands.Bot(command_prefix=None)
dir_name = "../utils/cogs"
cwd = pathlib.Path(__file__).parent
new_path = cwd / dir_name
path = pathlib.Path.iterdir(new_path).stem
@client.event
async def on_ready():
print(f"Logged in as {client.user}\nID: {client.user.id}")
await client.load_extension(path)
await client.tree.sync()
client.run(config["token"])
dude read the error
if you print new_path does it return a valid path? the iterdir is what is raising the error
yes am sorry am wrong lol
oh ok
and dont load on on_ready plz
python errors say exactly where the error comes from, if there is some python folder in the file path then you know the error is coming from the internals, meaning they passed an arg wrong, not imported something wrong
?? im back
aaah
how to make code for all members counting on all servers where is bot?
@slate swandont load exstentions in on_ready
and consider have a loop for more files u wanna load in future
what
like this
total_users = 0
total_bots = 0
for x in self.bot.guilds:
for y in x.members:
if y.bot:
total_bots += 1
else:
total_users += 1
``` ?
counting in status or in command
learn list comp
I know 😛
https://www.reddit.com/r/memes/.json
you could use this?
@manic wingtheory is same tho
all members in all servers count
json crap
u can grab how many servers with len(bot.guilds)
ik
json is crap for using as database thats all
but json integration crap on discord
database -> json is the way
huh?
yeah
json isnt bad ;-;
json is good if used correctly
nor does it have anything to do with discord
SQlite much better
which is hard
using json correctly is very very simple: use it for data transmission
i mean if u want to call alot json is tiny n fast... cache from database give json to be used/spammed
instead of call database
or to share data like api json is the way
stop
json isnt a database, its a data type, how dows SQL even come in the way of json
tempted to slap you
sum here, but i guess json works if not patiance to learn sql
😔
and has a very small server
but think json is for store DATA as a database ur so wrong
SQL is a language, json is a data format, where are you headed to?
anyways, its ot lol
ddddd
@cosmic agate so, yes, use that, endpoint, it'll save power and be faster
json is a static file it is nothing more than a textfile
^^
hmm
but
what now
But yeah just learn to use a databse
i dont want to complicate things for a meme command
@cosmic agatedid u do as i said?
also idk about OOP
make ur meme_generator as a function
i didnt understand
and call that function for ur button n when use command
pffttt, nvm, just do whatever you want, goodluck
^lol
@cosmic agatebasic python tho, play around with functions so u know how u can call em
or as they call it methods
What permission attribute is for unbanning
does ban_members give permission to unban also?
i use an sqlite database for my discord bot and i wonder if i can make a command which will register everysingle member in a discord server and save their information (id and balance) in my db file? would i have to make a loop which registers them all or can i just get the member list and get them all?
administrator is enough
but not all who have perms to ban also have admin
yes
Please don't give admin to bots for that - yes ban_members also lets you unban
thanks
why not does it cause conflictions?
@cosmic agatei give u one more example of functions so u understand
import random
def number_generator():
generated_number = random.randint(0, 100)
return generated_number
a = number_generator()
b = number_generator()
``` a and b gonna call number_generator() and get a number
just give your bot administrator and it will be able to do everything
sketchy link
no
just no. its not dangerous at all
I see. Thanks
just dont test commands in a server u cant risk stuff in
It is, and the above page explains exactly why
i read those and they are stupid
how would just token get leaked?
just dont be stupid and it wont get leaked dude
dont invite a bot someone tells u to invite
bro
and u safe
how would u possibly leak your token tho
no we are talking about your own bot. he is saying its dangerous to give your own bot admin perms
oh fuck no
Read the page fully
my bot is server-owner
@kick.error
async def kick_error(error, ctx):
if isinstance(error, MissingPermissions):
text = "Sorry {}, you do not have permissions to do that!".format(ctx.message.author)
await ctx.send_message(ctx.message.channel, text)```
i did
any reason why it doesnt say this when someone cant use the command?
and i dont see how a person could leak your token
imo that article is just wrong in so many ways
You could leak your own token, humans make mistakes, as the page explains
"No. As mentioned in point 2 people make mistakes"
would u test commands in a server u care about
how tf would u make a mistake tho
just keep your token for yourself and no one will get it
So you've never done anything by accident before which you regretted?
^
isnt it ctx, error tho
is this an inside joke y'all are playing on me?
just like u wouldnt tell anyone your password u wouldnt tell anyone your token
then its saying ctx is not defined
No
And there's a whole database of millions of passwords online that have been leaked
no shit dude
ctx will be interpreted as the error and error will be interpreted as context
so just because you wouldnt tell anyone doesnt mean it cant get leaked
but ur acting like thats cus someone told them their password
@lusty skywhen u place error, ctx u kinda twist them
how about i do this then. i put my token in my code and never touch it
ctx is always the first parameter (if you arent in a cog, for now, error is working as ctx and ctx is working as error)
and send_message isnt a thing iirc, await ctx.send(text) works
ok
im an idiot
I AM A CERTIFIED IDIOT
giving bot admin
dont be so hatefull
they are saying u shouldnt give your admin perms
and maybe u shouldnt but i dont agree with the arguments they said
Thank you and yeah not using cogs yet I dont have knowledge on it so everything is just in main for now until I move forward
those points have been pinned in this channel for the best part of a year now with no complaints from anyone else
its okay, everybody is (a bit maybe, dont get me wrong please)
@slate swanpost cute emojis
it really doesnt matter
uh
jk lol
if u guys wont give admin perms to your bots thats fine
just kick and reinvite your bot if thats needed
I would never invite a public bot asking for admin persm thats for sure tho
cool cool
and if my bot gets fucked cus i leaked my token i will tell u guys and u can all laugh at me
np i get it
ik
but im just trying to end the argument cus it really doesnt matter lol
it such a small detail honestly
CTRL+SHIFT+i copy the weird line of random numbers n letters ty @slate swan
This might be true for bots, but I'm not so sure about user accounts
but why dont u just youse that link and make life easier 😔
Discord's token scanning works on bot and user tokens, but it only currently happens on github and github gists
idk how to implement
all y'all smart people can also go to #databases and help me out with my discord bots database there thank u very much
@unkempt canyon will delete your message but the token is still valid, neither Discord not the pydis bots will revoke your token if posted in chat
Yes
I said that discord wont revoke the token
It's possible someone uploaded it to github to get it changed, but Discord doesnt actively scan messages for tokens and revoke the tokens, it will display a popup if you try to send tokens now, but no backend automation exists right now to reset them
numbers = list(range(1,100))
@bot.command(alises = ["si"])
async def simp(ctx):
ctx.send("You are " + random.choice(numbers) + "% simp")
sad
string cant be added to int
use randint
ohhhhhhhh
random.randint()
and f-strings and await
mate if you're just gonna use "si" just name your function si
he made a typo on aliases
yeah I figured
but he can use simp too
i was wondering why he didn't get an error about that
i know RoboDanny on the discord.py server automatically uploads tokens to github for discord's system to see
well dunno
perhaps an error earlier on in the code
that's robodanny
mate.
robodanny literally has access to everything
random.randint(<number, <number>)
🤷
did they really name the argument b
yes
what is <>
!d random.randint
random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
ew
mate it's just an example of where to put your numbers
you sound really briish there mate
do i have to put ><
guys i made a meme command

cheers
no
with next meme button


but the button doesnt work
@bot.command(aliases = ['MEME', 'Meme', 'Memes', 'MEMES', 'memes'])
async def meme(ctx):
all_subs = []
subreddit = reddit.subreddit("meme")
top = subreddit.top(limit = 50)
for submission in top:
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
likes = random_sub.score
comments = random_sub.num_comments
link = random_sub.selftext
em = nextcord.Embed(title = name, url = url, colour=nextcord.Colour.random())
button = Button(label="Next Meme", style=nextcord.ButtonStyle.green)
async def button_callback(interaction):
await interaction.response.edit_message(embed = em)
button.callback = button_callback
view = View()
view.add_item(button)
em.set_image(url = url)
em.set_footer(text =f"👍 {likes} | 💬 {comments}")
await ctx.send(embed= em, view=view)
for god's sake

I started being proud of you transil
ey what for those frankly many variables
DEKRIEL I'M LIKE U
The user has no perms to manage_messages and I have a permission check for it to use the clear command but for some reason they can still make the bot clear messages?
Any idea why?
@client.command()
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=30):
await ctx.channel.purge(limit=amount+1)```
@bot.command(alises = ["si"])
async def simp(ctx):
ctx.send("You are " + random. randint(1,101) + "% simp")
bRIJ
bruhhh
has_permissions checks if the user has the guild permissions and the channel permissions if user has the channel permissions then
convert it to an str
OHHH nvm
cast it to a string
use f-strings or just convert it to a str mate
mate
is it late there?
AttributeError: module 'discord' has no attribute 'Intent'
!d discord.Intents
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
Its not my code apparently tho for some reason my alt can still delete messages
Intents
*Intents
without the bot for some reason
huh
why this code not working???
@bot.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, user: discord.Member, *, reason=None):
if not reason:
await user.ban()
await ctx.send(f"**{user}** has been banned for **no reason**.")
else:
await user.kick(reason=reason)
await ctx.send(f"**{user}** has been banned for **{reason}**.")
also check the @ everyone role if it has manage_messages enabled
how does it not work?
also why did you use user.kick lmao
I thought it was a ban command
can anyone give me am example of how this f in string thingy works
could remove the whole check for the reason
!f-strings
Intents*
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
they have an s at the end which is fucking annoying
oooopssssss
import it..
^
import what
forgot to change after copying from my kick command 💀
mate you're copying 💀
@boreal ravine i dont think they forgot to import it though
it would have an attribute error
what is blue?
or if they just used randint() then perhaps
blue is a color
no like the code
!d discord.Colour.blue this?
*colour
classmethod blue()```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour") with a value of `0x3498db`.
??
ty
called it
thats for british 🧞
discord.Colour
🤷
Bog
swamp
pog
yeah
not listed on the docs either
Log water
not documented
pretty sure he's japanese
how are u sure
Yooo… Python… thoughts?
how do you know lmao
go figure
Mate this is discord-bots not python general
with next meme button
but the button doesnt work
@bot.command(aliases = ['MEME', 'Meme', 'Memes', 'MEMES', 'memes'])
async def meme(ctx):
all_subs = []
subreddit = reddit.subreddit("meme")
top = subreddit.top(limit = 50)
for submission in top:
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
likes = random_sub.score
comments = random_sub.num_comments
link = random_sub.selftext
em = nextcord.Embed(title = name, url = url, colour=nextcord.Colour.random())
button = Button(label="Next Meme", style=nextcord.ButtonStyle.green)
async def button_callback(interaction):
await interaction.response.edit_message(embed = em)
button.callback = button_callback
view = View()
view.add_item(button)
em.set_image(url = url)
em.set_footer(text =f"👍 {likes} | 💬 {comments}")
await ctx.send(embed= em, view=view)
If you want to ask questions about python then #python-discussion
how to make your bot send embed?
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
…
Ah I see they have changed Embed.Empty
??
type='poor'?
broke* 
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
check this out, I looked on the docs
'rich' apparently means " generic embed rendered from embed attributes"
i don't like it when kayle types it makes me nervous
just checked, he's from SA, just thought he was japanese because he speaks it 
Your are just incorrect lol idk what to tell you. It’s not a good practice at all
ctx.send(f'You are ' {random.randint(1,101)} '% simp')
removed it entirely*
wil it work
no
why D:
remove the two single quotes inside the string
what did i doo wrong this time
ctx.send(f'You are {random.randint(1,101)} % simp')
i'm working on a discord bot that checks a api for it's contents, but if it hasn't found anything (the api) it just returns {"success":"error"} but if it has it returns {"found":"12"} but if i have foundamount = data['found'] in the same discord command it bugs out when it doesnt find anything. im trying to find out a way to check first if it hasnt found anything and if it has to open a def function that sneds the text of the found things.
like that?
Defer the interaction
maybe, try it and see
wdym
can anyone help?
!d nextcord.InteractionResponse.defer if you don't send anything in the interaction within 3 seconds, you have to defer it
await defer(*, ephemeral=False, with_message=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
use that method at the top of the method by the way
that doesnt help
Check if the JSON that the API returns has a "success" key and if it does, then "open" a function ig
How do I open a function like that?
I've tried opening a function but it never works
Could u give me an example?
Well, you don't. You "call" functions not open them
how to slash commands
How do I "call" a function in a command?
def hello():
pass
hello()
``` sure
OHH
make the function -> call it
wait, but the def function uses await ctx.send(f"found: {found}") and i've tried that before and it didnt work.
Ok
hello