#discord-bots
1 messages · Page 1050 of 1
i can share resources through passing in functions, the only issue is self is not something im aware i can pass
You can
(im not)
!d discord.ext.commands.Bot.get_cog
get_cog(name, /)```
Gets the cog instance requested.
If the cog is not found, `None` is returned instead.
Changed in version 2.0: `name` parameter is now positional-only.
Pass this as self to the method
And what I am trying to tell you
# utils.py
async def your_func(bot, *args):
...
# your_cog.py
await your_func(self.bot, ...)
# api.py
class APICog(commands.Cog):
def __init__(...):
# you can construct your API anyhow
await your_func(self.client, ...)```
i would need to pass this on the webserver, which cant use discord.py

Wrap your whole API into a cog and you will have no issues with those between-app communications
how does utils.py get bot?
how to make like command
Just make your web server take in the bot afterwards and it’s pretty much all done
It's parsed as an argument
from?
Cog object
i dont have cogs in the webserver file or access to discord.py
async def carry(ctx, member)
await ctx.send(f"ctx.author carrying {member}")
how to do that cmd?
You didn't hear me well, you need to put your webserver into another cog
And you will have access to everything
im not sure how that would work, how can you have decorators in decorators?
Decorator basically takes a function and returns something instead of it
Or adds that function to somewhere
would i start the webserver on on ready then?
hello people!
does anyone know how to make a discord bot respond to webhooks / other bots.
Better to do it in the overwritten setup_hook method of your bot subclass
on the on_message event, check if message.author.id == webhook user id?
I am pretty sure all those are caught by on_message
hm yes could work.
yup they are, just been doing that
im not sure if putting my whole webserver in a cog is a good idea
TypeError: event() missing 1 required positional argument: 'coro'
what did you do?
@bot.event()
async def on_message(ctx, user: discord.User, *, message=None):
message = message or "This Message is sent via DM"
await user.send(message)```
im just trying to make my webhook do this
@sterile spindle message
and then the bot send the message
@bot.event()
async def on_message(message):
await message.author.send("This Message is sent via DM")
```?
tagged in the on_message?
yes
right okay
@bot.event()
async def on_message(message):
if message.mentions:
user = message.mentions[0]
await user.send("This Message is sent via DM")
can you try that?
sure.
also missed an indent
yup
Traceback (most recent call last):
File "record.py", line 6, in <module>
@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'
@bot.event
async def on_message(message):
if message.mentions:
user = message.mentions[0]
await user.send("This Message is sent via DM")
still got
is this in the main file of your bot? or a cog?
nvm
that works
now i need the message to be arrangeable
so it sends what the webhook says
well the message content you can get with message.content, so replace the string in user.send() with it
because the bot is seeing its own message
to fix that add if not message.author.bot: or for user id follow the message above
use the user id one for that, then
where bouts would i put that xd
sorry im not used to discord bots
how to make to my bot send when u ask .Help to bot send u in dm private message
can it go of by name
message.author == Recording.Mp3
....
@bot.event
async def on_message(message):
if message.author.id == 000000000000:
if message.mentions:
user = message.mentions[0]
await user.send(message.content)
replace 00000000 with the webhook id
thought so
webhooks dont have ids LMFAO so i did it by message.author == "webhook name"
It's just doing some weird loading thing for me
what do you mean?
I'll show u in a min
how pls help
why wont this send?
join_msg = await bot.get_channel(975083898365157376).send(content="<@&925444830480453644>", embed=req_embed)
await join_msg.send()```
mobile issue maybe
Make sure to run it inside a thread
what does this mean?
Message doesn't have a send function
what are you trying to get this to do? send a message with the content <@&925444830480453644>?
yeah
join_msg = await bot.get_channel(975083898365157376)
await join_msg.send("<@&925444830480453644>", embed=req_embed)
would be the way of doing it
not sure if your get_channel will work tho case you arent passing any info or guild id
like when is ur message .Help he send u a private message about help
since someone might know the answer is anything required for slash commands in terms of the guilded side of things because all my bots slash commands do work in dm's but never seem to show in my guild even when syncing them specifically i have no clue what happened over the course of 2 years for them to break and only show in dm's 🤔
have a command named "Help" and listen for a message with on_message
then, have
user = message.author
await user.send("whatever you want")
nice, np
@bot.command()
@bot.command(name="help") yeah
yeah and i add under that
well the name bit isnt needed per-say but i like to have it for clarity
on_message
user = message.author
await user.send("TEST")?
thats the idea
@waxen python how would i make it instead of mentioning the user it does the user id
ik the part for the webhook
can u give me full code?
well its just repeating the message of the webhook... so it has the mention in it
this under @bot.command() ?
hmm could i make it not send the user mention at all
as it seems you havent done discord.py before, i recommend you read the docs on how to get started https://discordpy.readthedocs.io/en/latest/quickstart.html
that would make it a little harder to detect who the webhook wants to dm
a ping in DM doesnt really do anything though, really, right?
true just looks ugly
yeah but i just only don't know to use on_message
and i want to put it in a embed
would a user id 611976655619227648 look nicer 🤔
mrrazamataz
just say how
@bot.command(name="help")
Then what here?
you could take the string and remove the [#00000000000](/guild/267624335836053506/channel/00000000000/) from it
yeah but i would have to manually do that or could the bot do it
the bot could do that
could make it split it
like split this out
f"<#{user.id}>"
it indeed works
mentioned, text = message.content.split(">")
how would i do user.send(embed)
@bot.command(name="help")
async def help(ctx):
user = ctx.author
await user.send("help blah blah")
i think should work
same as a normal message
await user.send("text", embed=embed)
ty
pls beg
@commands.command(aliases=["disconnect", "leave"])
async def stop(self, ctx):
await ctx.author.voice.channel.disconnect()
whats the command to make the bot disconnect?
You would do ctx.voice_client.disconnect()
first i tried it with voice_bot and second error is with voice_client
does anyone know how to add a reaction to a message (using discord token)
I'm trying this but it's not working:
`import requests
import emoji
def add_reaction(emoji):
headers = {
'authentication': discordToken
}
r = requests.put(f'https://discord.com/api/v8/channels/channelID/messages/messageID/reactions/{emoji}/%40me', headers=headers)
add_reaction(emoji.emojize('🎉'))`
whenever my bot sends a message in response to slash commands it sends it as a reply
is there a way I can send it as a normal message?
is your bot in a vc? note that when you stop the bot while its in a vc and restart it, the discord.py cache thinks that its disconnected
!d discord.Interaction.channel
The channel the interaction was sent from.
Note that due to a Discord limitation, DM channels are not resolved since there is
no data to complete them. These are PartialMessageable instead.
!d discord.PartialMessageable.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...
thanks :)
oh and btw
will this bypass the 3 second timeout
or do I have to run it outside the slash command block
alright thanks
can't import interaction from discord
tried using discord.interaction too, both didn't work
am I doing something wrong?
what library are you using?
discord.py and discord_slash
no idea, that's extremely outdated and doesnt have docs either
which is
discord_slash
you need to defer the interaction, that would be the solution
but idk how to do that in discord_slash, thats the point
yes im using discord.py for this
since the stuff above is discord.py I assume
oh okay got it tysm!! it works
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
import datetime
import emoji
import os
import random
client = discord.Client()
bot = commands.Bot(command_prefix = "!")
bot.remove_command("help")
@bot.event
async def on_ready():
print("Im online")
Bot.wait_until_ready
client.wait_until_ready
game = discord.Game("with your feelings")
guild = bot.get_guild(811624953740263476)
await bot.change_presence(status=discord.Status.online, activity=game)
extenstions = []
if __name__ == '__main__':
for extension in extenstions:
try:
bot.load_extension(extension)
print(extension)
except Exception as error:
print(error)
bot.run(os.environ[(TOKEN)])
the 'TOKEN' is actually the token in my code
its saying the token isnt defined on vs code is there another way to get the token to connect to the bot
you can't use the commands.Bot AND discord.Client, it's one or the other
commands.Bot is just the subclassed discord.Client with commands and tasks built on top
also, don't do shit in on_ready
also, you can set the presence of the bot straight in the constructor
it had worked on github/heroku so i assumed it would work on vs code
you have to load the env to be able to get a variable from a .env file
google has examples
nope
reading out variables from a .env file has nothing to do with dpy
from what i see do i call it
dotenv.env
with the like token =
ive called it in using
import os
from dotenv import load_dotenv
load_dotenv()
i got it now
thx for the help
How's this for a terms of service and privacy policy?
https://pastebin.com/Jsw6MNFW
I'm not a lawyer, can't say
Looks like you took my suggestion seriously haha
it has been something i've thought about a bit before. i imagine legally it doesn't offer much protection but better than nothing
I'm trying to make a command that just simply says the guild name but i cant get my head around it
Aloo: almost right, you want ctx.guild.name
also, closing apostrophe and right curly brace seems to be swapped
first, make sure you have a correct command
since you're actually not making a command, you're just using on_message in a way that "looks like" a command
you should check out the docs on how ot correctly make a command
then how have you even been learning?
yt vids...
please don't tell me through YT
don't learn frequently changing libraries through YT vids, they quickly get outdated and irrelevant
you can learn python fine with YT, just not any libraries that change often
i see
so, start with reading documentation I'd say, basic examples etc etc
mostly, YT tutorials are TOO focused on one subject or even have a bad implementation
thank you
W-
@commands.command(name='logoff')
async def logoff(self, ctx):
await ctx.send('`Bot Is Logging Off`')
await self.bot.close()
print('Bot Logged off')
RuntimeError: Event loop is closed
Process finished with exit code 0
M-
use stop()
Might work better for ya
just stop()?
nvm 💀
stop is just my implementation totally forgot that's not a function in the library
lol
it is
just not a method of the Bot class
!d discord.ui.View.stop
stop()```
Stops listening to interaction events from this view.
This operation cannot be undone.
Hi! Tryna make a sticky message type thing, buyt it deletes the message that's it's not meant to
@commands.Cog.listener()
async def on_message(self, message: disnake.Message):
channelID = 976266566972887090
appEmbed = disnake.Embed(
title = "Apply!",
description = "Press the button to apply for that game.",
colour = disnake.Colour.random())
if message.channel.id == channelID and message.author.id != self.bot.user.id:
await message.channel.send(embed = appEmbed)
async for x in message.channel.history(limit = 10):
if x.embeds[0].title == "Apply!":
await message.delete()
Written in Disnake
Yes, so basically when a message is sent, it resends the message (appEmbed) and deletes the previous message (appEmbed)
Sup guys
It's for a uhh application thing, you press a button, it makes a thread, but it moves the embed up, so a solution to that is to delete the previous message and send it again, no?
Never made a discord bot before and just learnt python anyone wanna help me lol
Depends, what do you need help with and what are you using for a library?
Like is it discord.py, nextcord, disnake, hikari, etc
Uhh idk too much I was planning on importing discord
😅
Uhh right well my personal recommendation is to use the library Disnake, but each to their own.
Main reason for that is that it's updated frequently and has a pretty decent guide
That sounds to be Discord.py
Is it easier than discord.py?
Yep it is
Haven’t rlly commuted lol I didn’t even know there was more than 1
They're about the same difficulty wise, but Disnake has some features over discord.py I think(?)
oh boy
Huh?
Also another thing, don't use replit as a permanent host, it can cause your bot to get rate limited very easily
What happened lol
So like it's fine for developing it
What’s rate limited
I wouldn't
Huh
Build up good habits from the start
😅
But not for hosting it
I only have replit lol
Save yourself some trouble, and download an IDE like Pycharm or an editor like VSCode
A rate limit is basically how many requests you can send to discord per second or minute I think(?)
You do, it needs a machine to be online 24/7 to be able to run
Yes.
Wow
You're able to get stuff like uhh Railway or Heroku that can host it tho
Cloud services
Ig I’ll be using replit for development lol
Also if you don't have an intermediate understanding of Python, I'd recommend you go do that first before attempting discord bots
Like robin said tho, break bad habits and try and use something other than replit
I got a intermediate python certificate from Sololearn
You're only going to hinder yourself with basic python knowledge
I mainly learnt on ios
oh boy
😅
Never heard of them, can't tell you if it's any good. If you feel ready, that's more important that a certificate
you got a laptop or anything?
Yea I know more than basics I would say
an ios is arguably the worst thing to code on
Make sure you understand concepts such as asynchronous programming, coroutines, the event loop, etc
Hmm let’s say yes but it sucks hard
this is coming from the same person using a phone to code
Ive been trying to tell em that lol
Lol
Shit up anonymous
I'm using an android which is a bit better
XD
Lol
How hard?
Anonymous explain
Bottom line is a laptop or desktop is preferable
I don’t wanna use it let’s just say
Mobile is fine but it's going to be a terrible developer experience
this tbh
I’m making a basic bot to learn lol
You can make a discord bot on mobile, but its 1000x easier on desktop lol
I agree, it's a pain in the arse
I wanna learn first tho
Guysssss this is for learning
Not to make a actual working bot
I would like to know how to make a button using discord.py.
This would be an example of what I want:
My Code:
import discord
from discord.ext import commands
client=commands.Bot(command_prefix=&...
help pls
When I wanna do that I’ll do it on pc
We know, but it's difficult to learn when you're being held back by your platform
Which is not something that should hinder one's learning experience
I use replit just fine lol
If you say so
Uhh oki
Does replit even support disnake?
Oof
Good question
Hmm where did everyone go lol
Uhh guys
Guyssssdd
@oblique laurel not working out : (
Just wait a bit ig for other ppl to be online
Uhh ok
You dont need to learn everything by tmrw ;)
I do need to know how to set it up tho :0
Try running the example code from github and see what it does with your bot
Also rule no. one, never share your token
Yeah dpy has a server
Also if anyone wants to help a professional idiot dm me :p
Good evening, I got an issue :
I'm currently displaying a message which contains a ui.Select menu, when I select an option I want to edit the current message with another one - I'm using a subclass of Select and the callback method but I'm facing a "discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook" when selecting an option..
Here is the code of my callback method :
async def callback(self,interaction : Interaction):
embed = discord.Embed(color=0x152dff)
embed.add_field(name="Pari selectionné", value="Placeholder text", inline=False)
view = View()
view.add_item(Choice1())
view.add_item(Choice2())
await interaction.edit_original_message(embed=embed, view=view)
Yes
It supports pip packages iirc
Try looking there..?
Import the variable or make a function that returns the value of it and call the get function from where you need it
how can I make a button in discord.py
Check discord.ui.Button
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
If I'm not mistaken, yes
Pretty sure you have to defer it first?
Then ; in your main.py =>
client.myVariable = "placeholder"
in your cog =>
def __init__(self,client):
self.client = client
print(client.myVariable)
Yep, I did not know it - thanks 🙂
use bot it looks better than client
what does this mean?
thats weird my bot isnt on
means others variable was used, but it wasn't initialized (set) before, likely because condition if teamsinuser[i].name in teams: was never met
you should know about variable scopes before you really start any project, thats a must
why do you need it? while True: is an infinte loop which prevents bot from doing any logic related to reactions on events
It depends on what you're doing inside it
If it's async you may be able to get away with it
before the loop, set others to anything, like None
you cant....., an infinite loop is blocking, you might want to use asyncio and run it in an event loop maybe correct me if im wrong
the for i in range ... loop
Again, depends on what you're doing inside the while True loop
discord.py internally has a few while True loops (e.g for polling websocket events, heartbeating, etc) that don't block
while True: loop means you're checking something or counting maybe, it can be rewritten using different logic probably
you could count without a loop too
and without range
and again, check stuff without a loop
nah youre right
making a task wont block the bots heartbeats
pykawaii lmao
😳
also, second for i in range(0, len(roles)): should be for i in range(0, len(teamsinuser)): following your logic
i think you could get away with an infinte loop with asyncio.sleep(0.1) for example
just what I wanted
what
yes, but you want to loop through teamsinuser roles, which you take len(roles) as a size of it... len(roles) may (and will be) different than len(teamsinuser)
the wrapper, I wantef those stuff for my bot, but I was just too lazy to do api stuff lmao
ah lol im still having a bit of problems with relative imports so i suggest you dont download it still until its functional
yeah probably i have an exam in 3 hours anyways, so probably gonna get some rest
ah alright good night🫂
😔
thanks
i have an exam tomorrow as well but i need to fix pykawaii first
gl
thankee
hey guys, just curious about how some of you would implement an inventory system in a database
Like if I'm storing my discord users ID's in a database and I wanted them to have inventories for items, how would you guys go about doing that?
More of, use an ORM
wait, werent you doing the same thing a few days ago...
TABLE Items
id PRIMARY KEY,
name TEXT
TABLE Inventories
id PRIMARY KEY,
user_id FOREIGN KEY REFERENCES Users.id,
TABLE InventoryItems
id PRIMARY KEY,
item_id FOREIGN KEY REFERENCES Items.id,
quantity INTEGER DEFAULT 1,
inventory_id FOREIGN KEY REFERENCES Inventories.id
``` something like this?
bad
wait, no
what?
👍
@slate swan bro your banner 🤣
Got an error NameError: name ‘fetch’ is not defined code: py @guild.command() async def emojis(ctx): emojis = await fetch.emojis() try: emojiEmbed = discord.Embed(title=f”Emojis for {ctx.guild.name}”, description=emojis) await ctx.send(embed=emojiEmbed)
!d discord.Guild.fetch_emojis
await fetch_emojis()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves all custom [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji")s from the guild...
Got it from this tho
it's underscore not a period
and its a method of the guild class lol
undefined name ‘fetch_emojis’
so it would be await ctx.guild.fetch_emojis()since Context has a guild attr which returns a Guild object
was gonna say this ^
Mhm. Let me use it
if you want to get all emojis the bot is in just add the bot/client object instead of ctx
@slate swan are you good with async requests?
ig
Nothing
?
I meant to send this before
But it is sent now
@slate swan
async def web_scrape(text):
async with aiohttp.ClientSession() as session:
async with session.get(text) as r:
status = r.status
if status == 200:
text = await r.text()
return text
@client.command()
async def wyr(ctx):
text = await web_scrape("https://either.io/")
soup = BeautifulSoup(text, 'lxml')
l = []
for choice in soup.find_all("span",{"class":"option-text"}):
l.append(choice.text)
embed = discord.Embed(color=discord.Color.blue())
embed.set_author(name = "Would you rather..", url="https://either.io/", icon_url=ctx.author.avatar_url)
embed.add_field(name = "EITHER..", value=f"🇦 {l[0]}", inline=False)
embed.add_field(name = "OR..", value=f"🇧 {l[1]}", inline=False)
msg = await ctx.send(embed=embed)
await msg.add_reaction("🇦")
await msg.add_reaction("🇧")
takes like 2-3 seconds to actually send the embed, any way to speed it up?
I’m getting this
@guild.command()
async def members(ctx):
mem = ctx.guild.fetch_members(limit=100000)
await ctx.send(mem)
code ^
its probably because of the for loop and your function can be done better
try this
@guild.command()
async def getmember(ctx,member:str):
print([i.name+'#'+i.discriminator for i in ctx.message.guild.members if member in i.name+'#'+i.discriminator])
U can't have it in a cog?
# old
async def web_scrape(text):
async with aiohttp.ClientSession() as session:
async with session.get(text) as r:
status = r.status
if status == 200:
text = await r.text()
return text
# new
async def request(method: str, endpoint: str, /) -> dict["Any", "Any"]:
async with aiohttp.request(method, endpoint) as payload:
return await payload.json()
is what i do
A subclassed of HelpCommand?
Why is there only 3 quotes
you saw nothing
would I need to change my code in the actual command?
Kek
i mean if you want better speed yes and you should send the embed before the for loop
Oh
how much faster would it actually be
which the for loop or the function?
the entire command as a whole
your site waifu.pics is sick asf btw
😳
well it would yes
Oh and
Whenever I use a subcommand the parent command is also invoked
how much faster do you think it'd be though?
Like this:
Aliases is parent command
!d discord.ext.commands.group
@discord.ext.commands.group(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Group`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").
This is similar to the [`command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") decorator but the `cls`
parameter is set to [`Group`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group") by default.
Changed in version 1.1: The `cls` parameter can now be passed.
you can timeit
with my old code it was about 3 seconds
In the parent command?
Or subcommand
yes sir, inside the group decorator
remember python is an interpreter language so most times it would read from top to bottom and if you execute a coro before a blocking for loop it would be faster yes as the coro before wont get invoked until the for loops is done with its iteration
🏌️♀️ quite the opposite when it comes to decorators
the thing that sucks more is typehinting them
😭
what
this is definitely not what i asked you to do
@slate swan TypeError: request() missing 1 required positional argument: 'endpoint'
?
you need to pass the endpoint url or have a base url
wdym?
the site im requesting is already in text =
at line 25 u got smth wrong module
yeah ik but it has 2 arguments
the first one is for the http request method and the other one is the url
its just a check that failed because the function wasnt a coroutine
!d asyncio.iscoroutine
asyncio.iscoroutine(obj)```
Return `True` if *obj* is a [coroutine object](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This method is different from [`inspect.iscoroutine()`](https://docs.python.org/3/library/inspect.html#inspect.iscoroutine "inspect.iscoroutine") because it returns `True` for generator-based coroutines.
so I need to add something before the actual "either.io"
yeah just pass "GET"
since it seems like in your old code all the http request methods are get i suppose
and why is this request not with a session?
how to i make when u send .Help to bot send u in dm a help message
I'm new to python. and I wanna how u can combine a string with a number and then combined it again with a string
For example 'Hi im' + 20 + 'Years old'
aiohttp has a method which starts a session in the back so you wont have 2 nested context managers
!d discord.ext.commands.Context.author
Union[User, Member]:
Returns the author associated with this context’s command. Shorthand for Message.author
!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...
You've received an answer in #help-cake.
I got, ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'
do I disable content_type?
xcirno knows everything😳
ahhh it returned text well just dont parse it and just return the payload
i thought the api returns json as most do😅
it's not an api
ah what is it a website?
yes
yeah i figured as i rechecked and the function name is web_scrape
yeah
so what do I do instead?
how to my bot keep be alive?
host it somewhere
just dont parse the payload and return the unparsed payload
yeah but i don't gonna have my cmds
what's the name for it again
sorry,?
name for what exactly?
the unparsed payload
async def request(method: str, endpoint: str, /) -> "Any":
async with aiohttp.request(method, endpoint) as data:
return data
this is what i ment
and my actual command code would remain the same?
or just with the get
the coroutine aiohttp provides await ClientResponse.json() just parses the payload and makes it into a dict
yeah its just more optimized
what do I have to await?
coroutine 'ClientResponse.read' was never awaited
well the line where an instance of ClientResponse is getting used to invoke ClientReponse.read
I dont see one?
show traceback
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'coroutine' object has no attribute 'startswith' C:\Users\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py:80: RuntimeWarning: coroutine 'ClientResponse.read' was never awaited self._context.run(self._callback, *self._args)
can you show your code
async def web_scrape(method: str, endpoint: str, /) -> "Any":
async with aiohttp.request(method, endpoint) as data:
return data
@client.command()
async def wyr(ctx):
text = await web_scrape("GET", "https://either.io/")
soup = BeautifulSoup(text, 'lxml')
l = []
for choice in soup.find_all("span",{"class":"option-text"}):
l.append(choice.text)
embed = discord.Embed(color=discord.Color.blue())
embed.set_author(name = "Would you rather..", url="https://either.io/", icon_url=ctx.author.avatar_url)
embed.add_field(name = "EITHER..", value=f":regional_indicator_a: {l[0]}", inline=False)
embed.add_field(name = "OR..", value=f":regional_indicator_b: {l[1]}", inline=False)
msg = await ctx.send(embed=embed)
await msg.add_reaction("🇦")
await msg.add_reaction("🇧")
well i dont really see anything related to the traceback itself
my code is probably incorrect
nvm i figured it out
254*
can you show more of the traceback?
The user’s unique ID.
How?
shouldn't it be return data.text()
yeah rud0lf is right you forgot to parse the data as text
why does mine look different? i use message.author.id
it'd be return await data.text() no?
well Message.author returns a Member | User object
!d discord.Message.author
yeah
hmm weird, it's taking the same amount of time as before
is the only way of deleting a message is only purge?
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to
delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages")
permission...
well its your for loop
let me try
do I just remove it then
since youre iterating through the elements its O(n) the more elements their is the more time it will take since its not linear
and im guessing you cant speed that part up?
wait. so what message will the bot delete?
the message that triggered it?
or the bots message?
depends on where you use the method and on which instance
there is still a way to make your for loop not block anything but its kinda over kill
let me see it
any help?
copy that text and send it here
does someone know how to my bot keep alive but to i don't host somewhere
if it's alive it's gonna have to be hosted
def for_loop():
for num in range(101):
print(num)
bot_instance.loop.create_task(for_loop())
since youre creating a task with the loop attr the Bot class has which returns a AbstractEventLoop it wont block anything in your code but in your case you should leave your for loop to execute first as it depends on the results of it
it has to be a coroutine
that's to complicated for me
😅
what did you code your api in?
my api wrapper?
the actual site
Crython
well its not really my site its someone elses i just made a wrapper in python for it
yeah but i don't gonna have my commands
oh I thought you made the waifu.pics site
can u give me an example on how to use it?
nah i made a wrapper for that api
ahh Nice though
my bot gonna have of that site commands
not mine what i maked
since Context.message returns a Message object you can use the method on it
!d discord.ext.commands.Context.message
The message that triggered the command being executed.
Note
In the case of an interaction based context, this message is “synthetic”
and does not actually exist. Therefore, the ID on it is invalid similar
to ephemeral messages.
I don't understand what you tryna say sorry @slate swan
Web api ?
yea
depends on what you use you can use Flask or django or fastapi if you want to use python
this is the code
@client.event
async def on_message(message):
if message.content.lower() == "!delete":
await message.channel.send(f"{message.author}> Okay")
Now how do i add it?
Flask is not async ig 
fastapi, I just wanna make an api for random images. is it hard?
well it depends if you want your api to be async
well i havent really tried it but it probably is
Is it possible to loop a try: expression x times, and if there are any exceptions in those x attempts, for it to go to the except?
message in this case is an instance of the Message class so you can use it with that
Sounds like a question for #python-discussion
It is better to use fastapi in most cases
havent tried fastapi lol
cna u do an example cause reading it example confused me .-.
Did u try pygame 
what is this self._listeners?
I ask this because there is a method listeners = self._listeners.get(event) is using this attribute but I can't find its real instance
discord/client.py line 212
self._listeners: Dict[str, List[Tuple[asyncio.Future, Callable[..., bool]]]] = {}```
its a dict with events to listen to iirc
nope
await message.delete()
in line 212, there are only type annotation there
oh im just missing the ()
yeah because it will get mutated later on in some methods hence the annotations
what does () mean? like what does it do?
👀
its calling the object
a function or somthing?

a function is an object yes
no, notice the = {}
okay thank yo
!e
def a():
...
print(type(a))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'function'>
since it hasnt been called no return type has been given so its not literal to anything
just to a function obj
you can use elipsis instead of pass?
I am finding where the bot will register all events. Seems that mutate is that. But I can't see where the invocation located.
how do I send embed? do i use the JSON format thing? where I type
!d discord.ext.commands.Context.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
This works similarly to [`send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.
For interaction based contexts this does one of the following...
use the kwarg
the events are saved in that dictionary, and are invoked using bot.dispatch if thats what you are looking for
what .-.
error:
right youre using TextChannel
@client.command()
async def gstart(ctx, prize, donor, host, *, msg):
now = datetime.now()
embed = discord.Embed(title = f"{prize}", description = f"Hosted By: {host}\n Donor: {donor}\n \n Message: {msg}", color = discord.Colour.random())
embed.set_footer(text = f"1 Winner | Started At {now}")
my_msg = await ctx.send(embed = embed)
await my_msg.add_reaction("🎉")
await asyncio.sleep(15)
new_msg = await ctx.fetch_message(my_msg.id)
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))
winner = random.choice(users)
await ctx.send(f"Congratulations! {winner.mention} won the prize: {prize}!")
``` code ^
!d discord.TextChannel.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...
it would be await message.channel.send(embed=embed)
message.channel.send?
make an embed using discord.Embed object and use the embed kwarg in send()
well yes channel returns a TextChannel object which then you use the send coro
can i do this? ```JSON
message.channel.send({
"content": "aaaa",
"embeds": [
{
"title": "wahhp",
"description": "em cool",
"color": null
}
],
"attachments": []
})
are invoked using bot.dispatch . where is the line invoke bot.dispatch then?
no. we are not doing discord.js
but if you still want to do something like that , this exists:
!d discord.Embed.from_dict
classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") to a [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") provided it is in the
format that Discord expects it to be in.
You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
?
hold on wth is kwarg
!kwargs-args
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
• Decorators (see !tags decorators)
• Inheritance (overriding methods)
• Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
• Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
anyways im going to sleep, good night guys!
give me an example can u?
any help?
the thing is that discord.py does not document a lot of important internal stuff 🙂
discord/client.py line 395
def dispatch(self, event: str, /, *args: Any, **kwargs: Any) -> None:```
well its just arguments that get called by their name, i gtg so sarth can probably explain it to you
async def on_message(message):
if message.content == "!embed":
Then what now .-.```
why would they?
ok ig
@slate swan mind helping me?
those are not really something which needs to be hidden from users, if they really are, just use private methods and variables......
I found this too yeah. But this code won't run itself.
The most possible line would be Line366 in gateway.py
But ws._dispatch = client.dispatch are not looping over anything too
its not really hidden from anyone its like treasure anyone can find it but only certain people can open the chest
and then dispatch has this component listeners = self._listeners.get(event)
ofcourse events are meant to be worked along with the gateway events....
so the focus shift from dispatch to _listener (dict)
never said that they hide it, they cant
discord.py does not document a lot of important internal stuff
well that does nothing but get the list of functions which are registered for an event, just like any other dict.get works
nvm figured it out .-.
Those are not really something which needs to be hidden from users
but you clarify here that its "hidden"?
i think you ment enlighten?
i know dispatch reads that dictionary, but which function fill that dictionary up? that was my question
!d discord.ext.commands.Bot.add_listener for Bot class
add_listener(func, /, name=...)```
The non decorator alternative to [`listen()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
Changed in version 2.0: `func` parameter is now positional-only.
the @event decorator for client and bot both
Flatten is deprecated
not everyone likes digging into the source code, documentation is the general way to learn about the functionality of a Library
Use an async for list comprehension
you dont really have to dig when the src is already given to you
unrelated to your problem, try using now = f'<t:{int(time.time())}>' for more timezone-friendly solution
and even if they don't want to show that in docs, adding comments/documentation is important while making a Library isnt it?
well you dont even really need to see the documentation of a lib to learn about it
quite ironic
i just read its source when i wanna know deeply about it but documentation is just a shortcut
client.run(token) --> goes to client.py.
And which lines it relates to bot?
and some libs docs offer source code location
Bot is a subclass of Client, it uses Client's .run()
really?
!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...
i said "Bot" is a the subclass of Client, not Client is the subclass of Bot
you are looking in the opposite way.
but it's running client, not running bot
then, your events work with setattr
discord/ext/commands/bot.py line 1377
class Bot(BotBase, discord.Client):```
discord/client.py line 1133
setattr(self, coro.__name__, coro)```
they just set those methods using @client.event
wait, running client would trigger any bot command? as you said bot is the child
if you are using Client, Bot things wont bother you
? it should be some line to link them otherwise your viewpoint is not valid
not at all
!e ```py
class A:
name = "parent class"
class B(A):
name2 = "child class"
a = A()
print(getattr(a, "name2", None))
``` the B class which is a subclass of A has name2 variable in it, but that doesn't affect the parent class A
@slate swan :white_check_mark: Your eval job has completed with return code 0.
None
but if you did B().name, it would get the "name" from its parent class A, thats how inheritance works.
you got the same result by deleting class B
you mean if i did the same for B, it will still return None?
this return None as well
thats not the point
or actually that is, i said the Bot class wont bother Client , even if it stays or not
you just proved what i said....
^^
what do you mean?
. what did you mean here?
my viewpoint is parent class won't link to any child class command.
what else did i say?
and then you say the opposite of what u r saying now
read the messages below that? xd
.
.
you were taking about listeners, and client doesn't have listeners, bot does.
doesnt exist
!d discord.ext.commands.Bot.listen does
@listen(name=None)```
A decorator that registers another function as an external
event listener. Basically this allows you to listen to multiple
events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").
Example...
difference between listeners and event is
you can have only one event
but unlimited listeners.
yeah so the question would be how client calls bot's method
why not just use Bot
it does not~
hey client.run(TOKEN) could load @events
that's not a problem of choice, it's actually working like this
client does not depend on bot any ways
and that _listeners dictionary is only being utilised while using wait_for
yeah so that confirms bot script is irrelevent
or dispatch
what do you actually want to do kin?
see how client loads event
the bot class isnt really useless if it were then the client class is useless as well just handle the gateway events yourself am i right
oki calm down
i need sleep
@client.event
async def event_name(*args):
...
client.event_name = event_name # where event_name is a function
``` are the exposed methods of adding events to a client
discord webhooks can't load nsfw?
the first one uses setattr, in the second one you are setting the attribute manually
this has nothing to do with listeners, its utilised in wait_for and the Bot subclass
this component override the event handler of Client instance. But that is not the part loop over all events and mounting them
mention the lines you are talking about
this whole thing only override the client instance attribute (event attribute)
thats how "events" work
class ABC:
method1
method2
method3
@client.event modifies it that's all
But it is not mounting them or changing the dictionary of _listener
if you mind reading this.
so why you mention them?
Traceback (most recent call last):
File "main.py", line 5, in <module>
from mails import GetDiscordEmail, GetEmail
ModuleNotFoundError: No module named 'mails'
How do I fix it?

install that module
how i can install?
can discord webhooks load nsfw?
i just mentioned the dispatch method, you bringed up the listeners discussion, while the solution of your question is in the last 3 lines of that method
Bruh i dunno what you wanna do but discord.py has no module related to emails
should not matter what the content is
if you mean display by "load"
i am using reddit feed other images and videos get rendered but nsfw marked contents are unable to load even channel is marked as nsfw
doesn't reddit let only registered users access nsfw content?
this still need to read this listeners = self._listeners.get(event) to get events
wich channel?
no why?
getattr(object, name[, default])```
Return the value of the named attribute of *object*. *name* must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, `getattr(x, 'foobar')` is equivalent to `x.foobar`. If the named attribute does not exist, *default* is returned if provided, otherwise [`AttributeError`](https://docs.python.org/3/library/exceptions.html#AttributeError "AttributeError") is raised.
Note
Since [private name mangling](https://docs.python.org/3/reference/expressions.html#private-name-mangling) happens at compilation time, one must manually mangle a private attribute’s (attributes with two leading underscores) name in order to retrieve it with [`getattr()`](https://docs.python.org/3/library/functions.html#getattr "getattr").
its a python fucntion which just needs an object and name of the method to get it, nothing else
The path should be like this:
client.run(TOKEN)await self start()await self.connect()coro = DiscordWebSocket.from_client(self, **ws_params)
gateway.py
- LINE366
ws._dispatch = client.dispatch
ok I found it.
entry = EventListener(event=event, predicate=predicate, result=result, future=future)
i don't think so
i don't see any mention of _listeners here
why don't you try one thing
make a client object, add some event to it and then print(client._listeners) after running it
if that returns a dictionary with those items then it should matter else thats not related
dispatch method still need to intake event strings in it
the gateway.py's dispatch provides that manually
Why am I getting an error ModuleNotFoundError: no module named ‘discord-interactions’
I had this import for over 2 days without anything like this
I misread some attribute. EventListener is not the object handle it
Do you know where is the line manifest the gateway.py's dispatch provides that manually?
@client.event
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
await message.channel.send('Member `banned` successfully')
this won't work
discord/state.py line 594
self.dispatch('message', message)```
anyone?
message is not defined, wrong decorator
can someone help me with nextcord's cogs?
i made a setup function which takes client as a parameter
but then i dont know what to put in it
the load_extension and the add_cog are 2 options given to me by nextcord helper staff
client.add_cog(cogname(client))
the thing is Ping here is not in the same file so
i mean it shows that its not defined
import Ping then...
you put the setup function in the same file as the cog
while loading the cog, it tries to look for the setup function
what do you mean?
you have nothing called message in that function
you have the context (ctx) since it is a command
the context has a send method
!d discord.ext.commands.Context.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
This works similarly to [`send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.
For interaction based contexts this does one of the following...
Does it take a lot of time to register the slash command of Ping?
i put my guild id inside tho
and the deco for command is not @client.event it is @client.command in your case
slash commands takes up to 1 hour to be registered globally
You have to check your package docs to find how to register it for a test guild
its @client.command()
and its await ctx.guild.ban(member, reason = reason)
and its await ctx.channel.send
thanks but it still doesn't work
send the code now
@client.command
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason=None):
await ctx.guild.ban(member, reason = reason)
await ctx.channel.send('Member `banned` successfully')
whats the error
no error
does the bot have permission to ban
yes
and do you have permission to ban
it has administrator
yes its my server
you cant ban anyone higher in heirarchy than the bot
!d discord.Guild.ban
await ban(user, *, reason=None, delete_message_days=1)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to
do this.
@waxen python
how can i make the bot "ask" for a number and then print it
!d discord.ext.commands.Bot.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
what does this mean?
ive never seen this error before
and ive tried fixing the code but nothing works
can i get my bot to add me as a friend?
No.
not any way?
why would u want that to happen
to be able to add it to groups
it already be able to?
That used to be a feature long ago, but bots can no longer be in group dms
bot's can only be used in guilds , DMS
probably a rate limit
ive never seen a rate limit that will stop me for like 2 months
thats a old file from last year
cuz this thing happened since last year and i ignored this code until now and still doesnt work
Try reseting your TOKEN if you haven't
429 is definitely a ratelimit, given it's got HTML I'd assume it's a cloudflare level ratelimit, rather than API level, which generally means you managed to spam a massive number of bad requests at the api within 10 minutes
well ok
are you running any other bots on the same machine which could be increasing the overall number of requests you're making?
wow tysm
i have a question about d.py's interactions... if interaction.user is the person who sent the interaction then who is the one clicking the interaction
ex: if the user types the help cmd and the bot sends a select menu, the user who invoked that select menu is interaction.user.. so if i want to add a check, so that it only works for the person who invoked it, how do i do it
its ok i got it working
No, if you have an help command the user who invoked could be both Context.author or ApplicationCommandInteraction.author based on the fact if the command is made with a prefix or with slash commands, buttons returns a different interaction. the button click interaction is MessageInteraction
its used with prefixed commands
then when the command is invoked you will have a Context object
basically how can i add a check for that.. the menu should be only used by tthe person who invoked it.. i think is possible with async def interaction_check
but idk how to make the if/else funcs
it depends on how your menu works
Yes it can send the spoiler message like this :
||Hey Guys||
he means images
not text
Oh ye
well actually there is a way to send spoiler images with bots .
Just add SPOILER_ to files name and then send that image
file = ctx.message.attachments[0]
file.filename = f"SPOILER_{file.filename}"
spoiler = await file.to_file()
await ctx.send(file=spoiler)
async def interaction_check(self, interaction: discord.Interaction) -> bool:
if interaction.user and interaction.user.id != # random person clicking the menu:
await interaction.response.send_message(content="This menu is not for you!", ephemeral=True)
else:
return True
i need to know what i should use in the place of that comment
bruh i told ya it depends on how your menu is constructed
in my opinion its pretty basic, want the full code?
you subclassed the View class?
yes
then you can do it like this
You will add a new parameter in the constructor called user (which will be passed whenever the help command is casted) which will be equal to the user which has used the help command, then you will need, inside your view subclass, to override a method of the view class called interaction_check (you will just need to add an async def interaction_check(self, interaction: discord.Interaction) in your subclass). This callback method will be called every time a button of that view is pressed. inside of that you will have an if statement:
if self.user (or wathever you will call the user parameter in your view) != interaction.user and inside the if you will do your stuff
how to do on_message
ooh thanks! ill try that
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled...
thx
Microsoft Visual Studio can install libraries just as easy as the IDLE! Take a look !
thx
Huh what's this
for that what he need
Nvm misread it as Visual Studio Code
I was like: VSC doesn't provide that functionality wtf
[text](link) in the description of an embed
thanks
!d discord.Embed.title
The title of the embed.
This can be set during initialisation.
Can only be up to 256 characters.
the url kwarg
!d discord.Embed.url
The URL of the embed.
This can be set during initialisation.
oops
can i only put it in embeds
??
ya
ok
no
imusing
self.bot.get_command('ping')
```to call the command. how do i run the command that it gets?
!d discord.ext.commands.Context.invoke
await invoke(command, /, *args, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Calls a command with the arguments given.
This is useful if you want to just call the callback that a
[`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally...
Smh the new discord update for Android sucks
why?
See the new channels UI. The spacing has been decreased and the app has become highly unoptimized
my spacing is still there and i got the latest version
Unless you got some kinda of beta
yeah mine too are pretty the same
I'm on Discord Beta
Prolly that's the issue
Also, context commands are available on phone at last!
wdym?
User and Message Commands
Not on mobile, no
weird, i remember that i used them 
Idk, I wasn't ever able to use them on mobile
They were
Oh the new menu thingy no those were not.
uhm well i don't have the new update yet, just realized it 
Lol
i've v126.12
128.8
now i'm sad
I had to update manually, even when I have auto update enabled
yeah but i don't have any update in the store too 
Yoo Discord now supports using Regex for filtering logs
Lmaoo
Imagine if they lock App Commands usage behind a paywall. "Pay for nitro and use those"
death for the mobile app for the whole dev community
bruh i updated my website locally like 1 month ago i can't believe that i'm that lazy even for updating a file
henlo can somone help me find a really good explanation where to use intents and how? im a beginner to python and discord bots ,thanks 🙂
how do I add bot activity? i tried a lot of things but nothing seems to work .-.
Which ipc can i use for my discord bot?
wdym?
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))```
no lmoa nvm
In the docs, if an intent is required, then it will be written
??
!d discord.Guild.fetch_members
async for ... in fetch_members(*, limit=1000, after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the guild’s members. In order to use this,
[`Intents.members()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") must be enabled.
Note
This method is an API call. For general usage, consider [`members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.members "discord.Guild.members") instead...
type=discord.ActivityType.watching,
name=f"{len(self.guilds)} servers!"
)```
for example this, you can see that in order to use it you require member intents
yeah do i just put activity? or do i have to do more?
like await bot.change_presence(status=discord.Status.idle, activity=activity)
im failing at first step cus i watched an older video, i fail at the beginning by client
it saiys type error but i dont se no type errors :DD
exactlyy
error
well d.py and related forks are constantly updated so it is hard to find video up to date, but the docs is constantly updated so everytime you use a method it is hardly recommended to read the docs
wat is it
whats ur client variable?
cant copy paste it
is this in ur main file or a cog?
u mean this? client = discord.Client()
yes
main
so instead of bot use client
glad i helped
i cant find an answer
docs is the best option
ehem :///
mine says: client = discord.Client()
TypeError: Client.init() missing 1 required keyword-only argument: 'intents'
i use stackoverflow and discordpy site think
thats where i search
and i foun out i should put intents.deafault or smt
do client = discord.Client(intents= discord.intents.defualt())
something like that
whats does intents= discord.intents.defualt() do?
enables defualt intents for th bot
