#discord-bots

1 messages Β· Page 1116 of 1

jagged adder
#

ok so i think the problem here is that its not searching under Inv, it can only search through a dict with set keys and values; not a list of dicts or a dict of dicts

#

which is what i think u were sayin before asher

shrewd apex
#
full = [b for k, v in dict.items() for a, b in dict[k].items() if a == 'name']
empty vine
#

that was it, thank you @paper sluice @shrewd apex !

jagged adder
#

hmm

shrewd apex
#

upto one for loop looks clean more than that it gets cluttered lemon_thinking

#

or maybe it's just phoneπŸ‘€

jagged adder
#

whats a and b standing for there

shrewd apex
#

nested dict unpack

#

expand and print as ryuga said b4

slate swan
#

πŸ‘‹ hello everyone

shrewd apex
#

πŸ‘‹

slate swan
#

um

balmy bobcat
#

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!")
slate swan
#

!d discord.Role.position

unkempt canyonBOT
#

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.

balmy bobcat
#

thank you!!

#

my question is dumb, but how can I check the position of a certain role? I forgot the keyword

jagged adder
slate swan
#

It will return the position

slate swan
#

list comp are not esoteric😠

shrewd apex
#

thats what i meant

#

look at one liners in esoteric

#

and u will feel full of motivation

#

for list comp

slate swan
dusky pine
#

no, it's just those one letter variables that make it unreadable

#

plus i don't think that should be a list comp anyway

shrewd apex
paper sluice
#

if u can understand it, its not estoric

slate swan
shrewd apex
#

tru

paper sluice
slate swan
#

thanks

slate swan
shrewd apex
slate swan
slate swan
jagged adder
#

ngl i had to google what esoteric meant lol

slate swan
#

sad

#

Rip abcd

shrewd apex
#

i did that for school i would get 0

dusky pine
slate swan
slate swan
slate swan
dim tapir
#

dis is as simple as simple as it gets fr

slate swan
dim tapir
#

i suggest figuring out how to make it non blocking

shrewd apex
#

ic

slate swan
#

I want to learn esoteric python but can't find any docs πŸ˜”

#

esoteric python isnt something to be learned

dim tapir
#

esoteric python is something you make

shrewd apex
slate swan
#

Ye but that skill

paper sluice
#

eternals is boring

slate swan
dim tapir
shrewd apex
#

nais

slate swan
dim tapir
#

!pastebin

unkempt canyonBOT
#

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.

slate swan
slate swan
paper sluice
slate swan
# shrewd apex ic

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

slate swan
dusky pine
shrewd apex
slate swan
#

?

paper sluice
supple thorn
slate swan
shrewd apex
supple thorn
slate swan
#

Lol

shrewd apex
#

bread between bread

jagged adder
#

i feel this channel has become slightly off-topic

supple thorn
dim tapir
#

write deez nuts across ur face

#

i been done tests

#

daz why i posted on git

slate swan
supple thorn
slate swan
#

I've never tried that tbh

supple thorn
slate swan
dim tapir
supple thorn
shrewd apex
#

the pic tho

#

not my fav

slate swan
dim tapir
#

ya im not finna do everythin

slate swan
#

my wifi smh

supple thorn
slate swan
#

pydis_nope_py :pydis_off_topeek:

dim tapir
#

i alr did the slider and the img placement just change the font

slate swan
supple thorn
#

It would be weird

#

How would it sound

#

Someimes

slate swan
#

someimes

#

some'imes

#

crap

jagged adder
slate swan
#

Alr I'll go πŸ˜”

supple thorn
slate swan
supple thorn
slate swan
dim tapir
#

discord-bots official shitpost channel?

supple thorn
#

I have more questions so i be in dms

slate swan
#

pfftt

dusky pine
#

why is there a random file named s

supple thorn
slate swan
paper sluice
#

thats zzzZZ

slate swan
#

Repo have different type of snoring

shrewd apex
slate swan
#

Ye maybe python snake is active

#

.

#

Ded chat

slate swan
#

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

paper sluice
#
def ...(ctx, param=None):
    if param is None:
        do something
loud junco
#

im back building my bot

#

after how long

