#discord-bots
1 messages Β· Page 1116 of 1
who said you can't
full = [b for k, v in dict.items() for a, b in dict[k].items() if a == 'name']
that was it, thank you @paper sluice @shrewd apex !
for nested dicts
hmm
upto one for loop looks clean more than that it gets cluttered 
or maybe it's just phoneπ
whats a and b standing for there
π hello everyone
π
um
hi, so I have a command that creates a custom role
and I'd like this role to be placed at the top of the roles list
how can I do that? because the created roles are at the bottom of the roles list
@client.command()
async def role_perso(message,name,color):
guild = message.guild
#---------------------------------------------------- converts #abcdef to 0xabcdef
colorhex = "0x"+color[1:]
colorhex = int(colorhex, base=16)
#----------------------------------------------------
await guild.create_role(name=name, color=colorhex)
role = discord.utils.get(guild.roles, name=name)
await message.author.add_roles(role)
msg = await message.channel.send("Role added!")
!d discord.Role.position
The position of the role. This number is usually positive. The bottom role has a position of 0.
Warning
Multiple roles can have the same position number. As a consequence of this, comparing via role position is prone to subtle bugs if checking for role hierarchy. The recommended and correct way to compare for roles in the hierarchy is using the comparison operators on the role objects themselves.
thank you!!
my question is dumb, but how can I check the position of a certain role? I forgot the keyword
trying to interpret this in a way that makes sense is doing my head in lol
list comp are not esotericπ
thats what i meant
look at one liners in esoteric
and u will feel full of motivation
for list comp
esoteric is good
no, it's just those one letter variables that make it unreadable
plus i don't think that should be a list comp anyway
indeed as long as u can understand itπ
if u can understand it, its not estoric
really, then look what I'm plannin'
tru
beautiful
thanks
Yes
yep
hw for someone?
esoteric project for school
Imagine
ngl i had to google what esoteric meant lol
i did that for school i would get 0
i've seen that before
that's called the alphabet not abc
nice
I'M ON PHONE I CAN'T TYPE LONG
postin this again https://github.com/e1pupper/LevelSystem
dis is as simple as simple as it gets fr
it had to be esoteric on purpose, I wasn't feeling up to the point, so I just shat as much as I could Β―_(γ)_/Β―
i suggest figuring out how to make it non blocking
ic
I want to learn esoteric python but can't find any docs π
esoteric python isnt something to be learned
esoteric python is something you make
go search named lambdas
Ye but that skill
eternals is boring
ik them π
i suggest learning Cpython first
nais
it is, cz it's slow and pointless
!pastebin
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.
um ok
Then what do I do I can't understand
i would argue its the worst mcu movie, but i haven't seen em all, so the worst one ive seen till now
I once had to create an API as homework and accidently left return "fuck off" and submitted that project π , Next day when I was presenting it, I got turned out of the classroom
worst one is doctor strange in the multiverse of madness, I swear
write tests pls
π
which school is this api as hw?
?
its not as bad as eternals
Do you guys actually eat bread that's wrapped in bread
but really bad
what...
i ate a big mac
I remember you being british
Lol
bread between bread
i feel this channel has become slightly off-topic
Did it suck
no
write deez nuts across ur face
i been done tests
daz why i posted on git
so what, a toast between breads is bread, so you're eating bread at the whole
What is this for
I've never tried that tbh
Do you say the t's in words
Sandwich
mostly yes sometimes no
ya im not finna do everythin
my wifi smh
Do you say them in sometimes
:pydis_off_topeek:
i alr did the slider and the img placement just change the font
ofc
i can understand k and v, but what does a & b actually stand for?
Alr I'll go π
Poop
shit
Dookie
nvm
discord-bots official shitpost channel?
pfftt
For s
Maybe ur repo is sleeping
thats zzzZZ
Repo have different type of snoring

