#discord-bots
1 messages · Page 1082 of 1
Should be winner instead of winners
thats what it returns?
An instance of it, yes
wym instance
so to get a date i should do discord.utils.snowflake_time(id).datetime ?
It returns a datetime.datetime by default, you don't have to call .datetime on it again
No that is not it
Can you print out winner and winners?
Well it all worked, until I wanted to add where it pings the winner
I am just looking to ping the winner
oh
And send that embed with it
I know what you're trying to do with it, can you print winner and winners though?
Something strange might be going on
you don't need to print winner - the traceback says its a list. so you must find where you declare it and ensure you haven't done so by initiating a list. perhaps by sending your full code we can assist more @frozen patio
Alright
Here is the code: https://srcb.in/24zJbazGf3
Let me know what I am doing wrong
looks like you're using winner = random.choices() so it's going to return a list
Oh
I'm not sure why you have both winner and winners though
Ok, well, how can I just ping the winner
There are multiple, which do you want to ping?
The winner whom won the giveaway
It looks like your code allows for multiple winners however
Yes
So, you want to ping all of them?
Yes the winner(s) of the giveaway
Bro this loop is giving NoneType object
' '.join([winner.mention for winner in winners])
You need to sort out winner/winners in your code first
You're sure that ID is valid?
Yep
Then it's probably not in your bot's cache, which case you can try to use fetch_channel
ohk lemmie try that
Argument is positional?
so first, you have a table value set here: py time, prize, message, channel, guild, participants, winners, finished = table[0], table[1], table[2], table[3], table[4], table[5], table[6], table[7]
and then later you overwrite that with py winners = []
I would recommend some object naming clarification with that.
Secondly, I would recommend condensing lines 68-74 into a list comp, something like py winner = [guild.get_member(int(user)).name for user in random.choices(participants, k=len(participants)] or k=winners depending on how many people are entered.
Thirdly, you need to use a string comp function to build your message when you send it, typically via the .join() function. ```py
message = f'Congrats to {", ".join([user.mention for user in winner])} for winning the giveaway'
What do you mean?
self.client.fetch_channel()
So i have to give it a channel id so is it keyword or positional?
I don't believe it has to be a kwarg
it is not afaik
Though positionals can be kwargs, so if you want to go right ahead
Just updated the parameter name for my bots command and this
How can I refresh the servers commands?
Yes discord_slash w d.py
Ah, can't assist with discord_slash. Regular d.py I can do
Speaking of, discord.py has built in slash commands, consider migrating to those instead of frankly outdated libraries
Alright, well, why would I have to change those and not the ping
I thought it would be simple just to make a simple ping
my third suggestion solves your ping issue. the first two are simply pieces of advice from 20+ years of coding experience
So I need to put message = inside of the send function
no
you need to declare your message following the format i used
you tried to call .mention on the whole list rather than the items in the list, which is solved by nesting a list comp of user.mention inside of a .join method
I got this error with your fix:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/nextcord/ext/tasks/__init__.py", line 168, in _loop
await self.coro(*args, **kwargs)
File "/home/container/cogs/giveaway.py", line 77, in giveawayCheck
message = f'{", ".join([user.mention for user in winner])}'
File "/home/container/cogs/giveaway.py", line 77, in <listcomp>
message = f'{", ".join([user.mention for user in winner])}'
AttributeError: 'int' object has no attribute 'mention'
user seems to be an int
is there anyway to add an attachment to an embed by a link?
just do
[f"<@{user}>" for user in winner]
@commands.Cog.listener()
async def on_member_ban(self, guild, user):
reason = "Anti-Nuke | Banning Members"
whitelisted = db.find_one({ "guild_id": guild.id })['whitelisted-users']
async for i in guild.audit_logs(action=AuditLogAction.ban):
if i.user.top_role >= guild.me.top_role:
return
if i.user.id not in whitelisted:
await guild.ban(i.user, reason=f'{reason}')
2022-06-03T00:49:52.188846+00:00 app[worker.1]: File "/app/cogs/antievents.py", line 20, in on_member_ban
2022-06-03T00:49:52.188846+00:00 app[worker.1]: if i.user.top_role >= guild.me.top_role:
2022-06-03T00:49:52.188883+00:00 app[worker.1]: AttributeError: 'User' object has no attribute 'top_role'
Any help?
Uhhhhh That worked 1 time
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/nextcord/ext/tasks/__init__.py", line 168, in _loop
await self.coro(*args, **kwargs)
File "/home/container/cogs/giveaway.py", line 80, in giveawayCheck
msg = await channel.fetch_message(message)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/abc.py", line 1513, in fetch_message
data = await self._state.http.get_message(channel.id, id)
File "/home/container/.local/lib/python3.10/site-packages/nextcord/http.py", line 337, in request
raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In message_id: Value "Congrats @frozen patio!" is not snowflake.
well youre trying to use an attribute that the User class doesnt have
well then how do i check if a user is higher than the bot
it needs to be an int of the id of the message
the ID is an int
How can I get this to work many times
remove the .name part of your winner selection list comprehension @frozen patio
^
an if statement
you want it to fetch many messages?
@pulsar bay were you trying to do that comand on a bot?
Ok I fixed that, but if I enter a giveaway with 2 or more winners I win and no one else who enters
No matter how many people entered
…….what
User class belongs to bots I'm pre sure
discord.User is a model, it doesn't belong to anything
oh my bad
@sick birch is there anyway to add an attachment to an embed by a link?
set_image? or....
!d discord.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`.
Inside the embed?
class Fight3(discord.ui.View):
def __init__(self, context: commands.Context):
super().__init__(timeout=None)
self.value = None
self.command_ctx = context```
with my view, `timeout=None` works, but if i plug in an amount of seconds like 5 it instantly times out, anybody know what im doing wrong?
yes, I can't use set_image though
@sick birch
async def setup(bot):
await bot.add_cog(Server(bot))
``` "coroutine 'setup' was never awaited
setup(self)"
did u await it while loading it like
await bot.load_extension()
What version d.py are you on?
setup and bot.add_cog shouldn't be coroutines iirc
With 2.0, yes they are
I'm suspecting that they're on an older version but using the async version of setup, so d.py calls it w/o awaiting
2.0
Anyone here that knows stuff about working with errors and commands.MissingRequiredArgument, getting them to send embeds from a different cog (help embeds)
Because rn I am trying this:
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
ignored = (commands.CommandNotFound, commands.UserInputError)
if isinstance(error, ignored):
print(error)
if isinstance(error, commands.CommandOnCooldown):
m, s = divmod(error.retry_after, 60)
h, m = divmod(m, 60)
if int(h) == 0 and int(m) == 0:
await ctx.send(
f' {ctx.author.mention}, you must wait **{int(s)}** seconds to use the **{ctx.invoked_with}** command!')
elif int(h) == 0 and int(m) != 0:
await ctx.send(
f' {ctx.author.mention}, you must wait **{int(m)} minutes** and **{int(s)} seconds** to use the **{ctx.invoked_with}** command!')
else:
await ctx.send(
f' {ctx.author.mention}, you must wait {int(h)} hours, {int(m)} minutes and {int(s)} seconds to use the **{ctx.invoked_with}** command!')
elif isinstance(error, commands.MissingPermissions):
missing = [perm.replace('_', ' ').replace('guild', 'server').title() for perm in error.missing_permissions]
if len(missing) > 2:
fmt = '{}, {}'.format(", ".join(missing[:-1]), missing[-1].lower())
else:
fmt = ' and '.join(missing)
_message = '{}: **{}** requires the `{}` permissions'.format(ctx.author.mention, ctx.invoked_with,
fmt.lower())
e = discord.Embed(
description=f'{_message}',
color=0xf8a424
)
await ctx.send(embed=e)
elif isinstance(error, commands.MissingRequiredArgument):
return Help.send_command_help()
return error
but the last elif isinstance won't work and I can't seem to figure out how I can fix it
You call .send_command_help() on the bot instance iirc
is that a thing? (edit: ig not)
!d discord.ext.commands.Context.send_help
await send_help(entity=<bot>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Shows the help command for the specified entity if given. The entity can be a command or a cog.
If no entity is given, then it’ll show help for the entire bot.
If the entity is a string, then it looks up whether it’s a [`Cog`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog "discord.ext.commands.Cog") or a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command").
Note
Due to the way this function works, instead of returning something similar to [`command_not_found()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HelpCommand.command_not_found "discord.ext.commands.HelpCommand.command_not_found") this returns `None` on bad input or no help command.
can anyone help me install stuff thru python on linux
python -m pip install <library>
*python3
not really
Why not 
this is hosted on a linux server
Then why does everyone ask to use python3 instead
👀
distros like ubuntu have 2.7 and 3.9 both installed
error : could not find a version that satisfies the requirement random
anyone know?
Yup yup
correct
why not?
?
you don't need to install random, its included in stdlib
the api im using for a seperate command has a bug and if it's not an attachment it wont send as a gif.
may i see ur code
Sure.
@client.command()
async def pet(ctx, *, user: discord.Member = None):
embed = discord.Embed(title=f"Pet!", color=discord.Color.blue())
av = str(user.avatar_url)
replace = av.replace("webp", "png")
embed.set_image(url="https://api.popcat.xyz/pet?image={}".format(replace))
await ctx.send(embed=embed)
okay now how can i install discord.py 2.0
you can use aiohttp to read the bytes of the image @slate swan and then send it as a local attachment
!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.
Would this save the gif to my pc?
check if you have git installed first ,tupe git in the terminal
i do
nope, only the cache
oh, How would I read the bytes then?
pip install -U git+https://github.com/Rapptz/discord.py
!d io.BytesIO
class io.BytesIO(initial_bytes=b'')```
A binary stream using an in-memory bytes buffer. It inherits [`BufferedIOBase`](https://docs.python.org/3/library/io.html#io.BufferedIOBase "io.BufferedIOBase"). The buffer is discarded when the [`close()`](https://docs.python.org/3/library/io.html#io.IOBase.close "io.IOBase.close") method is called.
The optional argument *initial\_bytes* is a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object) that contains initial data.
[`BytesIO`](https://docs.python.org/3/library/io.html#io.BytesIO "io.BytesIO") provides or overrides these methods in addition to those from [`BufferedIOBase`](https://docs.python.org/3/library/io.html#io.BufferedIOBase "io.BufferedIOBase") and [`IOBase`](https://docs.python.org/3/library/io.html#io.IOBase "io.IOBase"):
- make a request to the image url
py res = await session.get("url") - then read the response
byte_data = await res.read()
``` where `session` is an aiohttp.ClientSession
.
try a longer amount instead
doesnt work
nice bug
@keen mural what's yr discord.py version?
2.0 (i think(
custom id set ?
and added it in on ready ?
for persistent
async def setup_hook(self) -> None:
await self.load_extension(ExampleCog(self))
why does this raise
AttributeError: 'ExampleCog' object has no attribute 'startswith'
your tried to do self.startswith()
seems like an error in the cog to me
or used any instance
where....
in ur cog i suppose...
the traceback probably says it
youre supposed to pass a string
wdym
oh wait nvm
just ignore
im dying
👍
the attr error got raised because you passed an object into Bot.load_extension
yeahh yeah thanks

&6hi
Command "6hi" is not found
imagine handling CommandNotFound errors
@bot.slash_command(guild_ids=guild_ids, description="Get your token!")
async def get_token(interaction : Interaction):
global nitrado_api_key
client_guild_name = interaction.guild.name
reference = db.reference(f"/")
value = reference.child(client_guild_name).get()
server_key = value["client_token"]
nitrado_api_key = server_key #Issue Here
bot.run(config.api_key)
If I want to save the last variable server_key as nitrado_api_key in a "global" variable, would this be how or am I misunderstanding what the global means?
imagine handling errors...
Ngl those and MissingPermissions errors are the most common ones @slate swan
if isinstance(error, commands.CommandNotFound):
return
don't send any embeds or messages
that's just dumb
u can't do '/' u need to escape the backslash
so //
no, it's \ that you cant do
fuck me, im high, yea ill go sleep
oh LOL
dont worry about it
because you didn't indent that line
Why y'all acting like Ashley now
@bot.slash_command(guild_ids=guild_ids, description="Get your token!")
async def get_token(interaction : Interaction):
global nitrado_api_key
client_guild_name = interaction.guild.name
reference = db.reference(f"/")
value = reference.child(client_guild_name).get()
server_key = value["client_token"]
nitrado_api_key = server_key #This line should have one indent (which I already did, no need)
🚶♂️ i just pass the commandnotfound and missing permissions ( until its a moderation command)
So, I think I misunderstand the global then.
I'm wondering, how would I use that same variable in another command or is that not possible?
Lol
Or, is that actually all I need to do for that
Okay, let me try it in another, thank you ^^
use bot vars instead of globals
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
shes the only one whos smokes weed
?
well, it appears for me on autocompletes
🚶♂️wait, does it not for you? only in cogs maybe right?
typehint your self.bot to your bot class instead of commands.Bot
ah maybe it doesnt work for vanilla initialising of classes
@bot.slash_command(guild_ids=guild_ids, description="Get your token!")
async def get_token(interaction : Interaction):
global nitrado_api_key
client_guild_name = interaction.guild.name
reference = db.reference(f"/")
value = reference.child(client_guild_name).get()
server_key = value["client_token"]
print(server_key)
nitrado_api_key = server_key
@bot.slash_command(guild_ids=guild_ids)
async def test(interaction : Interaction):
print(nitrado_api_key)
So, the bottom CMD should work fine then, right?
Figured to ask before I go test 😄
I've never used global
if you invoke get_token first, and then test, it should work
Got it, that's the goal.
Thank you ^^
make sure to slide up in the terminal because it may get spammed with an error since you're not creating any response for the test command
Will do, I'm very new to databases and am just trying to get it to work.
Thanks for the help 😄
!docs
!numpy
!docs numpy
nvm you need to tap it
Uh what
How to replace (),
uh?
?
I want to remove (
its a tuple, use the first index
*d, where i'm assuming d is your tuple
yoru 
💀
!e ```py
print((1,)[0])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1
Didn't get that 
Ah yeah
!e
s = "test",
print(type(s))
print(*s)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | <class 'tuple'>
002 | test
@lyric apex ^
Lemmie try
if u get it fine.. otherwise go with what sarth suggested, both are fine
💀 man my keybaord wtf
get better

i am 
you can't compare yourself with yourself
better is a comparative term and is used between two unique objects or subjects
me comparing myself with my young self
💀
no comments
I fixed leave it
....

🎉
Guys how we can take image as input in dpy 2.0?
Would it be possible for someone to click a button and it pulls up a modal? I’m a bit unfamiliar with them. Just thought to ask.
ya it is, u just have to change the view
like !command url-of-image
I’ll probably go struggle with that tomorrow, thank you.
I want to use pil to modify image which user send
ya it should work then ig
what library?
its very possible, you just gotta send the Modal as the response to button click
u can use aiohttp to get the image then use bytes io to read after that u can edit with pil
If I want to add a new random number to an already existing number in a sql database, how would I do that ( adding the new value to the old one and then updating it into the sql database)?
fetch the old value add the new value then update and commit
rn im doing this, but this dont seem to work correctly:
@commands.command()
async def random(self, ctx):
value = random.randint(1, 11)
newvalue = value + value
db = sqlite3.connect('astral.db')
cursor = db.cursor()
cursor.execute('SELECT value FROM test WHERE user_id = ?', (ctx.author.id,))
data = cursor.fetchone()
if not data:
cursor.execute('INSERT INTO test(value, user_id) VALUES (?, ?)', (value, ctx.author.id))
await ctx.send(f'added {value} to db. the value in the db is now {data}')
if data:
cursor.execute('UPDATE test SET value = ? WHERE user_id = ?', (newvalue, ctx.author.id))
await ctx.send(f'added {value} to ur old value. value is now set to {data}')
db.commit()
cursor.close()
db.close()
newvalue here is doing value + value which u are updating later
so ur first step should be to fetch the old value and then add value to that
updating newvalue here will only update 2*random.randint(1,11)
so u should be updating data+value
ah
also sqlite 3 here is sync while discord commands are asynchronous so this will limit this command to only one person use at one time
wdym
multiple people will not be able to use this command
they will?
at the same time
how do i make it so that they will be able to use the cmds at the same time then
with the sql db
u may not notice now with with few people testing rn and such low usage of db the task just gets over done fast when there are more people it will lag
postgresql aiosqlite
aiosqlite?
yeah fair, gotta see how that works then with the whole connecting part
yeah
because i tried that before but it was giving me trouble with doing stuff
as in connecting etc, which made no sense
:<
Can we check an content for ex if that endswith Xyz
That does not work in @paper sluice client wait for event?
ya it should?
yo what is ctx?
@paper sluice if i take
async def filter(self, ctx, filter:str , image):
How can I load the image?
yo do anyone know how can i access a .json file in replit
!d open
open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)```
Open *file* and return a corresponding [file object](https://docs.python.org/3/glossary.html#term-file-object). If the file cannot be opened, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "OSError") is raised. See [Reading and Writing Files](https://docs.python.org/3/tutorial/inputoutput.html#tut-files) for more examples of how to use this function.
*file* is a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object) giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* is set to `False`.)
Read 
lets see
!d json.load
json.load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)```
Deserialize *fp* (a `.read()`-supporting [text file](https://docs.python.org/3/glossary.html#term-text-file) or [binary file](https://docs.python.org/3/glossary.html#term-binary-file) containing a JSON document) to a Python object using this [conversion table](https://docs.python.org/3/library/json.html#json-to-py-table).
*object\_hook* is an optional function that will be called with the result of any object literal decoded (a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict")). The return value of *object\_hook* will be used instead of the [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict"). This feature can be used to implement custom decoders (e.g. [JSON-RPC](http://www.jsonrpc.org) class hinting).
*object\_pairs\_hook* is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of *object\_pairs\_hook* will be used instead of the [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "dict"). This feature can be used to implement custom decoders. If *object\_hook* is also defined, the *object\_pairs\_hook* takes priority.
with open also work for it?
k
or u can send a request to that url and load it using io.BytesIO
most of this is blocking, so run it an executor to not block ur bot
A list of attachments given to a message.
!d discord.Attachment.read
await read(*, use_cached=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves the content of this attachment as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.10)") object.
New in version 1.1.
👀
with open(...) as file:
data = json.loads(file.read())
with open(...) as file:
data = json.load(file)
Is there any github repo which is using aiomysql and nextcord for discord bot ? I just really need an example so anything is fine. I just couldn't find any
you could find repos which have both examples and combine them to use search for a repo with nextcord and another with aiomysql
I know how to use nextcord and aiomysql seperately but idk how to use together

It sound dumb right 😂
like the aiomysql need loop as its args right ? idk what to pass in that
ok have u subclassed ur bot class?
no
async def conn():
pool = await aiomysql.create_pool()
async with pool.acquire() as conn:
async with conn.cursor() as cur:
bot.db = cur
async def main():
async with bot:
loop = asyncio.get_event_loop()
loop.run_until_complete(test_example())
bot.start(token)
syncio.run(main())
this is how u do in dpy 2.0
should be similar to nextcord right ?
now u can access the cursor using bot.db
yeah should be
i havent used aiomysql so there might be a few discrepancies but it should be roughly the same
i got the basic aiomysql intro from pypi tho but their docs are showing a bit diffrent usage u can see which one works for you
async with bot```
the what? Just subclass `commands.Bot` and override `setup_hook` method why even involving asyncio
anyone know to access the discord.py docs and acc find the stuff ur looking for
bc its so confusing
You mean like !d command?
can you show me the other solution ? I didn't understand this
no i asked if he did subclass the bot he said he didnt
class MyBot(commands.Bot):
async def setup_hook(self):
... # do setup stuff here
bot = MyBot(...)
...
bot.run(token)```
Oh ok

Still wtf is async with bot

ah ok
No I didn't mean use help builtin lmao
You actually need to make API requests to readthedocs
to use bot.start u need that
u can do other initlization stuff under that
U do know this isn't a general chat channel or smth and those GIFs suit better in general chats, right? (No offense meant)
none taken
Thanks for understanding
my bot doesn't respond to any commands
no errors either
it runs bit it doesn't respond
@vale wing hmu if u can help
Does it have message content intent on
And messages intent at all
ngl message content intent is a pain and now literally every person who is not well versed with the new discord api changes is gonna have the same. fucking. problem.
Yes I gotta rewrite a huge bot to slash commands 🥲
I tried to scam discord for message content intent but failed
Not me, I already got access to those and members intent
Lmao how
If I find the conversation I will show you
how do i do that
return future.result()
File "E:\first\main.py", line 58, in main
async with bot:
AttributeError: aenter
Ok then subclass it as I showed
Ikr
What use case did u specify
Nextcord doesn't implement this
How do i stop replit from auto updating my modules?or is this something beyond the scope of the channel?
Hi there icy Cirno
Hi hunter
ya this channel isn't really related to replit
Oh ok
How can we send dm in dpy 2.0?
!d discord.Member.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
Do i need to define member ig?
ic still wasting spending money on Nitro huh
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
IDK, I really like the emojis 
Lmao seems like u only changed yr name

Yea I was right
@vale wing can u dm me how to do that intents
async def conn(loop):
pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
user='root', password='',
db='react', loop=loop)
async with pool.acquire() as conn:
async with conn.cursor() as cur:
React.db = cur
class MyBot(commands.Bot):
async def setup_hook(self):
loop = get_event_loop()
loop.run_until_complete(conn(loop))
bot = MyBot(
command_prefix=config.Bot_prefix,
case_insensitive=True,
help_command=None,
intents=intent,
strip_after_prefix=True,
)
...
bot.run(token)``` like this ?
just do this
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(..., intents=intents)
import discord
from discord.ext import commands
import asyncio
class Select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="Send!",emoji="✍🏻",description="Send the suggestion!"),
discord.SelectOption(label="Cancel!",emoji="❌",description="Cancel the suggestion!")
]
super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
async def callback(self, interaction: discord.Interaction):
if self.values[0] == "Send!":
await interaction.response.send_message(content="successfully sent!",ephemeral=True)
class SelectView(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout=timeout)
self.add_item(Select())
class suggest(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def dm(self, ctx,user:discord.Member = None ):
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
await ctx.send("**Send the message you want to send **",delete_after=5)
mes = await self.bot.wait_for('message', check=check,timeout=20)
mes = (mes.content)
await ctx.send(f"This is your message:**{mes}** -\/ select the option below", view=SelectView(),delete_after=5)
async def setup(bot):
await bot.add_cog(suggest(bot))
I made a command to send a dm
I want that when someone select send option from dropdown it sends dm
So where I have to put bot.send_message()?
How
No
which library r u using?
discord.py-self
We don't help with that here sorry
Can anyone help me with this
switch dms?
!rule 5 self bots are against tos
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
i don't care
See it's documentation ;-;
its the same docs with discord.py its a fork
Let's not talk about the lib here please, thanks
its literally discord.py
I never heard of it ;-; use discord.py simple
What the
discord.py-self is a fork of discord.py
I would recommend dpy or pycord
If it is, why not use discord.py itself then?
BRO ITS THE SAME SOURCE, ITS JUST A FORK THAT ALLOWS TO LOG INTO USER TOKENS
Ik it's fork but do that
Go and ask in their support server don't mess up here
<@&831776746206265384> might be able to help us with the situation here
Take a deep breath, please
However, a number of things have been removed. For example:
Intents: While the gateway technically accepts Intents for user accounts (and even modifies payloads to be a little more like bot payloads), it leads to breakage. Additionally, it’s a giant waving red flag to Discord.
Shards: Again, technically accepted but useless.
discord.ui: Users cannot send items from the bot UI kit.
discord.app_commands: Users cannot register application commands.
From the docs
😶
if anyone know please ping me
import discord
from discord.ext import commands
import asyncio
class Select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="Send!",emoji="✍🏻",description="Send the suggestion!"),
discord.SelectOption(label="Cancel!",emoji="❌",description="Cancel the suggestion!")
]
super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
async def callback(self, interaction: discord.Interaction):
if self.values[0] == "Send!":
await interaction.response.send_message(content="successfully sent!",ephemeral=True)
class SelectView(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout=timeout)
self.add_item(Select())
class suggest(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def dm(self, ctx,user:discord.Member = None ):
def check(msg):
return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id
await ctx.send("**Send the message you want to send **",delete_after=5)
mes = await self.bot.wait_for('message', check=check,timeout=20)
mes = (mes.content)
await ctx.send(f"This is your message:**{mes}** -\/ select the option below", view=SelectView(),delete_after=5)
async def setup(bot):
await bot.add_cog(suggest(bot))
I made a command to send a dm
I want that when someone select send option from dropdown it sends dm
So where I have to put bot.send_message()?
Discord.py-self is a self botting library, and we don't permit help with self-bots here
Yes :-()
shutup dude
stop talkin 2 me
!mute 485776789277507585
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1654259218:f> (59 minutes and 59 seconds).
Bruh ;-; talk properly
Hmm, I wonder why some people are like that
Ye they don't have control on them
Can I say something pls
I have something to show ........
See what that guy doing with me
!ban 485776789277507585 nazi references, discord selfbotting, and for completion's sake, blatant disrespect of staff and harassment of other users
:incoming_envelope: :ok_hand: applied ban to @real geode permanently.
Don't even know how to talk ;-!
Send this to @novel apex next time btw 👍
K sorry
Anyway anyone help if possible
wym bot.send_message?
I got this from stackoverflow
do interaction.user.send in the callback
Unfortunately it's very outdated
Please don't copy from stack, especially dpy since most of the answers there are from the async version
dpy changed itself.. 4 times now..?
Isn't this the 3rd time?
And there's outdated code from all four versions out there, and stackoverflow is honestly terrible about updated questions
Pre v1
v1
v2
But i have a variable called {mes} in my command at below of the class so will the variable work?
Idk I started dpy when it was on idk, 1.5 or smth? (2 years ago)
async -> rewrite -> v2 I guess
did they call it v1 when it became async?
I started at 2.0 ;-;
Yea this is the correct one
Because there was a sync version before that
Wait u mean no asyncio?
yes
Literal sync methods?
yep
Sed
Damn, that's.....
How did they handle events..
Syncly
Lmao imagine if 2 people run a command at the same time
Hmm is dpy maintained these day?
use the discord.ui.select decorator, its much easier to work with
The maintainer is back and currently maintaining it, so yes
In callback?
Actually I never used this decorator
!d discord.ui.select
discord.ui.select(*, placeholder=None, custom_id=..., min_values=1, max_values=1, options=..., disabled=False, row=None)```
A decorator that attaches a select menu to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the [`discord.ui.Select`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Select "discord.ui.Select") being used.
In order to get the selected items that the user has chosen within the callback use [`Select.values`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Select.values "discord.ui.Select.values").
Ig writing something big
Good thing the deco also exists
no the way to use it is
class MYSelectOption(discord.ui.View):
def __init__(...):
...
super().__init__(...)
@discord.ui.select(placeholder=..., options=[discord.SelectOption(...), ...])
async def callback(self, interaction: discord.Interaction, select: discord.ui.Select) -> None:
# now do what u want here
Oh means i remove the callback from the class and make that you sent here?
ya, u dont need the Select class u made earlier, a subclass of discord.ui.View is enough here
https://github.com/Rapptz/discord.py/tree/794991adb6bfa6d66b2b977b1d2a6dcb639398d0 wow, the sync dpy version is quite interesting
794991a
on Aug 22, 2015
Git stats
6 commits
Whats this
Dpy in 2015
That's neat
Lol
Lol the server class
Guys is it possible to make our own api?
Ofc
Gonna be a fun experience if u know what u r doing
Can I put emoji in option?
class discord.SelectOption(*, label, value=..., description=None, emoji=None, default=False)```
Represents a select menu’s option.
These can be created by users.
New in version 2.0.
How will the emoji look in @discord.ui.select
u put that in the SelectOption
^^
that list of SelectOptions will be all the options in ur select menu
@discord.ui.select(placeholder="select an option", options=[discord.SelectOption("send","cancel"), ])
async def callback(self, interaction: discord.Interaction, select: discord.ui.Select) -> None:
I did this
Is it wrong?
yes
ur supposed to do label='...', value='...' they are keyword only args
yes
How do events work in dpy
Oof means i did wrong
examples/views/dropdown.py lines 14 to 19
# Set the options that will be presented inside the dropdown
options = [
discord.SelectOption(label='Red', description='Your favourite colour is red', emoji='🟥'),
discord.SelectOption(label='Green', description='Your favourite colour is green', emoji='🟩'),
discord.SelectOption(label='Blue', description='Your favourite colour is blue', emoji='🟦'),
]```
This error stops my loop how to fix that
just format ur options like so in the decorator
@paper sluice
@bot.event
async def on_ready():
bot.add_view(MyView()) # Registers a View for persistent listening
class MyView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None) # timeout of the view must be set to None
@discord.ui.select(custom_id="select-1", options = [...]) # a custom_id must be set
async def select_callback(self, select, callback):
...
@bot.command()
async def button(ctx):
await ctx.send(f"View persistence status: {MyView.is_persistent(MyView())}", view=MyView())
You mean this :)
I found it on pycord docs
Show code?
ya something like that, if ur using discord.py instead of select_callback(self, select, callback) its select_callback(self, interaction, select)
Oh k
Do I Have To Return The Error?
cats 
@paper sluice
@discord.ui.select(custom_id="select-1", options = ["send!"],emoji="❤️")
async def select_callback(self, select, callback):
This fine?
@robust fulcrum ur options should look like this
Ah my mind breaking from thus decorator
Means option and emojis are to be in class?
And this decorator out of class
option is just a list, inside it are SelectOptions
and u put the label, emojis etc in those selectoption
ur using pycord?
@slate swan what do you need help with?
`import discord
import random
TOKEN = 'no'
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_message} ({channel})')
if message.author == client.user:
return
if message.channel.name == 'general-wont-work':
if user_message.lower() == 'hello'
await message.channel.send(f'Hello {username}!')
return
elif username_message.lower() == 'bye'
await message.channel.send(f'Hello {username}!')
return
elif user_message
client.run(TOKEN)`
please use three `
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
ohh
import random
TOKEN = 'no'
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_message} ({channel})')
if message.author == client.user:
return
if message.channel.name == 'general-wont-work':
if user_message.lower() == 'hello'
await message.channel.send(f'Hello {username}!')
return
elif username_message.lower() == 'bye'
await message.channel.send(f'Hello {username}!')
return
elif user_message
client.run(TOKEN)```
so whats the issue?
your indents are wrong
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
No. You need to understand indentation better.
how
Also don't use discord.Clent use commands.Bot
ohh
let me try
from discord.ext import commands
like this u import
ok
can you fix it for me
@slate swan 😄 no.
Anyway. back to why I came here to begin with. Is there a way to tell if a message content is just a file?
yes
What do i use then?
from discord.ext import commands
bot = commands.Bot()
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), This class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.
How do I get guild banners and member banners?
I am doing this rn but it doesn't work:
@commands.command(name='guildbanner', description='view a guilds banner', usage='guildbanner (guild id)', aliases=['gb', 'serverbanner', 'sb'])
async def guildbanner(self, ctx):
if ctx.guild.banner is None:
e = discord.Embed(
description=f'{ctx.author.mention}: {ctx.guild.name} doesn\'t have a **banner**',
color=0xf8a424
)
await ctx.send(embed=e)
else:
await ctx.send(f'**{ctx.guild.name}\'s banner**\n'
f'{ctx.guild.banner.url}')
@commands.command(name='banner', description='view the banner of a user', usage='banner (user)')
async def banner(self, ctx, member: discord.Member = None):
member = ctx.author if member is None else member
if member.banner is None:
e = discord.Embed(
description=f'{ctx.author.mention}: {member.mention} doesn\'t have a **banner**',
color=0xf8a424
)
await ctx.send(embed=e)
else:
await ctx.send(f'**{member}\'s banner**\n'
f'{member.banner.url}')
dm me i can help u
Error?
btw u can simply do member = member or ctx.author
oh lol
Ye
u sure it's d 2.0
Ash will help u
LOL
peek-a-boo
hi ashley
hi north
can u help me perhaps
. (no errors, cant seem to print them out either)
do you have the members intent enabled?
yeah
because all my other member commands work too
it's just the banner ones that don't work
How can I get my bot to open a file sent in chat?
do you have a error handler?
yes i do, and that one isn't printing anything
access them using the attachments property on the Message object, this will return a list of File objects
i've tried that lol
can i see it?
# Listens for any errors and displays them to the user.
@commands.Cog.listener()
async def on_message(self, message):
if not message.author.bot:
message_channel = message.channel
if message.attachments:
await message_channel.send('Theres an attachment!')
message_attachment = message.attachments
print(message_attachment)
for attachment in message_attachment:
if 'vdf' in attachment.filename:
myvdf = vdf.load(open(attachment.file))
print(myvdf)
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
ignored = (commands.CommandNotFound, commands.UserInputError)
if isinstance(error, ignored):
print(error)
if isinstance(error, commands.CommandOnCooldown):
m, s = divmod(error.retry_after, 60)
h, m = divmod(m, 60)
if int(h) == 0 and int(m) == 0:
await ctx.send(
f' {ctx.author.mention}, you must wait **{int(s)}** seconds to use the **{ctx.invoked_with}** command!')
elif int(h) == 0 and int(m) != 0:
await ctx.send(
f' {ctx.author.mention}, you must wait **{int(m)} minutes** and **{int(s)} seconds** to use the **{ctx.invoked_with}** command!')
else:
await ctx.send(
f' {ctx.author.mention}, you must wait {int(h)} hours, {int(m)} minutes and {int(s)} seconds to use the **{ctx.invoked_with}** command!')
elif isinstance(error, commands.MissingPermissions):
missing = [perm.replace('_', ' ').replace('guild', 'server').title() for perm in error.missing_permissions]
if len(missing) > 2:
fmt = '{}, {}'.format(", ".join(missing[:-1]), missing[-1].lower())
else:
fmt = ' and '.join(missing)
_message = '{}: **{}** requires the `{}` permissions'.format(ctx.author.mention, ctx.invoked_with,
fmt.lower())
e = discord.Embed(
description=f'{_message}',
color=0xf8a424
)
await ctx.send(embed=e)
print(error)
try print(member.banner)
still need to make it better tho
raise the error instead of printing
and the indents are messed up ig
which is true because i dont have a member
banner*
But now I tried it with someone with a banner, and it gave me the same thing
the member doesnt have a banner
weird
because, you are running ctx.author.banner
The member I mentioned the second time, it did work
i am not tho
i even changed member = ... to member = member or ctx.author
wheres the code uhh
Oh wait, is it cus i did member: discord.Member = None?
no
huh
code
.
This you mean?
or my current code of what im tryna do now>
@commands.command(name='banner', description='view the banner of a user', usage='banner (user)')
async def banner(self, ctx, member: discord.Member = None):
member = member or ctx.author
print(member.banner.url)
weird
it should work since members intent is enabled too
Yeah, and the person I mentioned with a banner even gave me the same error
banner attribute is only available with fetch methods. This is written in the docs.
and how do i fetch it?
ctx.guild.fetch_member(ID) or bot.fetch_user(ID), you can use the id from member.id
but how do i even get the banner from that
These 2 methods will return a Member object, you can then use the banner attribute
b'"users"\n{\n\t"76561198425649012"\n\t{\n\t\t"AccountName"\t\t"robertmarius8"\n\t\t"PersonaName"\t\t"bob"\n\t\t"RememberPassword"\t\t"1"\n\t\t"WantsOfflineMode"\t\t"0"\n\t\t"SkipOfflineModeWarning"\t\t"0"\n\t\t"AllowAutoLogin"\t\t"1"\n\t\t"MostRecent"\t\t"1"\n\t\t"Timestamp"\t\t"1654036305"\n\t}\n}\n'
When I open a vdf file that I sent as attachment and print it, this is what I get.. How do I clean it up and make it more readable?
if 'vdf' in attachment.filename:
attachment_url = attachment.url
file_request = requests.get(attachment_url)
data = file_request.content
await message.channel.send(data)
print(data)
Also, use aiohttp not requests
I guess you can just .decode("utf-8") it to cast it to string rather than in bytes form
im trying to use that but it's not working
async def on_member_join(member):
guild = client.get_guild(980542229015830568)
channel = guild.get_channel(980542229015830568)
await channel.send('Welcome to the server {member.mention}! Be sure to regulate with rules and verify.') # Welcome the member on the server ````
How come this simple welcome doesnt work with no error and i did enable the intent
this worked \o/
Ngl, I wish there was a way Python allowed us to make a sync and an async function of the same name in the same namespace, which would do different things based on whether it was awaited or not
get_member -> Get from cache
await get_member -> Fetch from API
Would be fun ngl
Oh, that's a great idea
fetch_member & get_member 💀
I think we can make an Awaitable class and mess with __await__, then we decorate the target function with a decorator which make the function Awaitable instance
I don't really know tbh
Or idk mess with the builtins module?
I'll try something
Cool
Do you have a global error handler?
@worn lintel
channel/guild is probably returning None
The problem is that doing await foo() calls foo.__call__(), so we will never know if it's awaited
And if my thought has to be implemented, the change should happen in the Python's core, not on the frontend
This is my best approach, to call the sync func, you need to call it twice
It’s pretty easy, if a coroutine isn’t awaited it’ll warn you with a RuntimeWarning
You can just catch it and then that’ll let you know it wasn’t awaited
!d warnings.catch_warnings
class warnings.catch_warnings(*, record=False, module=None)```
A context manager that copies and, upon exit, restores the warnings filter and the [`showwarning()`](https://docs.python.org/3/library/warnings.html#warnings.showwarning "warnings.showwarning") function. If the *record* argument is [`False`](https://docs.python.org/3/library/constants.html#False "False") (the default) the context manager returns [`None`](https://docs.python.org/3/library/constants.html#None "None") on entry. If *record* is [`True`](https://docs.python.org/3/library/constants.html#True "True"), a list is returned that is progressively populated with objects as seen by a custom [`showwarning()`](https://docs.python.org/3/library/warnings.html#warnings.showwarning "warnings.showwarning") function (which also suppresses output to `sys.stdout`). Each object in the list has attributes with the same names as the arguments to [`showwarning()`](https://docs.python.org/3/library/warnings.html#warnings.showwarning "warnings.showwarning").
The *module* argument takes a module that will be used instead of the module returned when you import [`warnings`](https://docs.python.org/3/library/warnings.html#module-warnings "warnings: Issue warning messages and control their disposition.") whose filter will be protected. This argument exists primarily for testing the [`warnings`](https://docs.python.org/3/library/warnings.html#module-warnings "warnings: Issue warning messages and control their disposition.") module itself.
andy smort
But then, it should be done at the user side?
idk what that is
Make the event and just substract datetime.datetime.utcnow() - the user joined time
Yup
Like u gotta implement them manually in the lib. But the issue is, where to catch the warning and how to get the function name
Can someone link me to the docs where i can get all the info about a member
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
This?
Thanks
Interesting
Lemme dive into asyncio docs
I don't like it
some people would put await randomly and be making API calls accidentally
Yes might be confusing
Since we can consider it a kind of overload
Overloads are not "native" for python
@maiden fable https://paste.pythondiscord.com/utaguyagij.py kinda stuck here, I can't make so that we should call the function upon awaiting
Look at this sussy cringe idea
async def async_sussy_func(id: int, /):
return await some_async_func_to_get_obj(id)
def sussy_func(id: int, /):
obj = get_stuff(id)
return async_sussy_func(), obj
# somewhere in async code
coro, obj = sussy_func()
if obj is None:
obj = await coro```
Very cringe and pointless you could just make a function async
Ima look into asyncio source
!voiceverify
Sure, but you could make it work easily on the library side
It’s pretty easy to override the warning message class, hook the call getting the source, which is the coroutine. Then continuing from there
Ouh, gonna look into that once I get on my PC
Hmm, I'm not sure I understand what you mean, "hook the __call__ getting the source"?
You’ll have to wait for me to get on my laptop, the process itself is easy enough to understand though once you see it
upload it?
!d discord.Message.add_reaction
await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Adds a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
Changed in version 2.0: `emoji` parameter is now positional-only.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
@slate swan Could You Help me how to fix that error my loop stops when the message i fetch is deleted
just handle the NotFound exception in your error handler
return it back?
uh?
Like if the error happens i return that error?
Can u print msg[0] once?
nvm, hunter's gonna help
Ahh it is totally working when the message is present Wait i show
Replit?
Lol
Don't expect me to stick around much
Is that a yes
I don't even know what I've been saying from the past day, you're still better 
Why are you considering the error with replit and yeah i dont use that

Invisible chars
Nah I am just making social survey about replit users
Trying to figure out why tf they use it
Sorry for bothering

What code editor is this anyway
Thats the code
Not the full traceback
He said me to print that msg[0]
Ah
Not the error
Man sorry I am annoying
Np
Go Through the code i am getting a problem like my loop is working fine if the message is present but sometimes the user deletes it so how to avoid it
What u even tryna do bro
I am checking the db with the loop
Why not use async wrapper
?
You have sqlite? Switch to aiosqlite

@visual island so in the class u r accepting two funcs, one which can be called normally and one which can be called asynchronously?
psycopg2 -> asyncpg

It doesn't matter actually, it uses inspect.iscoroutinefunction() do determine the async and sync func
Yea I was also seeing that
What the, builtins module doesn't have an Awaitable or Coro class
Prolly andy was right, gotta mess with the warnings module
But the main issue would be, how to catch the warnings during runtime since there is no function (in discord.py or any other lib) which is invoked whenever a new request is done
I haven't really used slash commands much, sorry
ok np
Maybe dispatch("request") on HTTPClient.request()?
Yea, will have to make a discord.Route class method and call it whenever a request is sent
BTW, still waiting for Andy's solution 
@pliant gulch
Ah okay
Then I got stuff after that, but I’ll ping you when I write it
Sorry for disturbing
I didn't tell you to ping 
Never said u told me to ping
lol thanks
lol ping war
what message are you looking for
Just like y'all pinged me 3 times yesterday lol
@maiden fable
Yea?
go play
Not in a battle royale anyways
stream 
Idk, gonna see if I get a stable ping then lmao
sure 
Everybody having problems verifying their bot like me lately 
been over a week with no response to support emails, someone else has been waiting two weeks fml
another one got two different emails that said it was fixed and one saying it wasn't 
lmao
I waited for 2 months or smth
Not streaming
when you get verified in 20 mins and then there's a bug its just 
Lucky
Hi ded chat
Hi
bro
I'm sorry I couldn't help it
smh
I find that the best technique around bot verification is just not making public bots 
- No intent issues
- No dealing with random users
- No scaling issues
- Easy af architecture for both the bot and database schema
Aka custom bots
no because the verification didn't work and i've been waiting over a week now
wait wdym didn't work? did you get a bot verified email without the bot getting actually verified?
same
- no giving your personal identification
- no intrest xD
- how the hell you gonna monetise?
just pay yourself
D:
by selling your soul to discord
🗿
server I dev for has premium subs/patreon 
No offense to anyone but I feel like the people who pay for discord bots are.... weird (cannot think of a "better" word rn)
if you pay yourself for the bot i'd bet you'd get paid a lot, then you can just use what you earn to pay yourself even more
Make a bot dashboard site and play ads there
generous and/or have a lot of disposable income
not really weird
Or a bot that is just really uniquely useful
if u have 0 coding knowledge and just want a custom bot which does something other bots dont, ig it makes sense to pay and get it made. But if u mean buy ready made bots then yea thats dumb
Well I still feel like spending on smth like a discord bot is just an.... overkill
I know of some mod bots that have advanced unique paid features which some servers just need
I meant like getting Reaction Roles premium and stuff
not really, some bots out here have as much work as any app on the app store
Does your 200 member community server need those features? Probably not
Does a server with hundreds of thousands of members need it? Quite possibly
ah
You're a bit biased in the fact that as a bot developer, you feel like you can create the same feature by yourself for free. Do keep in mind that people who pay for premium features are by no means bot developers, and probably are not programmers in general, so they feel that they don't have an option
Agreed, probably cz I know how to code I am not able to see the other person's pov
Based on my research if you don't have features offered on your patreon and people just pay out of kindness you earn a little over 0.2c per server
game bots with pay to win type stuff get 2c all the way to 14c
Yet P2W "business strategy" never works out in the long run
depends how you approach it robin
Agreed
Personally though I find the discord bot market is more of less taken, there are mostly large bots and people don't often go outside their comfort zone to get smaller bots in
I never really went on the commercial side of it for that very reason
I'd say that's true only for the public side of the market
Well that is the reason we mostly see beginners in the channel 👀
Private single-purpose commission bots are still widely requested
i've found the opposite of this, unless you're expecting millions of servers for some reason
That's a good point
But when compared to profits of larger bots, it doesn't seem like all that much
indeed
You still will have to promote it
But for an independent developer, it can seem like quite a lot and be more than enough, could even consider it a side hustle
yes and no, my bot i made just for fun that's kinda a mess got to 1k servers in 6 months
to make any sort of money you'd need good conversion and 30k+ servers
but the promotion can be net positive if you have retention over 3-4 months (buying cpm at $1)
Well you didn't just make the page and let it be, did you? You did promote your bot somewhere
not for the first bot
Possible but I'd assume quite difficult like as mentioned the public market is largely dominated by other big bots
just let the page be
I've got something like 13k servers now, the hardest bit about monetisation for me is actually being motivated to implement it. There's a lot of moving parts that go into making something that realistically very few people will use
are discord bots good source of income?
Not enough to live off of
Lets just open a company which is gonna make bots for ppl
As an indie developer, that is
Yes, if you get to a critical threshold in the way bots like Dyno have, else no
If you're making a bot as a fun project by yourself, most likely not going to be able to live off of it
Just get an IT job you will get decent salary
bots are the same as anything else, 20% of people earn 80% of the money and 20% of those 20% make a good amount
Or if as mentioned earlier you make private commissions and become trusted and well known
so u need to make a really good bot, then u need really good marketting to get money?
Marketing is probably the hardest part I'd say
To make a public bot that makes a lot of money now you realistically need a lot of money to start with to get there
i'd say technically you don't need a good bot, you just need one people want and then good marketing and a good monetization strategy
Yeah that's one of business principles
MEE6 is proof enough you don't need a good bot, just a popular one 
Lmfao
so this is basically a mini business
Yes
MEE6 is objectively worse than most of its competitors, but people know MEE6, which gives it a massive advantage
its like pycord
btw you can do basic maths on patreons that hide their income
I'll refrain from commenting as a lib maintainer 
owobot is earning at least $2058 a month - 10% to patreon

most bots i've seen tend to earn just under their mid tier though so i imagine around £3
damn
A lot of people who pay a very small part of their own income can still generate a lot of developer income
Bro, that is more than my dad's monthly salary wtf
$3.75 x 2058 = $7718 - 10% = $6945 *12 =
u, teacher?
$83k per year
thats ∞x mine
what do u teach?
DivisionByZero error
Yes I teach accordion and I play it
owo bot is made by multiple people though (i think) so that's probably split
Maths
Most large ones are
Bruhhhh my parent's annual income is like 30k
That's one disadvantage when it comes that
The sus thing is that my accordion costs $5k
!ot you have been moderated
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.

traitor
Moderator
it needed to be done
also bear in mind that owobot has very low conversion compared to other bots
i thought u wr one of us 
im sorry little one
so the bot devs are basically earning thousands by doing almost nothing?
the cap for earning is probably more like $500k a year if you did everything perfectly
Yes just like most of businessmen do
well they did all the work up front so i wouldn't say nothing 
Put effort or money and then just collect money
i imagine maintaining a bot with that many users is hard af too
i am pretty sure those buisnessmen are oil tycoons
And most of them usually just put money
That is why almost
You only need to have a good marketing manager
with anything artistic you can't say that though, you have to make multiple attempts before you make anything if you even do
just responding to issues or bugs and problems would be hard
the reward is you can kind of relax and get some income for a few years when you finally get something that works
||Tony|| Stark
Support role grinders be like: am I a joke to you
also if you think the discord bot market is oversaturated, try to release something on the play store 
Fnaf 69 😉
Gonna become game of the year if google allows payments in russia which it won't do ofc
Counterargument for "the discord bot market is oversaturated": All the simple low effort ideas have been taken, you need to think further outside the box, find something everyone wants that they didn't know they want. There's a lot more ideas available than will ever be used, you just need to find them
yeah well the start and getting your product on market and standing out is always difficult
same for every market and creative thing you can do
the saturation is all balanced based on potential earnings
true if only it were so easy 
welp lets stop before someone warns us
Oh wait play store talk finished 😔
I wasn't able to brag about the project I am working on give my comments
with top.gg you can literally start marketing with $1
for what?
discord bots will always be bland, you make a feature its already probably been done, you make a unique one it gets stolen by the top bots and becomes a feature all bots have and the cycle continues!
idk product management in discord bot channel?...
Well in russia we can't pay to outside countries
about discord bots
eh I disagree
knowing an idea doesnt mean you're gonna be able to recreate it to any level people will want to use
the one who innovates will have an advantage
Btw aias just hit 50 guilds 😀
that's ominous
i mean like the poketwo bot full repo is out but there are no such bots on same level as it is
congrats🎉
btw here's an earning sheet for some bots
min earn is just the minimum based off of patreon lowest pledge
when they don't share their full earnings and just number of patrons
monthly?
yeah the earnings is monthly
thats alot just for a discord bot
epic rpg......
d!discord.user.banner