paper sluice
#

37mins

loud junco
#

its like weeks at least

#

and how do i define bot in cogs

paper sluice
#

u dont

loud junco
#

huh

#

but

e = discord.utils.get(bot.emojis, name = f'pog_{armor}')
``` @paper sluice
paper sluice
#

put it in the constructor

loud junco
#

how

paper sluice
#
def __init__(self, bot):
    self.bot = bot
loud junco
#

oo

#

i replace bot with self.bot right?

#

most beautiful thing in discord

paper sluice
#

ya

loud junco
#

ok

robust fulcrum
#

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

uncut jacinth
#

Hey guys, Anybody know how i make that if the buttons timeout the buttons get disabled in discord.py 2.0?

shrewd apex
#

!d discord.ui.View.on_timeout

unkempt canyonBOT
#

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.
uncut jacinth
shrewd apex
#

for item in view.children:
item.disabled = True

loud junco
#

what is this lmao

cloud dawn
#

Show the code.

loud junco
#

idk where is it
thats the probem

#

and thats the whole error

bright kindle
loud junco
bright kindle
#

I am not a Python Developer But i can find where the error is

uncut jacinth
shrewd apex
#

ur view what elseπŸ‘€

slate swan
#

you have to iter through view.children

shrewd apex
#

mhm thanks Ashley

bright kindle
#

Um Bro @loud junco The Code + error says invalid Syntax idk why so in the main file it is error.

loud junco
#

i dont see any (e.is)

uncut jacinth
shrewd apex
#

are u trying to iter thru a class πŸ‘€

uncut jacinth
#

im very new

#

This is my view class

loud junco
shrewd apex
#

do that in the class

uncut jacinth
shrewd apex
#

so u are trying to iter the class in the same class?

#

u just need to do in the class

uncut jacinth
shrewd apex
#

for item in self.children:
item.disabled = True

bright kindle
uncut jacinth
uncut jacinth
#

but how do i update the message then?

shrewd apex
#

view=view

#

u edit with the new view

shrewd apex
loud junco
#

at some point i will make all of this into one line

slate swan
#

nvm i mean tracback

paper sluice
loud junco
slate swan
slate swan
#

*semi

loud junco
#

thats it
no traceback nothing

slate swan
paper sluice
loud junco
slate swan
loud junco
#

just 4 lines of error

slate swan
loud junco
slate swan
#

no don't fork it, cause it may copy the same setup

loud junco
#

do it manually?

#

πŸ‘ with pain

slate swan
#

download all the files as zip, upload and unzip that tar.gz file

slate swan
dusky pine
toxic thicket
#

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)β€Š
paper sluice
#

so many prints

slate swan
#

for seeing where it errors

left dove
paper sluice
slate swan
slate swan
#

@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

slate swan
#

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!")

paper sluice
#

u r missing ,

slate swan
#

where

paper sluice
#

after "hello"

slate swan
#

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'

cloud dawn
#

I also recommend using more up to date version of slash commands.

slate swan
#

now i get this error

paper sluice
slate swan
#

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

slate swan
#

i saw from a yt video

#

inbuilt.

slate swan
#

what do i type then

slate swan
paper sluice
slate swan
#

install the master branch of discord.py
pip install git+https://github.com/Rapptz/discord.py.git

you need git installed as well

#

Ow

#

i'll make a why use hikari gist

#

would be cool

#

totally not based, and no bitching about discord.py

slate swan
slate swan
slate swan
slate swan
slate swan
#

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

slate swan
#

what's with the emoji
users[str(user.id)]["bank"] = 0?

robust fulcrum
#

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

slate swan
granite parcel
#
@client.event
async def on_message(message):
    if str(message.channel.id) == "988073972681801788":
        await message.delete()```
slate swan
#

cool

granite parcel
#

that isnt working is it wrong?

quaint epoch
#

rn it deletes every messages in a single channel

granite parcel
#

yeah

quaint epoch
#

yeah it works

slate swan
swift pumice
#

does someone know a capybara api?
that will give me random pictures of capybaras

granite parcel
#

but that doesnt work at all

robust fulcrum
granite parcel
#

still that doesnt work

slate swan
quaint epoch
#

