#discord-bots
1 messages ยท Page 52 of 1
nope?
Cause I see 22:57
thats not the time for me rn
i just typed a random number of course its not your time
i use that in my about lol
i generated it from a website
<t:10372912>
why not here then
how do i?
you can get a timestamp integer via member.created_at.timestamp()
it must be different for isnt?
oh ok thanks
what ๐
how is it still not the first ๐
Skull is below my
somehow
๐
๐
If you do not know python please do not speak in this channel ๐ญ๐ญ๐ญ
i was playing with pygame module
Real
๐
btw I just randomly opened this channel and instantly this message appeared
i mean i was coding smth
Sorry
Ok
I only know php
I still use turtle over pygame
What? 
i only know css
I only know block coding
bruh
we got some skills
did someone say blocking code?
blockingio

gonna add some jishaku cog to my bot i guess
time.sleep(600**10**230)
Iโm sorry guys I only know Fortnite creative logic
You're not alone, I only know minecraft command blocks
its quite easy, if youre using disnake use disnake-jishaku
command blocks?
ok
I am proud Minecraft NBT programmer 
bruh, I also made a plugin one time, it's very easy
kek
ohmygod
I had Optimised code with changes in 13 files
but that... is... burh
Do you know what an NBT is? ๐ญ
it reminds me of
No Buying Tutorials?
Non binary text or smth
what
Named binary tag
yes, absoulutely similar to Named Binary Tag
kek
shut up [This is in answer to Master32's question, to avoid confusion]
Ok sorry
I'll let you work out the other two letters
Uhm... Even though im Russian, I know what that means...
I wasn't talking to you. But while I'm here, be nicer to others.
whats your problem๐
that's SETFU
@slate swan I also saw your message before you deleted it. I suggest you behave better.
!ban etzeitet being mean to others for no reason
imagine allowing everyone to ban joe and kick lemon

no, joe cool
begin learning Python
this channel is never on topic :p
theres no real role for it, but theres been a pr, that was rejected iirc
We don't have a role for that
there's no such role here ig?
where do you think you are then?
#ot3
ofc
i do know, but not as much a pro
Wasnโt talking to you
oh ok
Imagine being Master and saying you don't know Python
embed.add_field(name="Created Account On:", value=member.created_at.timestamp()
embed.add_field(name="Joined Server On:", value=member.joined_at.timestamp()
is this wrong?
yes it is wrong
lmaooo
its ironic how harvs said
If you do not know python please do not speak in this channel ๐ญ๐ญ๐ญ
but continues talking
that edit
you're missing closing brackets
i just accidentally replied to the wrong message
and <t:> stuff to make a discord timestamp
lmaoo yeah
ok
well, that's upto them, they'll get a timestamp float here with what they have rn
yep
there's a class that do this automatically no?
!d discord.utils.format_dt suggested instead of manually creating the timestamp
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
sure
not sure
embed.add_field(name="Created Account On:", value=member.created_at.timestamp(<t:TIMESTAMP>))
embed.add_field(name="Joined Server On:", value=member.joined_at.timestamp(<t:TIMESTAMP>))
now?
bruh
not really
Better discord user
no
yes
Report!!
then pls tell me ๐ญ
watch people get mad at you :p
bruh people are wasting time on such things
i just want a wallpaper
await interaction.channel.send(embed=reply.pages[0])
await interaction.response.send_message(embed=reply.pages[0])
await reply.respond(interaction)
``` any idea why bot is not able to respond?
Here, line 1 works but 2 and 3 cause Unknown Interaction.
reply is a paginator
masters attack
!traceback
bro @silk fulcrum
if ur on discord.py v2 then use discord.utils.format_dt(member.created_at) otherwise you can do something likef'<t:{member.created_at.timestamp()}:{style}>'
what is that? pycord?
!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.
yeah
Traceback (most recent call last):
File "C:\Projects\YourAnimeBot\.venv\lib\site-packages\discord\ui\view.py", line 375, in _scheduled_task
await item.callback(interaction)
File "C:\Projects\YourAnimeBot\views\select_view.py", line 31, in main_callback
await interaction.response.send_message(embed=reply.pages[0])
File "C:\Projects\YourAnimeBot\.venv\lib\site-packages\discord\interactions.py", line 695, in send_message
await self._locked_response(
File "C:\Projects\YourAnimeBot\.venv\lib\site-packages\discord\interactions.py", line 942, in _locked_response
await coro
File "C:\Projects\YourAnimeBot\.venv\lib\site-packages\discord\webhook\async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
is it taking 3+ seconds to reach that code?
๐
nope,
if i do interaction.channel.send(embed=pages[0])
sad
it works
what happened
pycord is..... not the best library
well, i am pretty sure this is a problem from my side
not working ๐ญ
Just use dpy 2.0
which part?
What about it doesn't work
Sure other forks make it easier but then you are not learning
?tag idw
This is not a Modmail thread.
oof
embed.add_field(name="Joined Server On:", value=(f'<t:{member.created_at.timestamp()}>'))
If i do
await interaction.channel.send(embed=reply.pages[0]) it works
But if i do
await interaction.response.send_message(embed=reply.pages[0])It doens't work.
Both are basically the same thing, one is just sending other is responding so time taken should be same
why the heck would you combine that
decided not to caps
you need to add the style, after you put the timestamp add :R or repalce R with another style
You should be able to do it without that tho
File "main.py", line 130
embed.add_field(name="Joined Server On:", value=(f'<t:{member.created_at.timestamp()}:{style}>'))
^
SyntaxError: invalid syntax
where is style defined
it wont
seems like an error that might come from one of the lines above this
embed.add_field(name="Joined Server On:", value=(f'<t:{member.created_at.timestamp()}:{R}>'))
like this?
What
R doesnt go in the {}
alr
just a normal part of the string
try deferring it anyways
!e
a = (1)
b = (1,)
print(type(a))
print(type(b))
@torn sail :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | <class 'int'>
002 | <class 'tuple'>
await interaction.response.defer()``` at the start of button or whatever you are making
This is not your button to click! 
!timeit py print('This is not your button to click')
@silk fulcrum :white_check_mark: Your 3.11 timeit job has completed with return code 0.
500000 loops, best of 5: 567 nsec per loop
the bot is displaying this:
Joined Server On:
<t:1621163826.883:R>
Doesn't it render interaction.response.send_message useless
what
oh change {member.created_at.timestamp()} to {member.created_at.timestamp():.0f}
it will remove the decimals which discord doesnt want
int()
Never mind
i think this way is faster
perfect it works now
๐
Traceback (most recent call last):
File "C:\Projects\YourAnimeBot\.venv\lib\site-packages\discord\ui\view.py", line 375, in _scheduled_task
await item.callback(interaction)
File "C:\Projects\YourAnimeBot\views\select_view.py", line 27, in main_callback
await interaction.response.defer()
File "C:\Projects\YourAnimeBot\.venv\lib\site-packages\discord\interactions.py", line 542, in defer
await self._locked_response(
File "C:\Projects\YourAnimeBot\.venv\lib\site-packages\discord\interactions.py", line 942, in _locked_response
await coro
File "C:\Projects\YourAnimeBot\.venv\lib\site-packages\discord\webhook\async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
looks like something is wrong with interaction itself.
interaction.channel.send doesnt send with the interaction
it just sends a normal message in the channel
kbut that means interaction is not none atleast
Doesn't Discord invalidate your interaction when you handle it by sending a message
yeah, so respond should work right?
await interaction.response.send_message(embed=Embed(title="Hello"))
even this is giving Unknown interaction
But have you not already sent a message through the interaction by then
also does anyone know how to display key perms
i was just testing it by sending a message. cz it doesn't work with responding
@torn sail int() seems to be faster
idk maybe im wrong
at least i heard round() is bad
it is
!timeit
f'{int(12345.67)}'
This is not your button to click!
yeah same
weird is that round is also pretty fast
Because :.0f only loads a constant, and calling int loads this name and calls it
Besides the other parts of the expression, obviously
!timeit py f'{round(12345.67)}'
@silk fulcrum :white_check_mark: Your 3.11 timeit job has completed with return code 0.
1000000 loops, best of 5: 205 nsec per loop
WHAT
It should be as fast as doing :.0f because they do the same thing
well in c you can do (int) 2.5 or something so maybe that used that directly in python which would make sense why its faster
This is not your button to click!
It doesn't work the same way here at all
yeah idk what i meant
Calling int on a float rounds towards 0 (when float.is_integer() == False)
oh that's just a small amount of operations
that's why so fast
well int is still faster
but round seems to be faster than 0f ๐ณ
yeah but ive heard it can end like 0.999999999999
ok i am writing a complete explanation of my problem..
The point of rounding is to not have that many digits
I don't think it ever outputs irrational float values
complete explanator
What are we even talking about 
The performances of turning a float into an int
this is #ot3-discord-bots
Yikes
where in the cpython repo is the source for builtin types?
should really be an actual ot name one day
ofc

SO i have a custom paginator based on original paginator which is like this.
class SelectPaginator(pages.Paginator):
def __init__(self, pages: list, reply_callable: callable, timeout: int = 30):
prev_btn: PaginatorButton = PaginatorButton(
"prev", None, PREV_EMOTE, ButtonStyle.blurple)
next_btn: PaginatorButton = PaginatorButton(
"next", None, NEXT_EMOTE, ButtonStyle.blurple)
buttons = []
buttons.append(prev_btn)
buttons.append(next_btn)
super().__init__(pages, loop_pages=True, show_indicator=False, use_default_buttons=False, show_disabled=False,
disable_on_timeout=True, custom_buttons=buttons, custom_view=SelectView(reply_callable), timeout=timeout)
```It adds a custom view which is like this :
```py
class SelectView(View):
reply_callback: callable = None
def __init__(self, reply_callable: callable, timeout: int = 30):
super().__init__(timeout=timeout)
self.reply_callback = reply_callable
select_button: Button = Button(label="SELECT", style=ButtonStyle.green)
self.add_item(select_button)
select_button.callback = self.main_callback
async def main_callback(self, interaction: Interaction):
reply = await self.reply_callback()
await interaction.response.send_message(embed=Embed(title="Hello"))
await interaction.response.defer()
if isinstance(reply, Embed):
await interaction.response.send_message(embed=reply)
elif isinstance(reply, pages.Paginator):
await interaction.channel.send(embed=reply.pages[0])
await interaction.followup.send(embed=reply.pages[0])
await reply.respond(interaction)
Main purpose is when someone clicks on Select Button, a function is called as a callback
and that callback function returns either a select paginator or embed
dude made his own paginator based on pages.Paginator
which is to be sent
๐
cz normal paginator dont have buttons to select stuff
and it works
90% of the time
there is just one case where it is not working and giving Unknown Interaction
I just copied RDanny's paginator style
and can't think of anything else than it
oh that's pycord I shouldn't forget
i hate making paginators
why are you guys ewing on pycord when its clearly an external problem
What the fuck is a paginator
kek
how could a paginator look if not like Danny's?
taking a large list of things and splitting it onto multiple pages of something
Ok
Doesnโt sound hard why are yโall crying
we are arent "ewing" it because of an "external problem" where doing it because its source is garbage lmao
Etzeitet went offline
๐ฏ
or did he?
Iโm scared
its not hard, making a correct implementation that can be customizable is whats hard
I donโt wanna get banned for the third time
bruh, what a guy
Ah okay
is anyone willling to follow along i can explain what i am doing
Python discord bans are so harsh
just because of spamming mentions
Did you ask a discord js question
People when noises 
I didn't know I would've get banned for spamming mentions in thread called "Spam" or smth like that
Mods when you spam in spam ๐ญ๐ญ
and iirc I was spamming mentions of myself or my alt account
https://paste.pythondiscord.com/redamirema
nothing fancy, but works like a charm
What does iirc mean ๐ญ
``def runGiveTokens(amount: int):
if amount % 1 != 0:
amount += 1
tokens = get_all_tokens("tokens.txt")
all_data = []
tokens_checked = 0
actually_valid = 0
give_token = 0
for token in tokens:
s, headers = get_headers(token)
profile = validate_token(s, headers)
tokens_checked += 1
if profile != False:
actually_valid += 1
data_piece = [s, token, headers, profile]
all_data.append(data_piece)
print(f"{Fore.GREEN} > {Fore.WHITE}{profile}")
else:
pass
for data in all_data:
lines = 0
s, token, headers, profile = get_items(data)
if give_token >= amount:
with open('tokens.txt') as f:
for line in f:
lines += 1
contents = f.readlines(amount)
removeToken(token)
makeUsed(token)
@bot.slash_command(guild_ids=[settings["guildID"]], name="givetoken",
description="Allows you to give tokens to an buyer.")
async def token(ctx: discord.ApplicationContext,
amount: discord.Option(int, "Number of tokens to give.", required=True)):
if not isAdmin(ctx):
return await ctx.respond("Only Bot Admins can use this command.")
if isAdmin(ctx):
await ctx.respond("Started, this could take a while.")
runGiveToken(amount)
return await ctx.edit(f"{contents}")``
miru is like discord.ui.Views in hikari
This is against everything
Can someone help
I want to send tokens with /givetoken (Amount)
except rule 5 i guess
From an file
hikari was coded by an otaku or anime weeb ig
!rule 5
equivalent to ```py
import discord
from discord.ext import commands
from discord import ui
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
Itโs against tos I think
whats really the term "token" used for here?
spoiler: it is
u know and u still ask?
you forgot to add a return annotation to your initiate dunder kek
You are searching through logged profile tokens I think
now the whole code gonna blow up
I'm making accounts an use the account to give
No i dont know
Thatโs against tos
these tokens are tokens of users those will join servers to boost them when command executed
yay didn't use mypy back then, that code is like 6 months old :p
No i dont
mypy
it is
Its hand maked
Ikr
I'm making accounts an use the account to give
you want a boyfriend?
Making could mean multiple things
yeah this is my time to leave now
yaoi gang ๐
why:(
๐ yes, don't really like pylint for reasons
Ong
oh there is Asher and sarth then ok bye leave
Asher and Sarth slander

I pretend to know python so I can call other people code bad
ur code bad cus u dont know pithon ahhafehufahowefh im su gud at thus siht
whats bad here?
from typing import Any, Iterator
class GeneralCache:
def __init__(self) -> None:
self.hashmap_cache: dict[Any, Any] = {}
self.hashmapless_cache: list[Any] = []
def __iter__(self) -> Iterator[tuple[Any, Any]]:
for a, b in zip(self.hashmap_cache, self.hashmapless_cache):
yield a, b
def __class_getitem__(cls, item) -> str:
return f"{cls.__name__}[{item.__name__}]"
def __contains__(self, val: Any) -> bool:
return (
val in self.hasmap_cache.values()
or val in self.hashmapless_cache
)
i need feedback especially with my namespaces
Everything
Learn python smh
what
hashmapless cache wtf !
It was a joke ๐ญ
pretty funny namespaces ikr
zeffo give me advice
Has anyone done a Discord bot which plays certain radios?
Forget the name it is O(n) cache !
Probably not
๐
can a dunder method be decorated?
Yes
its a method obj so ofc
Itโs a method object, of course it can
ic i never tried so was just curious
Like FM/AM?
discord bot catching radio waves
i tried segfaulting and my computer exploded, so dont be scared of trying stuff
hm... looks weird
That would be cool xd, but similarly to this: https://raadiod.com/#myhits
Why there is quote in front of arrow
not sure where they get the audio
for you to ask ๐
!timeit
12345.67.__trunc__()
@torn sail :white_check_mark: Your 3.11 timeit job has completed with return code 0.
5000000 loops, best of 5: 43.3 nsec per loop
!timeit
int(12345.67)
@torn sail :white_check_mark: Your 3.11 timeit job has completed with return code 0.
2000000 loops, best of 5: 123 nsec per loop
much faster way
wrong channel ?
imagine using __trunc__()
Imagine knowing what the fuck that means
how would that look in code of the bot
truncate your float
and we saved a few nano seconds yay
magik
apparent int(12345.67) calls float.__int__ which doesnt eixst then float.__index__ which doesnt exist and then finally float.__trunc__
50
It is like using fstring instead of str(), faster but will cause Guido to visit u at 3 am with machete ๐ฉ
๐
!e
print(dir(float))
@shrewd apex :white_check_mark: Your 3.11 eval job has completed with return code 0.
['__abs__', '__add__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getformat__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__int__', '__le__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__pos__', '__pow__', '__radd__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmod__', '__rmul__', '__round__', '__rpow__', '__rsub__', '__rtruediv__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', 'as_integer_ratio', 'conjugate', 'fromhex', 'hex', 'imag', 'is_integer', 'real']
complex number's stuff
I wanna see abs
!timeit ```py
"12345.67".split(".")[0]
@pliant gulch :white_check_mark: Your 3.11 timeit job has completed with return code 0.
2000000 loops, best of 5: 168 nsec per loop
!e
print(dir(float)[52][-5:])
@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.
ratio

Ah It ran with a different amount of loops
How many
6
Does anyone have any idea how this happens? My bot works perfectly fine but randomly after like 2-4 hours it just goes offline?
And the terminal gets killed on my vps
Is it true that Discord removed Selects from modals?
I am?
Clearly not
yeah idk why after like a while it kills it idk why
why does it print "killed"
it was never supposed to be there in the first place
you for sure have something like that in your code
It used to work fine when I had it on heroku but since I switched to a vps it does this and is really annoying, if I am asleep and it goes down its down for a long time :( ๐
But an error or multiple shouldn't be killing it
Darn, I was enjoying them in my forms. Are there plans on bringing it back?
probably not but it would be nice if they were
Anyone got idea on how I could maybe fix my issue?
From my understanding it was a bug that you were even able to use select inside of the forms, as they are still in development, discord will release them again once development is finished
oh theyre coming back?
That's what I got from the official discord API server
I would like all sorts of stuff for modals, like checkboxes and whatnot
they have a lot of potential
I don't think so, since it was working fine on a other host, but since I switched a vps it does this
hpop
I have, doesn't seem like anything is wrong that
float.__int__ exists
what are you even doing lmao
91.6 in 3.11 what about 3.10 ๐
burh
@silk fulcrum :warning: Your 3.10 timeit job has completed with return code 0.
[No output]
according to google it does not which confused me
!timeit
12345.67.int
@maiden fable :warning: Your 3.10 timeit job has completed with return code 0.
[No output]
uhhuh
what are yโall doin
Tryna run a timeit job on 3.10
seeing how to convert floats to int fastest
Don't you have Python 3.10 at home
But I ain't got 3.11
how do we manage to talk about everything except discord bots here consistently
Because.... this is #discord-bots
The most active topical channel
Whoโs we 
ot3 off the edge
I firmly believe some of the questions being asked here are also unrelated to the topic
โMom can we get 3.10โ
โWe have 3.10 at homeโ
3.10 at home:
well some guy was make discord timestamps with datetime.timestamp() which returns a float and we wanted the fastest way to remove the decimals
LMAO
Every time I visit this channel, I wonder the same
Iโll let it slide ๐คซ if we keep this from the mods
then we wondered why caling int() is faster than :.0f in f strings
!timeit int(str(123.456).replace(โ.โ, โโ))
@slate swan :x: Your 3.11 timeit job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<frozen runpy>", line 198, in _run_module_as_main
003 | File "<frozen runpy>", line 88, in _run_code
004 | File "/usr/local/lib/python3.11/timeit.py", line 376, in <module>
005 | sys.exit(main())
006 | ^^^^^^
007 | File "/usr/local/lib/python3.11/timeit.py", line 315, in main
008 | t = Timer(stmt, setup, timer)
009 | ^^^^^^^^^^^^^^^^^^^^^^^^^
010 | File "/usr/local/lib/python3.11/timeit.py", line 123, in __init__
011 | compile(stmtprefix + stmt, dummy_src_name, "exec")
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/uzavawileb.txt?noredirect
will I get a role for participating in PyWeeK?
๐ญ
!timeit ```py
12345.67 // 1
@pliant gulch :white_check_mark: Your 3.11 timeit job has completed with return code 0.
20000000 loops, best of 5: 12.7 nsec per loop
It doesn't remove the decimal point
its floor division.... it should
\u200b
It'll zero it
iirc
ow
It does floor division, it just doesn't get rid of the decimal point for float types
When either the divisor or the dividend are floats, arithmetic operators return floats
huh
there will be .00 after decimal point
Okay easy fix is to omit the floordiv operator and use the dunder method directly then
!timeit ```py
12345.67.floor()
@pliant gulch :white_check_mark: Your 3.11 timeit job has completed with return code 0.
5000000 loops, best of 5: 46.4 nsec per loop
Even for % and **
gonna update something in my bot ๐ช
which one u gonna use
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
That works
this @torn sail
why were u not using that before lol
<t:-0>
my favorite time
was that the moon landing?
because I'm a dumbass?
no
Unix epoch
About 62 and a half milliseconds on my machine
>>> from timeit import timeit
>>> timeit("12345.67.__floor__()") * 1e3
62.45430000126362
>>>
that was the Unix epoch
same thing
if only they were
whats the f string format to convert base10 into base 2 i forgor
b
int(34567, base=2)
Wasn't the moon landing in July something?
b for binary, o for octal, x for hexadecimal
yes but i forgot the length etc and how its placed lol
before those shows the prefix
something like 0bbut i forgot how its placed
!e print(b"45678")
@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.
b'45678'
08b shows a zero padded 8 digits long binary number
shit im dumb
thats a bytes object
@brazen raft :white_check_mark: Your 3.11 eval job has completed with return code 0.
00010011
yeah, 0 assuring the length by filling it with 0s on the left side
Unless it's longer than 8 binary digits
I got the greggs hoodie
fire
Can someone explain why this script prints the guild name but 2 times.
``` for guild in self.bot.guilds:
print(guild)```
Goes in the femboy closet 
For every guild in the bots guilds it will print the guild object
Yes but my bot is in only 1 server
Can we see the output?
print self.bot.guilds and show us
<discord.utils.SequenceProxy object at 0x0000025424B33790>
Damn I am dumb
but 2 times
[<Guild id=915637697073254471 name='Le Trou Glorieux' shard_id=0 chunked=True member_count=28>]
If i put that in a list
Ok thatโs one guild
show the code that outputs this
print(list(self.bot.guilds))```
of my guild ? or the guilds where my bot is
He did that in the first time
^
no it is
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
!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.
mysql has pools? ๐ณ
yes
You should the initialization stuff in setup_hook, not on_ready
don't do connection stuff in on_ready, use setup hook instead
on_ready isn't always the first event that gets triggered ( in discord.py & forks)
any idea why
await interaction.response.defer(ephemeral=True)
await interaction.followup.send("Hello")
``` this is causing Unknown Interaction?
yes
I should mention it's not an event nor anything, you override bot.setup_hook with that coroutine function
^
bruh
It's simply a coroutine function
im pretty sure it can be registered as an event
literally just being told that its not an event
No decorator
@bot.event
async def setup_hook(): ...
``` is an equivalent of `bot.setup_hook = setup_hook`
yeah
discord.Client.event just uses setattr so yep
Bruh
looks vierd
thats why listeners over events ( if you use Bot ofc)
setup_hook is outside the scope of the first line
imagine
@bot.event
async def start(token):
await commands.Bot.start(bot, token)
๐
you would need self=bot
or you wouldn't?
self is a normal arg in this case
bot.event(lambda start: commands.Bot.start(bot, "token"))
```๐ฟ
Keyword and position work
of course! do not understand my sarcasm and try to combine it even more! that's what you need to do!
Setup hook is in this gist
yessss, combine it.... this already gets too far
man just replace the on_ready with setup_hook in your code
!d discord.Client.setup_hook if you wanna know how that works
await setup_hook()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A coroutine to be called to setup the bot, by default this is blank.
To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.
This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login "discord.Client.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") event.
Warning
Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for "discord.Client.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready")...
How to bump auto bot disbord with python ?
You donโt
has anyone created a bot which plays music from audio/mpeg url (not youtube)
Are u not on discord.py v2?
oh
Yeah that explains it
gosh
You could sublclass bot then override start and add it in there
If you have a url that points to a valid audio file you can use FFmpegOpusAudio/FFmpegPCMAudio
Oh do i check that ?
If that is the case, you have an open terminal window where it is running
hey guys
is there any way we can make the bot list the users with that specific role?
!d discord.Role.members
property members```
Returns all the members with this role.
thanks
Hello people. I am new to making discord bots and started making my first one today. But for some reason it will not reply to me. There is no error and the bot has started up but no reply is received.
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot 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
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
You need message_content
Ohh, I see. The thing is, in the tutorial I am watching there is no mention of intents. I added it after some googling and dont understand this intent things very well. Can I know where I can read up on it? Something a beginner can understand?
Are you watching Lucasโs tutorial?
Its a tutorial from freecodecamp.org
equally as bad
damn
this is a fast changing lib, no video tutorial will do
you'll have to watch docs and their examples to get correct implementations
Ohh, is that so? Ill search for something
Are Lucas tutorial's bad?
Yeah the tutorials are, crudely put, smoking hot garbage
yes
I mean I know youtube tutorials are not recommendable
I remember I got banned from his discord ๐
No they are not, I learned a lot of dpy from him ๐ญ
No Lucas slander 
me too and now I call bot client ๐ข
anyways I have been testing with getting audit_logs but every time it stops at a different number
for guild in self.client.guilds:
try:
async for logs in guild.audit_logs(limit=30000, action=discord.AuditLogAction.ban):
index += 1
print(f'Inserted {index} bans. | {logs.target}')
except:
print('Skipping')
At the moment Im just printing things
It stopped at 588
Skill issue
well, could it be you only banned 588 people?
Throughout all servers, you have banned 588 people 
Let me check the old database
he says it's a differnent number each time, so that wouldn't really make sense then
wouldn't the audit logs of the banned user still remain, even though he got unbanned?
True
Well now it got to 588 again
Any good hosting services for a low price?
Maybe you are getting an error that you canโt see because you are handling it
There are a few good free ones
yeah I was just thinking about that
24/7?
Yeah
which ones
Here
btw if I do
intents = discord.Intents().all()
instead of
intents = discord.Intents.default()
Will it solve this problem
5$ a month its a little expensive for me, i dont have that much money to start with
I saw a hosting option with 512 RAM, for 1$, what do you guys think
It did
Fuckin finally
why is this intend crap so confusing
There are no clear explanations on the web either
well... it still stops at this (same as before)
I got some missing permission errors but I already knew about that
@lapis lintel if you are a student you could try to get the github student developer pack and get some hosting for free
anyways if someone knows why this happens please mention me
using guild.bans() seems to work better
but I would like to use audit logs as it gives more information
https://hastebin.com/jalolaweyo.rb
^ My code ; what would i do if i dont want the first two buttons? the โฉ and โช buttons
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Iโve tried removing the first two but if i do the whole help menu stops working
Hi all! Is there any way to understand this library? because nothing is clear
Skull ๐
Whats not clear
What happens when u remove em?
Hi
I want more than one function to work at different time. Ex: first function at 6Pm second function will work at 9Am and so on. I have been try asyncio and sleep but it doesn't work. I saw some solutions on stack overflow but it doesn't work with me. Please can someone help me
using the on_member_join bot event, how can i get the server id from the server in which the member joined?
member.guild I suppose
someone said member.guild.id so ill try both
async scheduler
or ext.tasks
I did it but It doesn't work with fully correct with my code
kek
Why does this sometimes returns an error? Like the owner is not found
owner = member.guild.owner
em = discord.Embed(title="Alert, actions needed.", description=f"A new user has joined your server but there's no configured alerts channel, please set an alerts channel using **/config_set_channel** on your server ({member.guild}).", colour=0xe74c3c)
em.set_thumbnail(url=member.guild.icon.url)
await owner.send(embed = em)
I guess discord for some reason sometimes returns None as the owner?
await owner.send(embed = em) AttributeError: 'NoneType' object has no attribute 'send'
Well that's what discord.py is doing isn't it?
Is Buttons have exception TimeoutError ?
And how is this different from using discord.Member.ban?
im also using proxies
idk , just ideas
You're aware discord.py works off API requests?
So it does the same thing you're doing here
Using a proxy will slow it down further
itโs just ideas bro
what about threading
The network speed is the bottleneck
Compared to the network request time, the overhead is fractional, if not negligible
Guys how we can make giveaway bot in discord.py?
I think that's way too open ended to be answered properly
Code it
Idk how to make with time
You have a development time limit? Sorry I'm not understanding what you're asking
I mean like command like this !g start 5hrs (prize here)
I want that the after 5hrs giveaway should end
@sick birch I tried changing the file tree of my bot
changed the paths nd shit, but this still seems to error
it cant find connections
i know. I'm wondering why lol
Ah. Maybe asyncio.sleep()?
#help-broccoli i have a simple question guys
Won't it stop comamnd for all?
im asking a dumb question in my help i think everyone know that
I don't think this is related to discord bots either
i know
Like if i used giveaway comamdn in one channel and then in other channel will comamnd work after doing asyncion.sleep()?
yes
Ok
Then don't ask here?
Ty
look in settings.database
if settings.database.connections:
print("true")
else:
print('false')
look if it find the connections
if it dont just look in other modules
me?
@sick birch it is discord bots related tho
it's not an tortoise orm error or any type of db error
its an atr error that used to work before i changed the file tree lol
attribute errors are not directly related to discord bots
24.08 01:58:01 [Bot] [2022-08-24 02:58:01] [INFO ] discord.client: logging in using static token
24.08 01:58:01 [Bot] [2022-08-24 02:58:01] [INFO ] discord.client: logging in using static token
24.08 01:58:01 [Bot] Traceback (most recent call last):
24.08 01:58:01 [Bot] File "/./Bot2/main.py", line 161, in <module>
24.08 01:58:01 [Bot] bot.run(token)
24.08 01:58:01 [Bot] File "/.local/lib/python3.9/site-packages/discord/client.py", line 828, in run
24.08 01:58:01 [Bot] asyncio.run(runner())
24.08 01:58:01 [Bot] File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
24.08 01:58:01 [Bot] return loop.run_until_complete(main)
24.08 01:58:01 [Bot] File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
24.08 01:58:01 [Bot] return future.result()
24.08 01:58:01 [Bot] File "/.local/lib/python3.9/site-packages/discord/client.py", line 817, in runner
24.08 01:58:01 [Bot] await self.start(token, reconnect=reconnect)
24.08 01:58:01 [Bot] File "/.local/lib/python3.9/site-packages/discord/client.py", line 745, in start
24.08 01:58:01 [Bot] await self.login(token)
24.08 01:58:01 [Bot] File "/.local/lib/python3.9/site-packages/discord/client.py", line 577, in login
24.08 01:58:01 [Bot] raise TypeError(f'expected token to be a str, received {token.class!r} instead')
24.08 01:58:01 [Bot] TypeError: expected token to be a str, received <class 'NoneType'> instead
what does this mena ?
How do I modify the contents of an existing embed?
All mighty Robin
Or whoever decides to answer
I require thy infinite knowledge
How do I remove or overwrite the existing !help command?
Is it possible?
how do you downgrade the discord version in shell on replit
What event and callback ? And what's a commands.command is ?
that's a question you can google, we're not google ๐
i looked and got no answers
this is all in the documentation https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html
so i came here
what did you google?
how to downgrade discord version in discord.py
not the correct google keywords
you would be looking for "install specific python package version"
!d discord.ext.commands.Bot.help_command
The help command implementation to use. This can be dynamically set at runtime. To remove the help command pass None. For more information on implementing a help command, see Help Commands.
make sure your bot token is not a nonetype.. make it a str
how to create bot music on discord :)))
!ytdl get ytdl-ed
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโs robots.txt file; (b) with YouTubeโs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
you can use SoundCloud and download songs in cache to play them though
@slate swan Did you hear the bad news?
if im trying to store different values for each user, could i store a dictionary in a file and append the user and their individual "value"?
or does the discord API have an easier solution
yea
what kind of value?
you can save your stuff with respect to user's ID in a dictionary
its a casino type thing, so i want to store the user id and the amount of "chips" they have
alright that's a good base to build off of, thank you
๐ข sad
Thanks! 
A challenger appears
youre welcome
You cant say im a challenger because he gives no challenge making me the winner by default i guess
im joking btw so robin dont take it serious, kek

banned
You dont have such power because youre too weak to manage it, thats why you dont use python and use a language like JS
my english skills are weak as well, anyways i think we should stop joking around lol
@primal token that's my work to be here almost 24/7 dont steal it
my mental health is slowly degrading to a point where i wont take it anymore, so go ahead be my guess
He has connections 
connections that he cannot control, connections that get closed and return an HTTP code of 69420
Me?! i have none :(
Ill rather be broke then have fraudulent money๐
Hi Ryuga
hi
Does anyone know how to send a slash command? I normally just use post requests for sending messages from my account, but I need to know how to do slash commands.
selfbot?
yep
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
No self botting here
oh, i didnt know that sry
but does anyone know where i can get this information if not from here?
๐
Probably you cannot find it
Wait wait wait, what would the line be and where?
I read through and I believe I'm too.. beginner? to understand where and what to place
its a kwarg thats passed into the intialiazer of an instance of the Bot class kek
that is correct.
might also want to look at this: https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96
, help_command = None?
i dont want to see a screenshot of your code ever again
no, you passed a semi colon uppon creation of a pointer/variable
literally not needed at all๐ฟ
smh
shhhhh~
python is too high level for that
New to python, not new to coding
jk btw
The indenting is doing my head in 
kill('noid');```
kek
bruh don't you indent in other languages
I do -- makes it neat
segfault moment
Anyway, this?
yes
```pyjs
console.log('yes')
```
now remove that semicolon before i come for you

okay 
OH YEA, BEFORE I GO
Guido
you dont deserve hell
๐ช ๐ช ๐ช ๐ช ๐ช
you deserve to be put where java is
atleast its not
(commands:=getattr((ext:=getattr((discord:=__import__("discord"), "ext"), "commands")

:o
Epic!
Thanks for that
Now join the esoteric side
no autocompletes ๐
What is the way to have user input button name for persistent views?
Is this possible?
๐```py
import os
import random
import time
import discord
from discord.ext import commands
utils.get
discord.utils.get()
asyncio
discord.client.asyncio
wtah
discord.py has asyncio impoted in bot.py lol, not the best way, but no problems with using it
mah bad, its client.py
@primal token , I SUMMON THEEE
Whatโs the best way to parse Args through an on_message event?
Yea, probably
The guy above you was trolling
Ohh ok . . .
Use commands extension!!
Esplan in few word
Brain juice dry
Wait, could I just split the message into multiple strings and then use those strings as the Args?
I think I solved it, thanks @vocal snow for being such a good listener

I shall return when I fail
Guys I have an issue, I got 3 json files, each file contains information for some stuff like banned ppl, allowed channels, etc.., How to mix them in one file and when I need to get some info about one thing like banned ppl?
Database
paid db?
are there free dbs?
Sqlite is easy to start with
can't I do that with json?
who did this to you, karim
did what
even small amount of data?
Forget the amount of data. You're storing complex, relational data which belongs in a relational database
ok is there any tutorial for sqlite?
why why why
how to clear messages from users on a particular channel
HabitsTheHabitsTheHabits 
Docs
If you haven't used SQL before, check https://sqlbolt.com
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
https://cdn.discordapp.com/attachments/1009847459176009799/1011892541387456512/unknown.png
https://cdn.discordapp.com/attachments/1009847459176009799/1011892644575707136/unknown.png
amount not define in view ??? how can i transfer this amount data to view ?
I have this code
And when I run this code for the dropdown I get this
But then when I tap one of the options I get this
Anyone can help?
phone ๐
@tawdry tendon In your callback you are doing self.label[0], self here represents your View class, so you are trying to get view.label[0], and by the way even Select class doesn't have label, you probably meant select.values[0]
!paste please
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
your images don't even load properly (at least for me)
you cannot delete an interaction, what do you want to do?
!d discord.Interaction.delete_original_response I think this is what you want
await delete_original_response()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the original interaction response message.
This is a lower level interface to [`InteractionMessage.delete()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.delete "discord.InteractionMessage.delete") in case you do not want to fetch the message and save an HTTP request.
BadHabitsTheBadHabits
hm?
are you using discord.py 2.0?
ohhhh
bruh
Is phone replit programming a cult now or smth
tradition
No, Itโ s asking for wrong indentations
๐คฎ
Shit yes, thank you so much
It still has the error
what error
Iโm in Spain my computer is in England but Iโm flying back in like 1 hour
The interaction failed one
RDP ๐
Yup
what was it called to get a channel?
i remember it was something like bot.get.channel
get_channel?
if checks exist
thanks
if something.channel.id != my_channel_id: return
Ssh
thanks
is it possible to just delete every message?
that is send in that channel
uhm... check if channel.id is your channel id and then delete the message?
isnt that obvious...
thanks
Guys how can I make a button that can be only used by the comamnd user not by others ?
you could save the id of the user who requested the command and when someone clicked on the button, you would check if it is the same id of the person who requested the command
add an interaction check
send a example
!d discord.ui.View.interaction_check
await interaction_check(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.
This is useful to override if, for example, you want to ensure that the interaction author is a given user.
The default implementation of this returns `True`.
Note
If an exception occurs within the body then the check is considered a failure and [`on_error()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.on_error "discord.ui.View.on_error") is called.
thx
class MyCoolView(View):
async def interaction_check(self, interaction: Interaction):
return interaction.user.id == my_cool_user_id:```
@slate swan example 
How will it it know if the interaction author Id is == the message author Id?
nice
see an example I see
Bro i mean that how would I store the id?
And send to the button class
you can take a ctx argument when creating a view:
class MyCoolView(View):
def __init__(self, ctx: Context):
super().__init__()
self.ctx = ctx
async def interaction_check(self, interaction: Interaction):
return interaction.user.id == self.ctx.author.id```
and thenpy view = MyCoolView(ctx) await ctx.send("My Cool Message", view=view)
in a command
Ok thanks bro!
is it possible to make a message that is send in a channel to send that to another channel, like that my message gets send to #data-science-and-ml
?
wdym "to send that to another message"
i meant channel sry
Will it be discord.Context or Context?
thanks
that's just my typehints, it's commands.Context
why are you asking these questions? to explain you simple logic? See:
- you check if the message was sent in a specific channel
- then you get a channel where you want to send it to
- and then you send message.content to that channel
what is hard?
ok sorry
are text commands getting discontinued permanently? ๐ฎ
message commands need Message Content intent which is becoming privileged since August 31st, that means that you can still use message commands in your private bots but verified bots will need to get a permission to use it, so that's why everyone switched to slash commands. (Message Content intent not only allows you to use message commands, it is used to see the content of usual messages at all, so without it you can only see contents of messages that contain ping of the bot)
Extension 'cogs.utilis' raised an error: ImportError: cannot import name 'yesno' from 'views' (/home/runner/Bot1/views.py)
Guys why i am getting this error?
But it exists
show the code
See
I did
from views import yesno
in what file
What is this replit mobile stuff ๐
tradition
I thought using replit on computer was bad ๐
Now u got em doing it on mobile
Anyway i changed name of class
Now it's working
I changed name to Yesno
using replit is not exactly bad, it's bad as a VPS, well... bad as code editor tooo...
Iโ m missing the part where itโ s not exactly bad
well.... at least it can run the bot...
that's... already... pretty cool... right?..
Ur computer can too
well... it has a syntax highliting



