#discord-bots
1 messages · Page 222 of 1
it the ID
it say serverIDofOther say non self.name.value) say the ID
print the type for me
sure
if it's a string, you'll have to convert it to an int
THEN the guild will be found
you should also check once you use get_guild if the guild isn't None (when you, for example, type an invalid ID)
it print nothing werid
nice
soemthign wrong
that means your code never gets executed
print(type(self.name.value))
servernameofOther = self.name2.value
serverIDofMain = interaction.guild.id
serverIDofOther = bot.get_guild(self.name.value)
serverOwnerIDofOther = bot.get_user(serverIDofMain.owner.id)
serverOwnerIDofOther.send("Hi")```
bruh i running it
sending a message is async btw => await
it even got me this error Traceback (most recent call last): File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\modal.py", line 290, in _scheduled_task await self.callback(interaction) File "c:\Users\Ibrah\Desktop\Code\Python\main.py", line 1541, in callback serverOwnerIDofOther = bot.get_user(serverIDofMain.owner.id) AttributeError: 'int' object has no attribute 'owner'
this is useless btw
serverOwnerIDofOther = bot.get_user(serverIDofMain.owner.id)
ok!
guild.owner is already a user object...
you don't have to get the user again... would be useless
try and see 🤷
guild.owner is the guild owner of the server that i on rn
that i do the command
but i want owner of other server that i enter there id
got it?
other_guild = bot.get_guild(int(self.name.value))```
does other_guild just normal var right?
yes, it's a better variable name than serverIDofOther lol
ah
this still get only guild
the server now i want get the owner of that server
other_guild.owner
good luck
sup guys, how do i import a game.py file into my discord bot? When i use import game, the game loads but the bot doesn't
@potent spear sorry for the ping but i found this code and I think that this is what i should do:
```,
then replace:
```await channel.set_permissions(ctx.guild.default_roles, send_messages = True, reason = f'{ctx.author.name} unlocked {channel.name} with --server')```
with
```await channel.set_permissions(ctx.guild.roles, send_messages = True, reason = f'{ctx.author.name} unlocked {channel.name} with --server')
for more context here is how it looks. you can see that the bot doesn't loads
but what should i set the "guild" variable to
i just found a video on discord utils and idk what to set it to
@slate swan do you have a fix? sorry for ping
nah sorry, i just started bro
oh mb
Why did you get the role when you’re never using it?
Show me where
What do you think that is? 🧠
Well it looks like you have an input() statement in your game.py file, which is blocking the rest of the script. Python code executes serially, so the code afterwards doesn't run until the prior instruction is completed.
should i just replace ctx.guild.roles with "role" instead
can i send u both codes to fix it for me?
Yup
https://paste.pythondiscord.com/koruqerexu
here is the code
Well that doesn't change my answer
You have input() statements which must complete before the code after them runs
Are you actually trying to get input from the console or from discord?
you can use await aioconsole.ainput() for a non blocking version
actually
that won't fix your problem mainly
you can run it in another thread
from discord bot
like an embed imput using reactions
What 
here is how it's supposed to look(inside should be the game)
they can run the input function in another thread to prevent the block if I recall correctly
So why are you using input() and print()?
You know print() doesn't send a message to a discord channel right?
And input() doesn't read a message from a discord channel
i used print to display the gui of the bot, but it sends in console actually
so how do i create it to display like embed?
How new to python are you? I'm not sure if I'll be able to explain if you're a beginner...
im kinda new but i try to learn stuff
so you can try to explain
u took this from chat gpt na get intents tho
on message does right?
guess u should learn discord.py not only python
umm can u explain it to me tho?? lul
@vocal snow
!embed
umm typing finally
when you want to send a message to discord, you have to make an API Call;
An HTTP POST request to the /channels/{channel.id}/messages endpoint
In discord.py, this is abstracted to the Messageable.send method
!d discord.abc.Messageable.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.11)") 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.11)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
when you use print(), it will print to the program's stdout (or a file, if specified via the file kwarg)
so there's a very big difference between the two, and they absolutely cannot be substituted for each other
y ic
we can use it right?
i have another question how u learned discord.py?
from docs??
as well as reading the source
bruh u typed this for so long breh??
wdym??
I was wondering how to answer it, since I haven't really "learned" discord.py
Reading the source code: https://github.com/Rapptz/discord.py
heh
how does it work now
cuz i didnt learn it actually at some extent
@vocal snowbro listen how am i supposed to learn it cuz in docs also it gets ended i dont get what next i am suppose dto do
sry for continous pings
what do you want your bot to do?