how can i set a command param not to be required for example if the user inputs !help it shows the help menu or if they do !help tools it shows the tool menu
def ...(ctx, param=None):
if param is None:
do something
37mins
u dont
put it in the constructor
how
def __init__(self, bot):
self.bot = bot
ya
ok
Guys how can we make a turns system
Like first turn of player 1
And then player 2
I was confused so i asking here
Hey guys, Anybody know how i make that if the buttons timeout the buttons get disabled in discord.py 2.0?
!d discord.ui.View.on_timeout
await on_timeout()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A callback that is called when a viewβs timeout elapses without being explicitly stopped.
Ik but how i can disable the buttons, I already tried it but it doesnt work
for item in view.children:
item.disabled = True
Show the code.
Invite Me to The Code.
ok
I am not a Python Developer But i can find where the error is
With what should i define view
ur view what elseπ
you have to iter through view.children
mhm thanks Ashley
Um Bro @loud junco The Code + error says invalid Syntax idk why so in the main file it is error.
u know which line?
i dont see any (e.is)
File "C:\Users\lequi\Desktop\Hint Bot v2\cogs\economy.py", line 16, in on_timeout
for item in Transfermoneybuttons(self.amount, self.author):
TypeError: 'Transfermoneybuttons' object is not iterable
are u trying to iter thru a class π
I dont understand
im very new
This is my view class
π
do that in the class
It is
What does iter mean
for item in self.children:
item.disabled = True
Um Bro in 1st line in main.py there is small red color thing opining up. keep your cursor on it. it shows the err but idk why that error just showed up.
Ye i tried this before
hmm ok
but how do i update the message then?
?
lemme reload the page
does it hurt that much to add a few lines?
yes π€£
at some point i will make all of this into one line
oh god give me new eyes
just use semucolons
thats it
no traceback nothing
whole tracback?
idc, i want new eyes
there is none
create a new repl lol, that's very normal to happen in replit
just 4 lines of error
take mine they are pretty
π€£ confidence speech
no don't fork it, cause it may copy the same setup
:/
do it manually?
π with pain
download all the files as zip, upload and unzip that tar.gz file