i dunno any api specifically for capybara pics

swift pumice
#

oh ok

quaint epoch
#

!pypi capybara

unkempt canyonBOT
swift pumice
#

still thanks

quaint epoch
#

bruh

swift pumice
#

yay

slate swan
robust fulcrum
# slate swan a wait_for yes

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?

slate swan
paper sluice
#

ya they are the same thing in python

robust fulcrum
#

OOPS ig

uncut jacinth
#

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())
slate swan
# robust fulcrum OOPS ig

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

cloud dawn
#

!d datetime.datetime.now

unkempt canyonBOT
#

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").
slate swan
#

and use a pasting service

warm tulip
#

Hey help how i can make a ban cmd

slate swan
slate swan
unkempt canyonBOT
#

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.
cloud dawn
unkempt canyonBOT
#

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").
uncut jacinth
#

Any body knows why my bot showing no erros since i started using cogs?

quaint epoch
#

why discord no temp ban builtin 😑

paper sluice
uncut jacinth
quaint epoch
uncut jacinth
slate swan
#

just time the person out meh

quaint epoch
uncut jacinth
quaint epoch
#

guess we can't have everything

#

anyway, anyone wanna see my tempban cog?

warm tulip
#
  async def ban(self, ctx, *, reason):
      await ban(*, delete_message_days=1, reason=None)
``` @cloud dawn its not working
slate swan
heady sluice
slate swan
#

ily2

cloud dawn
quaint epoch
warm tulip
paper sluice
heady sluice
#

I dunno how often y'all say meh but I catch you lackin pretty often

cloud dawn
warm tulip
#

soo what i have to doo

uncut jacinth
#
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

paper sluice
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

warm tulip
#
  async def ban(self, ctx, *, reason):
    await ban(*, reason=none)```
not working
uncut jacinth
#

await member.ban(reason="Blabla")

warm tulip
uncut jacinth
#

Ez

uncut jacinth
#

async def ban(self, ctx, member: discord.Member, *reason):

slate swan
#
@commands.command()
async def selfban(self, ctx):
  await ctx.author.ban(reason="fuck you")

welcome

paper sluice
slate swan
#

ctx.me.ban thi

#

lmao

#

i wanna try this now

paper sluice
#

there are no good hand emojis

slate swan
#

@paper sluice πŸ˜” wanna exchange eyes still?

heady sluice
#

what a fuckboy

slate swan
#

lmao

cloud dawn
#

πŸ˜‚

paper sluice
#

lol

heady sluice
#

the problem is he probably succeeded

slate swan
#

πŸ˜”

heady sluice
slate swan
#

hm

paper sluice
slate swan
#

sarth πŸ’€

heady sluice
slate swan
uncut jacinth
#
async def main():
    async with client:
        await load_extensions()
        await client.start(token)
asyncio.run(main())

Any body knows why this is removing erros.

heady sluice
#

it's not

uncut jacinth
#

It does

#

I did it with client.run and it didnt outputs errors anymore

heady sluice
#

what is inside load_extensions

uncut jacinth
#
async def load_extensions():
    for filename in os.listdir("./cogs"):
        if filename.endswith(".py"):
            await client.load_extension(f"cogs.{filename[:-3]}")
errant coral
#

!d object has no attribute 'name'

unkempt canyonBOT
#

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.
heady sluice
#

yeah that doesn't either

paper sluice
uncut jacinth
heady sluice
peak turtle
#

how to make a file list to array

paper sluice
peak turtle
#

uhhhh

heady sluice
errant coral
#

!d attribute

unkempt canyonBOT
#

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.

slate swan
#

bro !d is not a get help command, it mentions docs.

peak turtle
slate swan
#

someon helpme very important i cant start my bot it says rate limit exceeded plz

slate swan
#

keep waiting, thats all u do

#

how much

warm tulip
#

@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.')


heady sluice
#

is this in a cog

warm tulip
heady sluice
#

this is half cog half main py code

#

you forgot self