take control of the world
and reading the docs won't help if you don't understand them;
you should make sure you understand intermediate level python first
umm am actully making a bot like for anime purpose like there will be some boss fights to earn coins or something like that teaming up with other charachters
😳
ya i do
lol
i have more ideas but am lazy to type it tho
lol
it's important you have a clear understanding of you want your bot to work
How does a player start playing the game?
Do they use a slash command? Maybe click a button?
And then, where are you going to store all the player data? Which database will you use
actually i didnt had idea of it at first glance
dk
lol
There's a lot of planning that needs to be done before the actual coding happens
@shrewd apexu made a pokemon bot?
umm yea?
(The best pokemon bot)
how check if a var is int
but i actually have it tho
totally not
lol
isinstance; ```py
if isinstance(var, int):
...
!d isintance
No documentation found for the requested symbol.
typo
🧐
!d isinstance
isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised. [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") may not be raised for an invalid type if an earlier check succeeds.
Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
wasnt it like var (type)
lol
no
oh lol
know any good vm viewers?
uh wht is vm tho sry for disturbance
I use WSL for all my linux needs ☺️
virtual machine
need it for vms online
heh? lul leave
i can but its faster sometimes with gui
i dont have to google commands for everything 
impossible !1!!!1
ask
🪨
linux terminal consol good gui windows BAD
from where did u got the pitures of it from official site??
Windows best
ah i gathered from a bunch of sources
Like?
pokeapi showdown pokemondb and so on
ya like?
can it cant be taken from official site?
but recently i compiled all of the images i gathered and made a bunch of prs to pokeapi
so most of the images are now available there
But that's not good
except the gifs i made pr not accepted yet tho
wht id pr tho lul.
U must give credit
oh
it was open sourced
Oh whatever but I think it's better
i didnt take ones from artists and stuff mostly the open sourced ones like showdown
@shrewd apexdid u learned discord.py??
plus it not economised
u did it all alone?
the bot ur asking me about is what i used to learn python 
yeah
heh didnt get it

sry for consuming so much of ur time tho
i actually didnt get it can explain pls
explain what?
this line
it literally means what is written i used the bot as my project to learn python
oh but did u first took a pyhton course or just begun it
i did a few smol projects but nothing too big
cuz i am a game dev but came on discord just for experience
just dived in mostly
means u learned in the match right?
aight
damn
not recommended tho
lol
i learnt stuff in all the wrong order
Is this help channel?
how much time did it took anyway
if its smol we can help u out
lol sry
if not #1035199133436354600
about 3-4 months to make then just adding features or rewriting old stuff
17
oh ic
@shrewd apexthnx for giving me ur time
hello, i am currently doing a captcha verification, what is the most efficient way to check like every 0.2, 0.3 seconds if the captcha is expired while being able to guess and complete the captcha
Hello! I can provide some general advice on how to efficiently check for captcha expiration while completing the captcha.
First, it's important to understand how captcha expiration works. Captchas typically have a time limit after which they expire and become invalid. This time limit is usually set by the website or service that is using the captcha.
To check for captcha expiration, you can use a timer function that runs every 0.2 or 0.3 seconds. This function should check the time elapsed since the captcha was first displayed and compare it to the captcha expiration time limit. If the time elapsed is greater than the time limit, then the captcha has expired and you should stop any further attempts to complete it.
To guess and complete the captcha efficiently, you can use automated tools like captcha solving services or machine learning models that are specifically designed to recognize and solve captchas. These tools can significantly reduce the time and effort required to complete a captcha. However, it's important to note that using automated tools to bypass captchas without permission is generally considered unethical and may be illegal in some jurisdictions.
Alternatively, you can try to manually solve the captcha by following the instructions provided, such as identifying certain objects or characters in an image. This can be time-consuming, but it's a legitimate way to complete the captcha without violating any rules or laws.
Overall, the key to efficiently checking for captcha expiration while completing the captcha is to use a timer function to monitor the time elapsed and to use automated tools or manual methods to complete the captcha as quickly and accurately as possible.
u can read if u want
ight ty
where did u copy that from bro 💀
lul
No I watched a toturial, but it didn't work so I asked chatgpt if it could fix it
chatgpt no doubt
I wanted to see what I did wrong
not u this ^
k
adding multiple options to select from in an option?
i wanna learn how to create a bot
on_guild_leave or on_guild_remove?
the latter
heh?
are we supposed to use intents.message_content or intents.messages??
@slate swan
lol sry for ping

help?
pls
those are two different intents depends what you need
!d discord.Intents
class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").
New in version 1.5.
read about them here what they add\
bruh tell na thts too less
plss
oof
?
i told you go to the docs i sent and read what they add and you decide what you need
nothing there to read
i didnt found anything i tried a lot really
there is plenty there to read
really just scroll a bit
not sleeping is hard for but still i was not sleeping for 2 days
where u find this
i didnt actually found it anywhere
here
you see this blue text here, you can click it to go to the doc page
on windows, shift+windows key+S
if you just want a summary, messages is how your bot knows when a message was sent in real time, while message_content is needed to access the text sent in that message (and is a privileged intent so it needs to be enabled in the dev portal beforehand)
addendum: fetching messages via the API (i.e. not real-time) will also return no content if message content isnt enabled in the dev portal
didnt got
bruh wht are these words
this is what your bot sees if you have messages enabled but not message_content (with some exceptions listed in the documentation)
:huh:
in other words you know when the message was sent, where it was sent, and who sent it, but not what was sent
we use message content for it??
yes
what did your bot respond with?
it was supposed to send that u choosed this or that
but it dosent
and now it dosent send the dm as well sed
wouldnt this be easier to use as a command instead of on_message ?
it was not sending message tht way either
how is the interaction triggered? with !team up?
so i gone for it
y
a
u mean prefix right?
minor pointer that message content isnt enabled so you're relying on one of the three exceptions for receiving message content, but regardless capitalize() likely isnt doing what you expect it to do
heh am i supposed to add message content intent as well
?/
..
if you need to receive message content outside of the exceptions, for example to recognize "!team up" when someone sends it inside a server, sure
!e as for capitalize(), here's what that looks like: py name = "Eren Yeager" content = "eren yeager" capitalized = content.capitalize() print(capitalized, "vs", name)
@hushed galleon :white_check_mark: Your 3.11 eval job has completed with return code 0.
Eren yeager vs Eren Yeager
^ it doesnt produce the same string so your check isnt able to match those names correctly
heh?
one is capital one is small
right, which means they are not equal strings, so when your check tries to do msg.content.capitalize() in pokemon_list, it will always return False
i did changed it
whats done more commonly for case-insensitive comparisons is lowercasing both strings, as its simpler to understand: ```py
items = ["cookies", "cream", "sauce"]
x = "CoOkiEs"
x.lower() in items
True```
the timeout you mean? sure that seems fine
but still not working tho
you havent solved this though
i have to change capitalize to lower right?
and make the strings in your list lowercase too
k doing it in 1m
this??
@hushed galleonsry for so much pings
it is working like this lol
do you have multiple instances of the bot running?
thats why the bot is sending multiple messages for one command
wait one sec
but the bot is only taking message in dms
not on servers tho
thegamercracks
help

i did it tho
what ryuga said, you probably have multiple versions of your bot running
ya tht work is done
it is workin correctly now but i want to make the start command more cool tho so how can i lol (i know u are annyoed from me but i cant help it either)
use embeds and emotes
didnt get it
checkout discord.Embed
from where?
docs
Oof
its same as hell
it's very organized if you ask me, alternatively you can just google "how to make an embed in discord.py" and check out some readymade example explanation
i am a baka so for me its hard and thnku for help
i would google it then
also the bot code template you're using is quite outdated, read the docs or some gist to get a better and subclassed one
heh?
again didnt got
to put it simply, you're just trying to put everything in one file and not using classes to make cogs.
subclassing the bot is the best method
man when ppl type so much for me i actually feel awful
bruh what is this
it'll also get messy with over 10 commands since it'll already reach like 600ish lines
i should sleep i guess my eyes are burning cuz i didnt slep for 2day tho
thnks for ur time sir
actually, just decorate the feedback message using emotes and embeds.
heh?
guys can any one help me to know how use database
sry am a noob this guy is smart @slate swan
lol ok
Depends what database
lol

!discord.embed
oof?
!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.
x == y Checks if two embeds are equal.
New in version 2.0...
@cloud dawn
?
..why exactly?
Using the embed kwarg
!d discord.abc.Messageable.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.11)") 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.11)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
should i read this?
Just look at what it takes
?
embed=discord.Embed(...)
thts not my dout
customizability, maintainability and code cleanliness
am asking am i supposed to send it after await command?
embed = discord.Embed(...)
await channel.send(embed=embed)
and then this?@odd mango
its there
ya ic ty
fax
i am gonna ask a shit question but
its saying channel is not defined
...
lol
what are you using? context?
should be message.channel.send(embed=embed) according to your code
The TextChannel or Thread that the message was sent from. Could be a DMChannel or GroupChannel if it’s a private message.
LOL do not do discord.Embed(...)
feed in its params
lol
It was an example lol
params?
parameters
of
discord.Embed
oh*
still wht to do abt the channel thing
Look at the first answer there is an example maybe you will understand it with it
not defined
i am supposed to click on the link?
await message.channel.send(embed=embed) #for sending it in channel
await message.author.send(embed=embed) #for sending it in dms
yeah? Its stack
stackoverflow
You know it right 
am actually feeling so awful
wht if i say no i am still a 6th grader tho
but i want to learn
UHHH violation of ToS
heh?
discord is a 13+ app 🚶♂️
lmao wtf
"Ignoring exception in on_message" wht is this
full traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
bro i actually did it
@slate swansry for ping
@odd mangosry for ping
sry for wasting ur time again
👍
damn i just came back
@odd mangousing images from official webs in dc is not wrong right
ic
ofcousre unless it violates terms of service of the image provider or discord
heh?
can i ask a question?@odd mango
is it day or night at ur place?
it's night
ic
yeah about 00:30
likewise
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.
x == y Checks if two embeds are equal.
New in version 2.0...
all capital?
do you see it being all capital here
no
python is case sensitive, so the documentation is made according to it, and accessed likewise via this bot
umm in the embed can i add user avtar as well?
yeah
set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
message.author.avatar_url iirc
hello, i am gettng this error when import from nextcord.ext import menu
ImportError: cannot import name 'menus' from 'nextcord.ext' (unknown location)
did you do from nextcord.ext import menu?
i think they want thumbnail
embed.set_thumbnail(url=message.author.avatar_url)
there is no such thing like menus in nextcord
hello all, somebody will and can help me with some python. it's for in my discord server to make a command
try from nextcord.ext import menu, idk about nextcord
what are you trying to do?
then nextcord.ext does not have menu
try from nextcord.ext import menus
i think there is
really? there should be
doesnt work too
check the docs then
i was using it ages ago but i belive it was removed
well ill ask again
what are you trying to do @slate swan
so is it in dpy now?
could be, i dont know anyways lol
i am trying to do a paginated embed for my warnings
so if there are e.g more than 5 results, it should create another embed with new fields
mhm i see
can you tell me how to start cuz i have no idea
looks like it is an external package now https://github.com/nextcord/nextcord-ext-menus
i guess the docs are not updated then, because it's there https://menus.docs.nextcord.dev/en/stable/ext/menus/pagination_examples/
oh right thanks
that too for stable version
those are not nextcord doc
those are the external package docs
whaaa 😂
https://docs.nextcord.dev/en/stable/
here are nextcord docs
yeah its not there
i will try it now
i get the error embed has no attribute edit
msg = discord.Embed(description=f'Deleting this ticket in **5** sconds', color=0x303135)
await ctx.channel.send(embed=msg)
time.sleep(1)
await msg.edit(description=f'Deleting this ticket in **4** seconds')
time.sleep(1)
await msg.edit(description=f'Deleting this ticket in **3** seconds')
time.sleep(1)
await msg.edit(description=f'Deleting this ticket in **2** seconds')
time.sleep(1)
await msg.edit(description=f'Deleting this ticket in **1** seconds')
time.sleep(1)
await msg.edit(description=f'Deleting this ticket in **0** seconds')```
i added this but nothing chaanged like the avatar not showing yet
create a new embed and edit the message, you dont edit the embed, you edit the message
huh?
//@slate swan //
bruh
then how the black part come
eh
message = #get your message to edit
NewEmbed = discord.Embed(...)
await message.edit(embed=NewEmbed)
ohh okay tyy
dont copy paste
you are not using client.command()
you are using an on_message event
i am not getting the code tho
no no
bruh??
this still doesnt seem to work
i got the same errora
@client.command()
async def avatar(ctx: commands.Context, member: discord.Member) -> discord.Message:
member = member or ctx.author
embed = discord.Embed(title=f"{member.display_name}'s Avatar")
embed.set_image(url=member.avatar_url)
return await ctx.send(embed=embed)
``` this is what i would do
show code
wht is -> this now
ignore that
msg1 = discord.Embed(description=f'Deleting this ticket in **5** sconds', color=0x303135)
await ctx.channel.send(embed=msg1)
time.sleep(1)
msg2 = discord.Embed(description=f'Deleting this ticket in **4** seconds', color=0x303135)
await msg1.edit(embed=msg2)
time.sleep(1)
msg3 = discord.Embed(description=f'Deleting this ticket in **3** seconds', color=0x303135)
await msg2.edit(embed=msg3)
time.sleep(1)
msg4 = discord.Embed(description=f'Deleting this ticket in **2** seconds', color=0x303135)
await msg3.edit(embed=msg4)
time.sleep(1)
msg5 = discord.Embed(description=f'Deleting this ticket in **1** seconds', color=0x303135)
await msg4.edit(embed=msg5)
time.sleep(1)
msg6 = discord.Embed(description=f'Deleting this ticket in **0** seconds', color=0x303135)
await msg5.edit(embed=msg6)```
ic
@client.command()
async def avatar(ctx, member):
member = member or ctx.author
embed = discord.Embed(title=f"{member.display_name}'s Avatar")
embed.set_image(url=member.avatar_url)
return await ctx.send(embed=embed)```
work with this for now
you are still editing the embed
you need to edit discord.Message NOT discord.Embed
how do i get the message
just store it in a var
msg = await ctx.send(...)
^^
huh
oh
k
msg1 = discord.Embed(description=f'Deleting this ticket in **5** sconds', color=0x303135)
UltimateMessage = await ctx.channel.send(embed=msg1)
time.sleep(1)
msg2 = discord.Embed(description=f'Deleting this ticket in **4** seconds', color=0x303135)
await UltimateMessage.edit(embed=msg2)
time.sleep(1)
msg3 = discord.Embed(description=f'Deleting this ticket in **3** seconds', color=0x303135)
await UltimateMessage.edit(embed=msg3)
time.sleep(1)
msg4 = discord.Embed(description=f'Deleting this ticket in **2** seconds', color=0x303135)
await UltimateMessage.edit(embed=msg4)
time.sleep(1)
msg5 = discord.Embed(description=f'Deleting this ticket in **1** seconds', color=0x303135)
await UltimateMessage.edit(embed=msg5)
time.sleep(1)
msg6 = discord.Embed(description=f'Deleting this ticket in **0** seconds', color=0x303135)
await UltimateMessage.edit(embed=msg6)
Sorry but what?
they are trying to edit the message
@left dew that should do it
okay tysm
lol its their pick not mine
<t:1992121212:R>
<t:1680453929:R>
<t:1680121212:R>
i think its enough of timestamps
Lol
yeah @left dew refer to it, i wouldn't recommend using time.sleep() and editing ever second either
save some api calls
<t:1680464096:R>
oh
never use time.sleep in discord bot use await asyncio.sleep(1) instead
okay
!d asyncio.sleep
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Example of coroutine displaying the current date every second for 5 seconds:
but for this case timestamp will be better option
Deleting message <t:1680464196:R>
Relative time
here are the docs for it
ic
If you need to repeat certain lines multiple times, there is a better way to do it.
how do I tell a bot to use slash commands?
like do I need to import something and stuff
you change your code...
@unkempt canyon use slash commands
those are called app_commands
it's not a parrot
like for this, how do I change it to use slash commands instead of putting !
@dc.event
async def on_message(message):
if message.author == dc.user:
return
elif message.content.startswith('!hello'):
await message.channel.send('Hello!')
well, that's not a command in the first place
@dc.event
async def on_message(message):
if message.author == dc.user:
return
elif message.content.startswith('/hello'):
await message.channel.send('Hello!')
yeah this is just reading messages and waiting for the keyword
@slate swan @odd mango thank you for today guys
LMAOOO
fixed
isnt there a more specific way to use discord's built in slash feature
mhm, he's a day too late for this April Fools code
!d discord.app_commands.command
arent there only client and bot @ ?
@discord.app_commands.command(*, name=..., description=..., nsfw=False, auto_locale_strings=True, extras=...)```
Creates an application command from a regular function.
<t:1680464672:R>
decorators?
ic
u mean name can be anything?
ofc its just a var name
i have two bots set up on the same ip
will discord rate limit based on the ip or the bot?
ip
Frick
ok on second thought I am not gonna use slash commands
just gonna go old fashioned since there seems to be no good solutions to this
client.run(os.environ['TOKEN'])
File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/client.py", line 777, in start
await self.login(token)
File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/client.py", line 612, in login
data = await self.http.static_login(token)
File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/http.py", line 805, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.```
i keep on getting this code when trying to pass in my token
i formatted my token as TOKEN=x , x = token value
and i didn't really use x i am just using that as an example
import os
intents = discord.Intents.all()
client = discord.Client(command_prefix='!', intents=intents)
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello my people')
client.run(os.environ['TOKEN'])```
this was my code
you dont load the environment varriables
.env (dotenv) files are a type of file commonly used for storing application secrets and variables, for example API tokens and URLs, although they may also be used for storing other configurable values. While they are commonly used for storing secrets, at a high level their purpose is to load environment variables into a program.
Dotenv files are especially suited for storing secrets as they are a key-value store in a file, which can be easily loaded in most programming languages and ignored by version control systems like Git with a single entry in a .gitignore file.
In python you can use dotenv files with the python-dotenv module from PyPI, which can be installed with pip install python-dotenv. To use dotenv files you'll first need a file called .env, with content such as the following:
TOKEN=a00418c85bff087b49f23923efe40aa5
Next, in your main Python file, you need to load the environment variables from the dotenv file you just created:
from dotenv import load_dotenv()
load_dotenv(".env")
The variables from the file have now been loaded into your programs environment, and you can access them using os.getenv() anywhere in your program, like this:
from os import getenv
my_token = getenv("TOKEN")
For further reading about tokens and secrets, please read this explanation.
what am I missing thats causing this error?
heres my code,
https://hastebin.com/share/owomeratep.python
error,
Traceback (most recent call last):
File "c:\Users\Madth\Documents\Projects\discord slash\main.py", line 26, in <module>
class Hello(commands.SlashCommand):
^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'discord.ext.commands' has no attribute 'SlashCommand'```
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
how to do hybrid command on command group
ty
what is a decorator
ugh
see this is why I hate learning python and stuff because it literally consumes your whole day by waiting for hours and hours to get a response
what is arg
@bot.command(name='list')
async def _list(ctx, arg):
pass
an argument
which is
wdym
A parameter is a variable defined in a function signature (the line with def in it), while arguments are objects passed to a function call.
def square(n): # n is the parameter
return n*n
print(square(5)) # 5 is the argument
Note that 5 is the argument passed to square, but square(5) in its entirety is the argument passed to print
So parameter is like a variable to build a function and argument is an actual value used in the function
A value created inside a function can't be used outside of it unless you return it.
Consider the following function:
def square(n):
return n * n
If we wanted to store 5 squared in a variable called x, we would do:
x = square(5). x would now equal 25.
Common Mistakes
>>> def square(n):
... n * n # calculates then throws away, returns None
...
>>> x = square(5)
>>> print(x)
None
>>> def square(n):
... print(n * n) # calculates and prints, then throws away and returns None
...
>>> x = square(5)
25
>>> print(x)
None
Things to note
• print() and return do not accomplish the same thing. print() will show the value, and then it will be gone.
• A function will return None if it ends without a return statement.
• When you want to print a value from a function, it's best to return the value and print the function call instead, like print(square(5)).
check this gif
how come the 5 went to x
how does the code know to do that
oh
the function is my_function
then he reuses it down below and it references the earlier lines on what to do
ok that makes sense
so return just tells it to use the output
Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.
This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.
To call an async function we can either await it, or run it in an event loop which we get from asyncio.
To create a coroutine that can be used with asyncio we need to define a function using the async keyword:
async def main():
await something_awaitable()
Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function
To run the top level async function from outside the event loop we need to use asyncio.run(), like this:
import asyncio
async def main():
await something_awaitable()
asyncio.run(main())
Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().
To learn more about asyncio and its use, see the asyncio documentation.
what does * do
Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.
for i in range(len(my_list)):
do_something(my_list[i])
The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:
for item in my_list:
do_something(item)
Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.
alright found it, * allows for variable number of arguments
Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.
This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.
To call an async function we can either await it, or run it in an event loop which we get from asyncio.
To create a coroutine that can be used with asyncio we need to define a function using the async keyword:
async def main():
await something_awaitable()
Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function
To run the top level async function from outside the event loop we need to use asyncio.run(), like this:
import asyncio
async def main():
await something_awaitable()
asyncio.run(main())
Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().
To learn more about asyncio and its use, see the asyncio documentation.
guys how create a discord channel by the bot
is there a way for a bot to find out if there is a number in a string or not
!e
import re
pat = re.compile(r"\d")
string = "Meow"
if pat.search(string):
print("Has number")
else:
print("Has no number")
string = "Meow_1"
if pat.search(string):
print("Has number")
else:
print("Has no number")
@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | Has no number
002 | Has number
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you must have [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.11)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
Read the docs
@naive briar does this work too
async def add(ctx, number, member: discord.Member):
try:
number = int(number)
await ctx.send(f'Adding {number} honks to {member}')
except ValueError:
await ctx.send('this is not a number bro')
@naive briar :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | int("Meow_1")
004 | ValueError: invalid literal for int() with base 10: 'Meow_1'
it should go to except ValueError right
!e
async def add(ctx, number, member: discord.Member):
try:
number = int(number)
await ctx.send(f'Adding {number} honks to {member}')
except ValueError:
await ctx.send('this is not a number bro')
@tight fog :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | async def add(ctx, number, member: discord.Member):
004 | ^^^^^^^
005 | NameError: name 'discord' is not defined
!e
number = "hello there"
async def add(ctx, number):
try:
number = int(number)
except ValueError:
print('not a number')
@tight fog :warning: Your 3.11 eval job has completed with return code 0.
[No output]
guys how fix this error ```Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x00000192DE7445B0>:
Traceback (most recent call last):
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Ibrah\Desktop\Code\Python\main.py", line 1491, in crosserverschat
message1 = await interaction.send("CrossServer Chat StartUp", embed=embed, view=myview, ephemeral=True)
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 564, in send
return await self.response.send_message(
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 893, in send_message
await adapter.create_interaction_response(
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 204, in request
raise NotFound(response, data)
nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
your command?
maybe cause interaction is not defined..?
what
then how would it run the send method

can someone give me a discord.ext.commands.MinimalHelpCommand example please
!d discord.ext.commands.MinimalHelpCommand
class discord.ext.commands.MinimalHelpCommand(*args, **kwargs)```
An implementation of a help command with minimal output.
This inherits from [`HelpCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HelpCommand "discord.ext.commands.HelpCommand").
Its better to make your own help command instead
ok tysm
it's mostly focused on HelpCommand though
yeah ill try to read and understand ig
guys why message.value not working in @bot.event async def on_message(message): await bot.process_commands(message)
Wdym?
!d discord.Message.content
The actual contents of the message. If Intents.message_content is not enabled this will always be an empty string unless the bot is mentioned or the message is a direct message.
message.value
Guys what is the function for response to mention?
Can I set the footer of an embed to a timestamp? eg. <t:1680499624:R>
Hello everyone, I would like to link two projects discord bot but I can't do it... possible to help me if you like? I can send it to you omplet I have all prepared
You can do that by embedding API server into each
It's not footer, it's separate part
!d discord.Embed.timestamp
The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.
Will it show up in the footers area?
You can set it in the constructor
Yeah
so it'd be the epoch as a string or what? For the timestamp
datetime.datetime object
it converts it itself?
I'd like it to be a relative timestamp of when the embed was sent
Yeah that's current time
Eg. Sent <t:1680499624:R>
!e ```py
from datetime import datetime
print(datetime.now())```
@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.
2023-04-03 05:46:25.484971
my error :
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
Can it send relative timestamp like the ".. minutes ago"
Embed timestamps don't support that
what areas do?
Anywhere that supports formatting 🤷
I believe embed fields values/description and regular messages
alright thanks
@mighty sundid it worked?
adding intents?
if not then send full code
ya add intents
u here?
shall i explain?
I tried but it doesn't work I'll send it to you in private message@slate swan
It doesn't work doesn't explain the problem
!paste
huh?
@slate swan I sent you all in private message my friend
I'm sorry but I'm French and I try to do my best...
this is my problem
heh?
sending in dms is something i dont support
but I can't run the code I made
Read the error
cuz i am not ur personal assitance tho
ah ok sorry bro ^^
yup intents missing
I didn't know sorry, I thought I could since I sent my tokens
intents = discord.Intents.default()
intents.members = True
intents.messages = True
intents.message_content = True
do this
after import thing
even with a self bot I have to add that?
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
see the error tho it is writeel intents are missing
how do I get the guild icon again?
have u did import discord in the start?
sry but idk
!d discord.Guild.icon
property icon```
Returns the guild’s icon asset, if available.
there ppl smarter than me on this server wait for their response i g
Read the docs
bruh
in the begining do import discord
u didnt imported discord bruhhh
Hey @mighty sun! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discord.com/developers/applications
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
have u learned python?
my env : RELAY_BOT_TOKEN=****
RELAY_SOURCE_CHANNEL_ID=***
RELAY_PRIORITY_DESTINATION_CHANNEL_ID=****
RELAY_FALLBACK_DESTINATION_CHANNEL_ID=****
RELAY_ROLE_ID=****
and my bridge.py : https://paste.pythondiscord.com/ikuzupajar
yes a little bit but it's complicated I'm French, what should I do? import discord?
@mighty sun
intents = discord.Intents.default()
intents.members = True
intents.messages = True
intents.message_content = True
go read docs first bro
import dc st 1st line oof
but I wrote it xD
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
now run bot hpefully it should work
using selfbot = bad ?
I am not looking to read the documents, I am looking for help because I am French
i use self bot
dk
dem
ur pfp scares me

shut it's cute
lol
guess i cant help u now wait for other to come and help u are making it complicated
for me
whats wrong if u r french
i am Indian tho
i still read docs
not saying i am Indian so i cant
Oof
so what? I didn't come to read documents I said I was looking for help
u cant be helped bcz u are asking us to feed u code
cant*
first learn the thing u want to aim for
bruh this keirara guy typing so much
So the voice state intents give access to the member.voice,
but... you can't actually account for the time someone actually talks w/ these intents right...?
or is there a package I can use?
This would be for a custom function to add xp to user for each (x-amount-of-time) they talk...
bruh???
you are able to receive voice data, however discord.py does not have builtin support for it yet
I believe Py-cord does, but I cannot attest to how stable it is
ty!
https://github.com/Rapptz/discord.py/pull/9288 This one seems a bit more active too
much appreciated 🙂
so can on_interaction classify as a cog listener?
An event
which would be like on_voice_state_update, which is an event.
so... technically yes...?
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
dont think there is an event for that
easiest way would be to check for user voice States wether they are muted or not i am not sure if there is a state if they are speaking but if it's there u can use it
maybe make a cache with userid and timestamp and check for updates then add xp
this is in the gateway section... so that's why i'm assuming that i could use it as a cog listener.
true... cause that's one of the params.
You forgot to pass the intents
oh nice yeah u can use that then
Is there no way to get the avatar url to default profile pictures?
!d discord.User.display_avatar
property display_avatar```
Returns the user’s display avatar.
For regular users this is just their default avatar or uploaded avatar.
New in version 2.0.
So I can just change all of them to that I guess
it's an asset so it would be user.display_avatar.url to get the url i believe.
self.bot.user.avatar.url gets the bot's avatar url.
Code?
class help(commands.HelpCommand):
async def send_bot_help(self, mapping):
self.previous = config["previous"]
self.next = config["next"]
self.stop = config["stop"]
e1 = discord.Embed(color=co)
e1.add_field(name="", value=f"", inline=False)
e1.add_field(name="", value=f"", inline=False)
e1.add_field(name="", value=f"", inline=False)
e2 = discord.Embed(color=co)
e2.add_field(name="", value=f"", inline=False)
e2.add_field(name="", value=f"", inline=False)
e2.add_field(name="", value=f"", inline=False)
paginator = pg.Paginator(self.bot, [e1, e2], self.context, timeout=60, invoker=self.context.author.id)
paginator.add_button("prev", emoji=f"{self.previous}", style=discord.ButtonStyle.blurple)
paginator.add_button("end", emoji=f"{self.stop}")
paginator.add_button("next", emoji=f"{self.next}", style=discord.ButtonStyle.blurple)
return await paginator.start()
ignore the blank names and values I removed it when i sent code
invoker=self.context.author.id
is why im getting
AttributeError: 'help' object has no attribute 'bot'
the issue is self.bot HelpCommand doesnt have bot attribute, get your bot instance from context, self.context.bot
wait
ur right i knew that
I thought it was self.context cus I use
nvm too much to explain
How do i make an embed send when a button has been pressed? i've tried this:
await interaction.response.send(embed=n)```
show full code
how does this not return "false" ?
but if I put everything at True it returns True
im stuck here: I want to add someone to a list when he is: not muted, not deafened and not in an afk channel
what it rn does is following: it adds someone who is muted and deafened
!or
When checking if something is equal to one thing or another, you might think that this is possible:
# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
Not the same operator, but the same concept
let me try that, one second
How do i know where to add on code to a already existing code.
finally man thank you so much @naive briar
Your expression is basically this
if (mute) and (deaf) and (afk == True)
You need to use all
if all(v == True for v in (mute, deaf, afk))
makes sense, didnt know this, thanks!
you can just do ```py
if all((mute, deaf, afk)):
Assuming those variables are strictly bools yes
all(iterable)```
Return `True` if all elements of the *iterable* are true (or if the iterable is empty). Equivalent to:
```py
def all(iterable):
for element in iterable:
if not element:
return False
return True
!e
print(1 == True)
@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.
True
@discord.ext.commands.hybrid_command(name="help", description="Shows commands")
async def help(self, ctx, option = None):```
def test():
old_links = []
while True:
try:
base_url = ""
with webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options) as driver:
driver.get(base_url)
driver.implicitly_wait(7)
title = driver.find_element_by_css_selector('').text.strip()
link = driver.find_element_by_css_selector('').get_attribute('href')
if link not in old_links:
return title, link
except Exception as e:
print(e)
driver.quit()
time.sleep(5)
i am trying to web scrapping every 5 mins(in code just test) and the sites are more than 100 but when i make codes with async def each site like this code, the bot is keep shut down. so i am trying to make with def but i don't know how to convert from title and link in def to async def
may i get advices what is good method to get the title and hyperlink of a new post every 5 minutes for more than 100 sites
@vale wing I fixed it!!
Is EmojiQuiz.get_db_data a classmethod or staticmethod?
give EmojiQuiz class code
whats that?
i nedd help with my stats bot
def find_matching_data(id, date_str):
with open('dnd.json', 'r') as f:
data = json.load(f)
matching_data = [item for item in data if item["id"] == id and item["date"] == date_str]
if matching_data:
return matching_data[0]
else:
return None
data_item = find_matching_data(id, date_str)
if data_item is None:
await interaction.response.send_message(f"No data found for {selected_option}")
return
this code scans for the matching data in dnd.json but it always responds with no data found but the data is present there
is this indented correctly? you're calling your own function
wht is self bot?
no i copied it
damn levi is so cool@lyric halo
doesn't make much sense, that function, right?
seems to be an infinite recursion
unless that "copied code" looks different in your IDE
im on my mobile rn ill check it up
guys how fix this error ValueError: invalid literal for int() with base 10: 'visk0623\n'
how make biot check the message have a ping
@slate swan why u offline today?
!e
print(int("meow"))
@shrewd fjord :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | print(int("meow"))
004 | ^^^^^^^^^^^
005 | ValueError: invalid literal for int() with base 10: 'meow'
!e
print(int("123"))
@shrewd fjord :white_check_mark: Your 3.11 eval job has completed with return code 0.
123
its obvious ig
but i want when it see a string just skip iot lol
u want it to be ignored?
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
ye
use try-except block
umm'
brooooo
bruh
set_image(*, url) wht is the in thid code used for?
@slate swan
can yoguys like wtf is thisprint(serverIDofOther) if serverIDofOther == "None": print("") await interaction.send(f"Sorry But, We Found No Server With This ID :no_entry:!", ephemeral=True) return... serverIDofOther is none but it not doing anything in IF statue
Python Enhancement Proposals (PEPs)
Is it None or "None"?
There's a difference between None (NoneType) and "None" (str)
it None
And consider following pep8
idk
if serverIDofOther == "None":
and it say in consoal "None"
im wanting to get the content of a message in a tasks.loop() but how do i do it?
Normally?
which message in particular?
hw can i add image in embed?
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
define it?
for which image
png
so you have it saved on your computer?
am abt the path
whts with url??
what?
wht am i supposed to write in ur?
did you read the link?
ya
How do I use a local image file for an embed image?
Discord special-cases uploading an image attachment and using it within an embed so that it will not display separately, but instead in the embed’s thumbnail, image, footer or author icon.To do so, upload the image normally with abc.Messageable.send(), and set the embed’s image URL to attachment://image.png, where image.png is the filename of the image you will send.
Quick example:
content_copy
file = discord.File("path/to/my/image.png", filename="image.png")
embed = discord.Embed()
embed.set_image(url="attachment://image.png")
await channel.send(file=file, embed=embed)
but there image.png
their filename is image.png
but my file name is diff na?
huh?
am i supposed to only change filename not path or anything?
of course you have to change the path
like attachment:/
and attachment thing?