Goose bumps
disgusting smh
totally not me
that looks like the Gopher
I work with PIL, the text is not drawn on the picture and the person's ava is not displayed, why?
@bot.command()
async def card(ctx, user: discord.Member = None):
if user is None:
user = ctx.author
print(1)
image = Image.open("fons/user_card.png")
draw = ImageDraw.Draw(image)
print(2)
font = ImageFont.load_default()
print(3)
name = user.name
print(4)
avatar = user.avatar_url_as(size=128)
print(5)
draw.text((145, 30),'Hello World', font=font, fill='blue', size = 50)
print(6)
avt = io.BytesIO(await avatar.read())
print(7)
imga = Image.open(avt)
print(8)
imguser = imga.resize((300, 200))
print(9)
image.save("user_card.png")
print(10)
await ctx.send(file = discord.File(fp = 'user_card.png'))
print(11)β
so many prints
for seeing where it errors
use asyncio.sleep instead of sleep
ya ik, but its a little excessive
You might get more help in #βο½how-to-get-help or #python-discussion, #media-processing
no comments
whole of the command is blocking anyways lmao
@slash.slash(
name="Hello"
guild_ids=[938894294549422080]
)
async def _hello(ctx:SlashContext):
await ctx.send("Yo!")
i get invalid syntax pls help
for the guild ids line
name needs to be lowercase
and don't use a third party lib
use the slash commands dpy provides
i still get invalid syntax
@slash.slash(
name="hello"
guild_ids=[938894294549422080]
)
async def _hello(ctx:SlashContext):
await ctx.send("Yo!")
u r missing ,
where
after "hello"
smh
Traceback (most recent call last):
File "main.py", line 8, in <module>
from discord_slash import SlashCommand, SlashContext
ModuleNotFoundError: No module named 'discord_slash'
I also recommend using more up to date version of slash commands.
now i get this error
i recommend not installing diff lib for slash commands
?
that's what I said.....
nd got ignored unfortunately
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
that happens everytime you ask not to use the almighty discord_slash library
yes....
what do i use
this library is no longer maintained, why are you using this?
i saw from a yt video
discord.py/forks have slash command.
inbuilt.
who said yt videos never get outdated.
what do i type then
?
most yt vids are outdated, just refer to docs and examples
install the master branch of discord.py
pip install git+https://github.com/Rapptz/discord.py.git
you need git installed as well
https://gist.github.com/Ashley-Violet/9be0affc876d65138000aea31c84974a
this has all the info about slash commands and installation process :)
Ow
i'll make a why use hikari gist
would be cool
totally not based, and no bitching about discord.py
just like you :))))
so its gonna get ignored as well mhm
π nice
lmao no
no u
ah i realise this is what you were doing few hrs ago
yep xD
even though I wrote it with explanations, people just gonna see the example codes and ignore other stuff π
the user doesn't have a 'bank' key
uwufy the text
what's with the emoji
users[str(user.id)]["bank"] = 0?
Guys how can we make a turns system
Like first turn of player 1
And then player 2
I was confused so i asking here
surely gonna ignored since most people r boomers gonna close it π
use checks
@client.event
async def on_message(message):
if str(message.channel.id) == "988073972681801788":
await message.delete()```
cool
that isnt working is it wrong?
how do you intend for it to work
rn it deletes every messages in a single channel
yeah
yeah it works
dont typecast message.channel.id to be a string, rather compare the integers directly
does someone know a capybara api?
that will give me random pictures of capybaras
but that doesnt work at all
Oh like you first told me the input thing?
i tried int too
still that doesnt work
.wiki capybara
aw mannnn
a wait_for yes
i dunno any api specifically for capybara pics
oh ok
!pypi capybara
still thanks
bruh
yay
https://api.capybara-api.xyz/v1/image/random
returns random images for capybaras
thank youu
https://docs.capybara-api.xyz/reference/images here's docs btw, you can even get facts
I want to use it to make a fight command
So if i want if player 1 and player 2 hp <0
My bot takes input from both like punch , kick
So when any player hp >0 then it do game over
How can I do it?
thanks
I would make an object for each person
ya they are the same thing in python
OOPS ig
Any body knows why my bot showing no erros since i started using cogs?
async def main():
async with client:
await load_extensions()
await client.start("")
asyncio.run(main())
for example
class Player:
def __init__(self, hp: int, armor: int) -> None:
self.hp = hp; self.armor = armor
''' create methods and stuff to reduce hp and armor or whatever '''
player_one = Player(100, 150)
player_two = Player(100, 150)
something like that
!d datetime.datetime.now
classmethod datetime.now(tz=None)```
Return the current local date and time.
If optional argument *tz* is `None` or not specified, this is like [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today"), but, if possible, supplies more precision than can be gotten from going through a [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time") timestamp (for example, this may be possible on platforms supplying the C `gettimeofday()` function).
If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the current date and time are converted to *tz*βs time zone.
This function is preferred over [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today") and [`utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "datetime.datetime.utcnow").
and use a pasting service
Hey help how i can make a ban cmd
ash the semicolon π
π totally me
!d discord.Guild.ban
await ban(user, *, reason=None, delete_message_days=1)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
!d discord.Member.ban
await ban(*, delete_message_days=1, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.ban "discord.Guild.ban").
Any body knows why my bot showing no erros since i started using cogs?
why discord no temp ban builtin π‘
do u have a error handler?
Code one yourself
i have but me want builtin
No, I only got listeners
just time the person out meh
what if my want timeout for 3 years π‘
Yes would be great
async def ban(self, ctx, *, reason):
await ban(*, delete_message_days=1, reason=None)
``` @cloud dawn its not working
just ban the person, even the person wont be interested in joining the server back anymore or most probably would have forgotten about it, and would be a wonder if your bot still runs after 3 years
summoning
ily2
Don't literally copy the code.
kek
wymmmmm
i have never seen this, and i wish i never did
I dunno how often y'all say meh but I catch you lackin pretty often
That you literally copied the "example" code.
async def main():
async with client:
await load_extensions()
await client.start("")
asyncio.run(main())
This is basically the line removing the errors from my bot
Anybody knows why
!resources learn python before making discord bots
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
async def ban(self, ctx, *, reason):
await ban(*, reason=none)```
not working
BRO
await member.ban(reason="Blabla")
π
You dont even really specify a member
async def ban(self, ctx, member: discord.Member, *reason):
@commands.command()
async def selfban(self, ctx):
await ctx.author.ban(reason="fuck you")
welcome
π₯ π₯£ ποΈ
there are no good hand emojis
@paper sluice π wanna exchange eyes still?
what a fuckboy
lmao
π
lol
the problem is he probably succeeded
π

hm
*for holding a spoon
sarth π
yeah I don't see any either
π€
I know you don't hold a spoon like that but okay
async def main():
async with client:
await load_extensions()
await client.start(token)
asyncio.run(main())
Any body knows why this is removing erros.
it's not
what is inside load_extensions
async def load_extensions():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
await client.load_extension(f"cogs.{filename[:-3]}")
!d object has no attribute 'name'
class object```
Return a new featureless object. [`object`](https://docs.python.org/3/library/functions.html#object "object") is a base for all classes. It has methods that are common to all instances of Python classes. This function does not accept any arguments.
Note
[`object`](https://docs.python.org/3/library/functions.html#object "object") does *not* have a [`__dict__`](https://docs.python.org/3/library/stdtypes.html#object.__dict__ "object.__dict__"), so you canβt assign arbitrary attributes to an instance of the [`object`](https://docs.python.org/3/library/functions.html#object "object") class.
yeah that doesn't either
show full traceback
And in the cog is no command except test
what
file list to array
wdym
uhhhh
this is #discord-bots π
!d attribute
A value associated with an object which is referenced by name using dotted expressions. For example, if an object o has an attribute a it would be referenced as o.a.
bro !d is not a get help command, it mentions docs.
where to go since idk ma men
ik
someon helpme very important i cant start my bot it says rate limit exceeded plz
replit?
yes
@cloud dawn its not workinngg
@commands.command(name=ban)
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f'User {member} has been baned from the server.')
send error
is this in a cog
ya
Forgot self,
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f'User {member} has been baned from the server.')
```?
yes
okk thanks
u have ban outside quotes, so unless u defined it, its gonna throw and error
its not still working
Anyone know how to fix this error?
object has no attribute 'name'
ohh yeah i forget
Show code
please stop saying not working, show the error
if after.channel.name == "π€ο½join to create": the error is on name in this line
Do you use it in event?
@client.event yes
Ok, So try it with id
already did it the same error but with id
async def on_voice_state_update(self, member, before, after):
if after.channel != None:
if after.channel.id == channelid:
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "ban" is not found
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "ban" is not found
Did yo got it like that?
helppp
@client.event
async def on_voice_state_update(member, before, after):
if after.channel.name == ":microphone:ο½join to create":
CAT = discord.utils.get(member.guild.channels, name="Voice")
vc = await member.guild.create_voice_channel(f"{member.name}", category=CAT)
await member.move_to(vc)
else:
if str(before.channel.name) == str(member.name) and after.channel == None:
await before.channel.delete()```
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f'User {member} has been baned from the server.')```
leguait
Youre cog is not loaded
wym
Did you load your cog?
wymmm
im gonna try this
Thats what worked for me
k i got a error with channel just
?
bot.load_extension("commands")
if this mean the load yea i loed it
So you got a single cog for all your commands?
await bot.load_extension
ye...
If you use discord.py 2.0
Then why u use cogs
await bot.load_extension(commands)
You could just write the command in one file
do you know a delete channel when 0 people in code because thats the problem for me relly
u mean this?
someone teached me and he was doying it in cog and soo idk..
just
nvm why its not workiing
offf
Because your cog isn't loaded
Obviously it says that there is no command with that name
So it means that the command is not loaded
Can I bypass it if I reset my wifi ip?
No
Replit is a pretty bad service so not sure what you were expecting
@client.command()
async def role_perso(message,name):
guild = message.guild
await guild.create_role(name=name)
role = discord.utils.get(guild.roles, name=name)
await role.edit(position=20)
This doesn't work, how do I change a role's position?
I bypassed it by running kill 1 in shell
just another normal day of replit
Dude its free hosting 24/7 i never had a issue
now u will have π€£
I wont spend money on hosting
im also using replit
we will find that out later
π€£
? This is my first issue with it
my man hacked a hacker plan
that doesnt reset your ip, it resets the repl's IP
Yes and it wokred
lol
I know?
thats the part
u dont
If you really need it I guess you can use heroku but its not that good
If you use it for free
If you host with heroku for free it goes offline for a few days at the end of the month
nobody's arguing
DUDE U TOLD THAT REPLIT IS SHIT
Fucking dumbass
Report ur mom
alt account
Hey calm down
Id so fucking punch you in the face
<@&831776746206265384> can we get someone here? π
π§
<@&831776746206265384> help
Hello
nvm my wifi
Hey!
!mute 815897400211800105 π
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1655999149:f> (59 minutes and 59 seconds).
thanks :)
seriously
lol
How to make a bot a speaker in the stage channel through code?
class discord.VoiceChannel```
Represents a Discord guild voice channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channelβs hash.
str(x) Returns the channelβs name.
you cant
Can ig
How then do some of the popular bots become listers?
but u said speaker 
how can i use a an api?
https://docs.capybara-api.xyz/reference/images this is the api i want to use
check the docs for the api, there is no universal way
you said speaker, you can use the connect method on the StageChannel object
to make the bot a listener
could u look at it? maybe , cuz i literlly have 0 knowledge of apis, and i cant find a yt vid
you just have to make get requests and it'll return back a response
what? how would it look alike?
import aiohttp
async with aiohttp.ClientSession() as session:
response = await session.get(url)
content = await response.json()
^
^
preferably use the cm session as well
^
bro that was so helpful, i know that it is dumb to copy paste. but this time i needed this thanks
Nice
hi
hello.
does anyone know how to send a message with a bot once a specific user sends a specific message?
use the on_message event
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your botβs own messages and private messages are sent through this event. This can lead cases of βrecursionβ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
what would the command look like? cuz like if i make @bot.commad() it will give me a error
what? like command.command?
async def main():
async with client:
await load_extensions()
await client.start("")
asyncio.run(main())
After is started using this because of my cogs it started to output no erros in the terminal even tho i have errors i have no error events
igtg and it wont error
oh ok
Cog?
no i dont use cogs
then @bot.command()
async def capybara (aiohttp.ClientSession() as session):
response = await session.get(https://api.capybara-api.xyz/v1
/image/random)
content = await response.json()``` like this? but it says session is not defined
can someone help?
did you do pip install discord?
Install discord
in the terminal
thanks will check it out
well, how can i check that?
Your botβs own messages and private messages are sent through this event. This can lead cases of βrecursionβ depending on how your bot was programmed. If you want the bot to not reply to itself, **consider checking the user IDs**. Note that Bot does not have this problem.
checking the user id before letting the bot send a message
if message.author == bot.user:
return
async def capybara(ctx):
try:
async with aiohttp.ClientSession() as session:
async with session.get("https://api.capybara-api.xyz/v1/image/random") as r:
data = await r.json()
await ctx.send(data["storage_url"])
except Exception as e:
await ctx.send(f'{e}')
``` why isnt this working?
define not working
what?
we should add a rule to this channel, anyone who says "not working" should be banned /jk
what
what is not working here?
nothing happens, it returns no error in console
Maybe not to that extreme but itβs definitely a pet peeve of mine
fr(french revolution)
what does data["storage_url"] return?
it returns a picture of an capybara
did u restart the bot after adding that command?
yes, is it working for you?
cuz it isnt working for me idk
yes
can someone help? I have already downloaded the discord module
are u sure u have the command above bot.run or whatever ur using to start the bot
yess, is it working for you?
u installed discord and ur still getting that error? which ide do u use?
i didnt test it, but it should
Try a venv
idk. cuz it isnt working
print something inside the function to try and find out why it isnt working
ok.
^
can't i just do?
if message.author.id == (int or str???):
return ...
is the id a string or an integer?
int
id will always return int, idk why you want to check that?
yes you can do that too, just put in the id there
for a specific user
like if a certain message is sent, it will return a message
but ur checking author.id which is always interger
bruh they are just asking what type is message.author.id
so i have a variable in my command how can i use it in the buttons class?
make the variable an instance or bot var
how?
bot.x = something
yes
just do it in the button class y do in bot
button class is recreated for each command call bot is not there might be a few unexpected behaviour
or make in the view class
because maybe the function is in different namespace
hmm a bit more detail would be nice
That wont work
message.author.id will never return a tuple
its not a tuple
bro you all cant see this msg
i just wanted to ask if its int or str
you have to use the in keyword to check if the id is in an iterable
if message.author.id in (id1, id2,):
...
thanks nova haha
lol
this guys
Select choose python version
int, Nova told you
yeah
they aint entering a tuple either ```py
message.author.id == ( 1224 or "1234")
some people thinking its a tuple lol
smh
message.author.id in ( 1224 or "1234")
who are these some people, i just wanna say hi
wrapping an object in ()s doesn't make it a tuple my sir
hi
Oh wait
π
My phone didnt show me the whole thing
hi π«
im also wondering who they are π€
parentheses -> ()s π nice abbreviation
bruh
zeffo go away
Brackets
llmaoo
yeah shoo
() = tuple
(something) = type of something
1, = tuple
paranthesis
my abbreviations are always noice
what are you cooking