warm tulip
#
@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.')
```?
uncut jacinth
#

yes

warm tulip
#

okk thanks

uncut jacinth
#

Try

#

reason: str="None"

paper sluice
warm tulip
#

its not still working

errant coral
#

Anyone know how to fix this error?
object has no attribute 'name'

paper sluice
errant coral
warm tulip
#

its working now

#

bot is on

#

let me test it on server

errant coral
uncut jacinth
#

Ok, So try it with id

errant coral
#

already did it the same error but with id

uncut jacinth
#

async def on_voice_state_update(self, member, before, after):
if after.channel != None:
if after.channel.id == channelid:

warm tulip
#

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

uncut jacinth
#

Did yo got it like that?

uncut jacinth
#

Its not the code that is not working

errant coral
# uncut jacinth Did yo got it like that?
@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()```
warm tulip
#
@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

warm tulip
#

wym

slate swan
#

Did you load your cog?

warm tulip
slate swan
#

Did you load it?

uncut jacinth
errant coral
#

k i got a error with channel just

uncut jacinth
warm tulip
#

bot.load_extension("commands")

warm tulip
uncut jacinth
uncut jacinth
warm tulip
#

ye...

uncut jacinth
uncut jacinth
warm tulip
#

await bot.load_extension(commands)

uncut jacinth
#

You could just write the command in one file

errant coral
warm tulip
warm tulip
#

just

#

nvm why its not workiing

#

offf

uncut jacinth
#

Obviously it says that there is no command with that name

#

So it means that the command is not loaded

slate swan
sick birch
#

Replit is a pretty bad service so not sure what you were expecting

balmy bobcat
#
@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?

slate swan
loud junco
slate swan
loud junco
slate swan
#

I wont spend money on hosting

loud junco
#

im also using replit

loud junco
slate swan
#

dude I just told u i fixed the issue

#

Im using replit for 1 year

#

Jokes on u

loud junco
#

🀣

slate swan
#

? This is my first issue with it

loud junco
#

my man hacked a hacker plan

slate swan
slate swan
loud junco
#

lol

slate swan
#

Tell me a better one for free

#

U coconuthead

slate swan
loud junco
zealous jay
#

If you really need it I guess you can use heroku but its not that good

#

If you use it for free

slate swan
#

LMAO

#

Nah

#

They started this argument

zealous jay
#

If you host with heroku for free it goes offline for a few days at the end of the month

slate swan
#

DUDE U TOLD THAT REPLIT IS SHIT

#

Fucking dumbass

#

Report ur mom

zealous jay
#

Hey calm down

slate swan
#

Id so fucking punch you in the face

zinc reef
#

<@&831776746206265384> can we get someone here? πŸ™‚

zealous jay
slate swan
hollow badger
#

Hello

slate swan
#

nvm my wifi

zealous jay
#

Hey!

blissful lagoon
#

!mute 815897400211800105 πŸ”

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1655999149:f> (59 minutes and 59 seconds).

zealous jay
#

thanks :)

slate swan
#

seriously

hollow badger
#

😦

slate swan
#

etz wanted to do this mute fr

#

scofflaw bad bad

zealous jay
#

lol

slate swan
#

Hi again

#

hello

rare saddle
#

How to make a bot a speaker in the stage channel through code?

slate swan
#

!d discord.VoiceChannel

unkempt canyonBOT
#

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.
rare saddle
paper sluice
#

but u said speaker lemon_pika

swift pumice
#

how can i use a an api?

swift pumice
paper sluice
slate swan
#

to make the bot a listener

swift pumice
slate swan
swift pumice
slate swan
#
import aiohttp

async with aiohttp.ClientSession() as session:
     response = await session.get(url)
     content = await response.json()
paper sluice
#

^

shrewd apex
#

^

paper sluice
#

preferably use the cm session as well

slate swan
#

^

swift pumice
slate swan
#

Nice

rapid falcon
#

hi

slate swan
#

hello.

rapid falcon
#

does anyone know how to send a message with a bot once a specific user sends a specific message?

slate swan
#

!d discord.on_message

unkempt canyonBOT
#

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.
swift pumice
slate swan
#

cz its command

#

com mad

swift pumice
uncut jacinth
#
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

slate swan
#

igtg and it wont error

swift pumice
slate swan
swift pumice
slate swan
#

then @bot.command()

swift pumice
# slate swan 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
normal jackal
#

can someone help?

swift pumice
uncut jacinth
swift pumice
normal jackal
#

in terminal

rapid falcon
#

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

shrewd apex
swift pumice
#
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?
paper sluice
#

define not working

swift pumice
#

what?

paper sluice
#

we should add a rule to this channel, anyone who says "not working" should be banned /jk

swift pumice
#

what

paper sluice
#

what is not working here?

swift pumice
sick birch
paper sluice
swift pumice
paper sluice
#

ya it works fine

#

does it not send the url in chat?

swift pumice
#

yes

#

it doesnt do anything

paper sluice
#

did u restart the bot after adding that command?

swift pumice
#

cuz it isnt working for me idk

sick birch
#

Have you the proper intents?

#

Both in code and dashboard?

swift pumice
#

yes

normal jackal
paper sluice
# swift pumice yes

are u sure u have the command above bot.run or whatever ur using to start the bot

paper sluice
paper sluice
swift pumice
paper sluice
shrewd apex
#

^

rapid falcon
#

is the id a string or an integer?

grim oar
#

int

paper sluice
#

id will always return int, idk why you want to check that?

grim oar
rapid falcon
#

like if a certain message is sent, it will return a message

paper sluice
grim oar
#

bruh they are just asking what type is message.author.id

slate swan
#

so i have a variable in my command how can i use it in the buttons class?

grim oar
#

make the variable an instance or bot var

slate swan
#

how?

grim oar
#

bot.x = something

slate swan
#

mhm k

#

and then use {bot.x} in my class?

grim oar
#

yes

shrewd apex
#

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

grim oar
#

because maybe the function is in different namespace

shrewd apex
#

hmm a bit more detail would be nice

grim oar
#

ask there

slate swan
#

restart the editor

#

works for me

regal pulsar
rapid falcon
#

its not a tuple

grim oar
rapid falcon
#

i just wanted to ask if its int or str

slate swan
#

you have to use the in keyword to check if the id is in an iterable

if message.author.id in (id1, id2,):
  ...
rapid falcon
regal pulsar
#

Control shift p or something

#

Type python

grim oar
rapid falcon
regal pulsar
#

Select choose python version

slate swan
rapid falcon
#

yeah

slate swan
rapid falcon
#

some people thinking its a tuple lol

slate swan
#

smh

paper sluice
slate swan
regal pulsar
#

Oh wait

grim oar
#

πŸ’€

regal pulsar
#

My phone didnt show me the whole thing

paper sluice
regal pulsar
#

Small screen ;/

#