type of something?
vscode
wdym
Venvs usually fix all these sorts of issues
like a = (1); type(a) # int
class Buttons(discord.ui.View):
def __init__(self, author, member, *, timeout=180):
super().__init__(timeout=timeout)
self.add_item(Select())
self.author = author
self.member = member
async def interaction_check(self, interaction: discord.Interaction):
if interaction.user != self.author:
await interaction.response.send_message("You can't use that", ephemeral=True)
return False
return True
@discord.ui.button(label="0",style=discord.ButtonStyle.green)
async def gray_button(self,interaction:discord.Interaction,button:discord.ui.Button):
label = int(button.label)
label += 1
button.label = label
await interaction.response.edit_message(view = self)
How do i do that the select item is listed over the button
basically, it does nothing.
Why is 1 in parenthesis here?
same question
enclosing items functionally really doesn't do anything
cuz of this
yeah so (x) is x, not type of x
i was talking about types in that whole message ....
!e print((1) == 1)
@sick birch :white_check_mark: Your eval job has completed with return code 0.
True
someone was confused with how tuples work, they thought (element) is tuple
they're equivalent
waht
Ah okay, makes sense. Yeah that is quite confusing
OH i understand what you are saying
!e
x = (1)
print(type(x))
x = 1,
print(type(x))
tuples don't get created unless π
restart ide, if it doesnt fix the issue try a venv as robin said
u dont need parens in second one
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | <class 'int'>
002 | <class 'tuple'>
as you like
clean
I just wanted to make it clear
Β―_(γ)_/Β―
idk how many times did i do ```py
embed = hikari.Embed(...),
imagine
?
you can't, it's how discord works
its in the first row, and the buttons are in the second row
How to do it in the first row
!d discord.ui.Select
class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.
This is usually represented as a drop down menu.
In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Select.values "discord.ui.Select.values").
New in version 2.0.
"row" kwarg
@...button(..., row=1)
and 0 for select
Thanks very helpfull
@client.command()
async def dsetup(ctx):
await set_dono(ctx.guild,ctx)
dono = await get_dono()
with open("gdono.json", 'w') as f:
json.dump(dono,f)
``` code ^
Is the json empty?
line: 1008 nice
ur looking for guild id not a channel
How do i make pages with commands from cogs
It is sync.
ic
so like only 5 commands show in first page
They open a separate thread (task) for it.
^
in simple words, it supports asynchronous opening and file methods
ik ik i had a doubt since i saw sync opening in quite a few repos
they just dont know that opening those are sync or that the time duration is almost negligible
ummm i need some help
no
hmm π€ prolly the latter since those were some advanced repos
ya pretty much everything builin in python except asyncio is sync
ic
im new to python, whats wrong with this
Sync opening a file on startup etc is fine but if you are going to repeat that process it's best to use aiofile
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
a task as in an asyncio task?
indeed
Most likely they use asyncio
Yeah and a context manager, basically the best situation.
asyncio ofc, they use run_in_executor not sure if it can still be termed as Task
my pet peeve with async programming is that it just looks ugly and is more lines of code
run_in_executor has always been iffy with me when talking about discord.py
I feel like in some cases it'll cause issues with the ratelimiter cause locks aren't thread safe
but most people will probably never face that issue
say's unknown message but it is there
ummm
should be using threading module instead right? ( im referring to this: https://docs.python.org/3/library/asyncio-sync.html#:~:text=asyncio primitives are not thread,to perform operations with timeouts.)
any help>
you don't have an env named TOKEN setup, if you do, its not loaded
asyncio provides more support for concurrent.futures than for multiprocessing and threading from as far as i have used them
client.ctx? is that some custom attr?
I cba to look into it rn, but most often than not, for things your running in a thread via run_in_executor, you'll most likely never need to do requests as I'm gonna assume that'll be done in the entrypoint
got client.ctx = ctx in my command
this is a class btw
won't it be self.client if in a class
$poetry add python-dotenv
``` ```py
# in code
from dotenv import load_dotenv
load_dotenv("token.env")
lemme try it
whats $poetry?
check your shell
poerty is a package manager like pip
hmm yeah sarth why do u use poetry it's fine to generate using pip right?π
poetry basically wraps pip lmao
are there any big advantage using it?
more control
its not builtin
btw i add the lower block in the main code and the first one in the shell right?
i can specify the exact version of the library with python version relation
how does that help
ic
yes the upper one goes in shell, lower one in code
when something is builtin, it basically dies in the sense that it takes a long long to time to get new features, whereas external things are more likely to get updated frequently
more focused development i see
if you ever used javascript you'll notice how cool is it to use poetry
cause npm functions somehow similar
mhm
βButtons4β has no attribute βclientβ
im installing a fortran compiler for some reason 
fortran lmao
i will learn js for website designing soon ig
if you want the client just use interaction.client
no need to attach extra attributes
To fetch the message from a different channel?
interaction.channel
will the channel always be same?
for that
drk
If the user updates it will be different
!d discord.Interaction.channel
The channel the interaction was sent from.
Note that due to a Discord limitation, DM channels are not resolved since there is no data to complete them. These are PartialMessageable instead.
you still have the id right?
It would fetch the message where the interaction was sent from
Yah
The message that sent this interaction.
so just get the channel with that id and use fetch_message on that
I got the channel but how do I fetch it?
Directly use fetch_message?
the load_.env comes up as wrong syntax
you copied it wrong
its load_dotenv, not load_.env lmao
Sarth ^
channel.fetch_message(id)
!d discord.abc.Messageable.fetch_message
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") from the destination.
Channel can be a VoiceChannel or StageChannel too, so it doesn't have a fetch_message method
TextChannel is a subclass of Channel and Messageable iirc
βCommandβ object has no attribute βfetch_messageβ
did you define channel as a command or something
!paste show code
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.
how do i make my code in replit active if the tab is closed?
use a host if you wanna do that
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
replit for hosting is bad π
oh ok
whats a good host?
did you do client.ctx = ctx somewhere?
Heya is anybody in here that can help me understand something regarding graphql queries?
type kill 1
Dear please tell me why it is not imported?
in shell then restart
file structure?
also does it give a run time error
clickhouse_secret no import
how do i check if the msg author is the bot itself in a cog?
what is your directory structure
if msg.author == bot.user:
it says its undefined
it's not installed in first place
where in cog are u adding the
that* on message event/listner?
yes
send it here
if message.author != bot.user:
Please tell me what can I do to get it installed.
hmmmmm alright
does it even exist?
Apparently not. I'll post another info then
there is nothing called clickhousesecret π
Is there any info on clickhouse?
yes
there is something missing in ur code then
no no. Do you have a link to the clickhouse-driver guide? how to create tables, how to change the value and stuff like that
I have if message.author != self.bot but it still executes when the author is the bot :/
what's the issue?
It stil executes when the author is bot while having a check
Code pls
it's
if message.author != self.bot.user
message = discord.Message(author=self.bot)```
oh wait my logic failed
...
bruhhhh
i thought my seizures were bad /s
...
smh
/chat-revive
π¨ π applied revive to #discord-bots permanently.
i just did that my bot will send random capybara pictures :D i love my bot xd
neat
nice
nice
bruh, im so dumb lmao. the problem just was the file wasnt saved and , so i didnt upload it correctly. this is why it wasnt working lmao(i use dynox to host my bot)
welcome nice
use autosave, u will never have that problem again
autosave ew
how can i do that in vsc?
might be some option
thanks, ill look for it
yeah there is
most editors save as soon as u edit anything, look for it in the settings
okay
Oh wait it's the mute one
no need of autosave I have a habit of pressing ctrl s and sometimes I press it on Google chrome and it opens the save menu π
i :wq quiet a lot, it gets a little annoying
What hell is :wq
ya i did wq to run code, but in pycharm i have a keybind to run code so i dont have to close the file and go in the termial, still sometimes i do that ( ik u can do :!... and run bash commands, just didnt do that cuz smol window and vim is hard to config )
You can also open a terminal in vim
Ohh
i didnt know anything back then, and habit developed back then π
i haven't actually ever properly configured vim
its sad
https://github.com/an-dyy/nvim my config π³ kind of bad tho
ya i saw that
It's not up to date, but basically all I added was lspconfig
Error while calling lua chunk: /home/rohan/.config/nvim/lua/core/settings.lua:1: attempt to index field 'opt' (a nil value)
i get this while calling luafile init.lua
What is your neovim version
do you guys have any command ideas?
0.4.3
ouf, ok
I mean, the current version is 0.7 after all
Ah yea, checking again lua support was added 0.5
You do need to update to get opt
ya, it installs .4.3 with apt, hold on

apt kek
self destroy, maybe?
windows 10 and wsl is painful, its hard to get stuff done
Neovim has a binary for windows
i think i have it as well
im messy
ya thats 0.7.0
Window has always been bad for TUI stuff
ya getting the same error there
Is your config in the right place?
If your using it on the windows binary it'll have a different directory for the configuration
Compared to that of the one from WSL
hmm, lemme check
we can i use hidden messages in python 2?
ahem
I did my config in like 5 minutes
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
https://github.com/nanotee/nvim-lua-guide#modules
~/AppData/Local/nvim/lua ya i dont have nvim folder there, lemme check scoop
no
yes
@commands.command(aliases = ["123", "321"])
async def command_Forge_image(self, ctx, member: discord.member = None):
if ctx.author.id != 567107484850847744:
img = requests.get(i_background, stream = True)
img = Image.open(io.BytesIO(img.content))
img = img.convert('RGBA')
img.save('./ImageS/kik.png') # ΡΠΎΡ
ΡΠ°Π½ΠΈΠ» ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ
embed = discord.Embed(
title = "123",
color= 0xff0000
)
file1 = discord.File("./ImageS/kik.png")
embed.set_image(url='attachment://kik.png')
await ctx.send(file=file1, embed=embed)
os.remove("./ImageS/kik.png")
Dear tell me why the picture is not sent? does not output errors
@commands.Cog.listener()
async def on_message(self, message):
if message.author != self.bot:
print(message.author)
```this works even when `message.author == self.bot` for some reason :/
@slate swan 
Again my inattention. Thanks
do self.bot.user
hmmm okay
@pliant gulch got it to work, thank you π
π got ignored as usual
pog
thanks

packer.nvim: Error running config for lualine.nvim: attempt to call a nil value i get this tho
Can you send the full error? And we should probably do this in #editors-ides
how would i make it so that whois and usage would be on a seperate line than prefix?
in the add_field set inline=False
inline=False for the add_fields
for the first one or second one?
second one right
for the ones you dont want to appear together
^