i just saw the (

rapid falcon
slate swan
paper sluice
grim oar
#

zeffo go away

regal pulsar
vocal snow
#

llmaoo

slate swan
#

yeah shoo

paper sluice
#

() = tuple
(something) = type of something
1, = tuple

slate swan
slate swan
slate swan
#

just like you

grim oar
#

what are you cooking

slate swan
vocal snow
normal jackal
sick birch
#

Venvs usually fix all these sorts of issues

paper sluice
uncut jacinth
#
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

slate swan
sick birch
slate swan
#

same question

sick birch
#

enclosing items functionally really doesn't do anything

paper sluice
vocal snow
paper sluice
sick birch
#

!e print((1) == 1)

unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

True
slate swan
sick birch
#

they're equivalent

sick birch
vocal snow
#

OH i understand what you are saying

slate swan
#

!e

x = (1)
print(type(x))

x = 1,
print(type(x))

tuples don't get created unless πŸ˜”

paper sluice
paper sluice
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | <class 'int'>
002 | <class 'tuple'>
slate swan
#

as you like

paper sluice
#

clean

slate swan
#

I just wanted to make it clear

#

Β―_(ツ)_/Β―

#

wut idk how many times did i do ```py
embed = hikari.Embed(...),

#

imagine

slate swan
uncut jacinth
#

So dankmemer has it above

slate swan
#

its in the first row, and the buttons are in the second row

uncut jacinth
#

How to do it in the first row

slate swan
#

!d discord.ui.Select

unkempt canyonBOT
#

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.
slate swan
#

"row" kwarg

paper sluice
#

and 0 for select

uncut jacinth
slate swan
#
@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 ^
uncut jacinth
#

Is the json empty?

slate swan
#

oh wait

#

mb, i just cleared it

paper sluice
slate swan
#

got this error here

#

i do have "channel" in my json file

paper sluice
#

ur looking for guild id not a channel

shrewd apex
#

i always wanted to ask is opening files sync?

#

if not what does aiofiles exist for?

uncut jacinth
#

How do i make pages with commands from cogs

cloud dawn
shrewd apex
#

ic

uncut jacinth
#

so like only 5 commands show in first page

cloud dawn
slate swan
#

^

shrewd apex
#

ic

#

but i still see many codes opening sync in the commands

slate swan
#

in simple words, it supports asynchronous opening and file methods

shrewd apex
#

ik ik i had a doubt since i saw sync opening in quite a few repos

slate swan
copper maple
#

ummm i need some help

slate swan
#

no

shrewd apex
#

hmm πŸ€” prolly the latter since those were some advanced repos

paper sluice
shrewd apex
#

ic

copper maple
#

im new to python, whats wrong with this

cloud dawn
#

Sync opening a file on startup etc is fine but if you are going to repeat that process it's best to use aiofile

shrewd apex
#

!indents

unkempt canyonBOT
#

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

slate swan
cloud dawn
shrewd apex
#

yeah they do

#
async with aiofiles.open()
#

kinda goes like that

cloud dawn
#

Yeah and a context manager, basically the best situation.

slate swan
paper sluice
#

my pet peeve with async programming is that it just looks ugly and is more lines of code

pliant gulch
#

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

slate swan
#

say's unknown message but it is there

copper maple
slate swan
slate swan
copper maple
shrewd apex
#

asyncio provides more support for concurrent.futures than for multiprocessing and threading from as far as i have used them

slate swan
pliant gulch
slate swan
shrewd apex
#

won't it be self.client if in a class

slate swan
# copper maple
$poetry add python-dotenv
``` ```py
# in code
from dotenv import load_dotenv
load_dotenv("token.env")
slate swan
slate swan
#

check your shell

paper sluice
copper maple
#

oh ok

#

so i dont need to import os?

shrewd apex
#

hmm yeah sarth why do u use poetry it's fine to generate using pip right?πŸ‘€

slate swan
#

poetry basically wraps pip lmao

shrewd apex
#

are there any big advantage using it?

paper sluice
copper maple
slate swan
#

i can specify the exact version of the library with python version relation

shrewd apex
slate swan
paper sluice
shrewd apex
#

more focused development i see

slate swan
#

if you ever used javascript you'll notice how cool is it to use poetry

#

cause npm functions somehow similar

shrewd apex
#

mhm

slate swan
paper sluice
#

im installing a fortran compiler for some reason pithink

pliant gulch
#

fortran lmao

shrewd apex
#

i will learn js for website designing soon ig

slate swan
#

no need to attach extra attributes

slate swan
shrewd apex
#

interaction.channel

slate swan
shrewd apex
#

for that

slate swan
#

If the user updates it will be different

shrewd apex
#

!d discord.Interaction.channel

unkempt canyonBOT
slate swan
slate swan
slate swan
shrewd apex
#

for message

#

!d discord.Interaction.message

unkempt canyonBOT
slate swan
# slate swan Yah

so just get the channel with that id and use fetch_message on that

slate swan
#

Directly use fetch_message?

copper maple
slate swan
#

its load_dotenv, not load_.env lmao

copper maple
#

oh....

#

u actually type dot....

slate swan
slate swan
#

!d discord.abc.Messageable.fetch_message

unkempt canyonBOT
#

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.
slate swan
#

mhm

#

Lemme test it

shrewd apex
#

nvm

#

πŸ™ˆ

slate swan
#

Channel can be a VoiceChannel or StageChannel too, so it doesn't have a fetch_message method

shrewd apex
#

ic

#

so is it under TextChannel tho?

slate swan
#

TextChannel is a subclass of Channel and Messageable iirc

slate swan
#

did you define channel as a command or something

#

!paste show code

unkempt canyonBOT
#

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.

copper maple
#

how do i make my code in replit active if the tab is closed?

slate swan
#

use a host if you wanna do that

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slate swan
#

replit for hosting is bad πŸ‘Ž

copper maple
copper maple
slate swan
worldly solstice
#

Heya is anybody in here that can help me understand something regarding graphql queries?

slate swan
#

Anyone?

shrewd apex
#

type kill 1

slate swan
#

Dear please tell me why it is not imported?

shrewd apex
#

in shell then restart

shrewd apex
#

also does it give a run time error

slate swan
stone palm
#

how do i check if the msg author is the bot itself in a cog?

shrewd apex
#

what is your directory structure

shrewd apex
stone palm
#

ah okay

#

ty

slate swan
stone palm
shrewd apex
shrewd apex
#

that* on message event/listner?

stone palm
shrewd apex
#

send it here

stone palm
#
        if message.author != bot.user:
shrewd apex
#

self.bot

#

it's in a class

slate swan
stone palm
shrewd apex
#

does it even exist?

slate swan
shrewd apex
#

there is nothing called clickhousesecret πŸ‘€

slate swan
shrewd apex
#

idk

#

there is only a clickhouse-driver

#

no secret

slate swan
shrewd apex
#

there is something missing in ur code then

slate swan
stone palm
slate swan
slate swan
#

it's
if message.author != self.bot.user

heady sluice
#

oh wait my logic failed

slate swan
#

...

quaint epoch
#

i thought my seizures were bad /s

slate swan
#

...

quaint epoch
#

/chat-revive

swift pumice
#

i just did that my bot will send random capybara pictures :D i love my bot xd

swift pumice
# paper sluice what is not working here?

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)

paper sluice
slate swan
#

autosave ew

swift pumice
paper sluice
swift pumice
slate swan
#

yeah there is

paper sluice
#

most editors save as soon as u edit anything, look for it in the settings

swift pumice
#

okay

slate swan
paper sluice
pliant gulch
#

I :w alot too

#

I get lazy sometimes and just super + shift + q to close my nvim

slate swan
#

What hell is :wq

pliant gulch
#

Save quit

#

Yes

paper sluice
# pliant gulch I :w alot too

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 )

pliant gulch
slate swan
paper sluice
#

i haven't actually ever properly configured vim

#

its sad

pliant gulch
pliant gulch
#

It's not up to date, but basically all I added was lspconfig

paper sluice
#

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

swift pumice
#

do you guys have any command ideas?

paper sluice
pliant gulch
#

You should probably update then

#

That's outdated

paper sluice
#

ouf, ok

pliant gulch
#

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

paper sluice
#

ya, it installs .4.3 with apt, hold on

slate swan
pliant gulch
#

apt kek

slate swan
paper sluice
pliant gulch
#

Neovim has a binary for windows

paper sluice
#

im messy

#

ya thats 0.7.0

pliant gulch
#

Window has always been bad for TUI stuff

paper sluice
#

ya getting the same error there

pliant gulch
#

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

paper sluice
#

hmm, lemme check

pliant gulch
#

Yes

#

There is no pain

#

Only speed and less strain on my wrist from mouse movement

slate plank
#

we can i use hidden messages in python 2?

slate swan
#

ahem

pliant gulch
#

I did my config in like 5 minutes

slate swan
#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

paper sluice
paper sluice
slate swan
#

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

heady sluice
#

it only works for people that are not you

stone palm
# slate swan Code pls
    @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 ![this](https://cdn.discordapp.com/emojis/470903994118832130.webp?size=128 "this")
slate swan
stone palm
paper sluice
#

@pliant gulch got it to work, thank you πŸ™

slate swan
stone palm
#

thanks

pliant gulch
#

converted another to nvim

#

😈

paper sluice
paper sluice
pliant gulch
eager bluff
#

how would i make it so that whois and usage would be on a seperate line than prefix?

paper sluice
slate swan
#

inline=False for the add_fields

eager bluff
#

second one right

slate swan
#

for the ones you dont want to appear together

paper sluice
#

^

eager bluff
#

like that?

slate swan
#

boolean is capital

#

false != False

#

this isnt rust😳