#Basic Pycord Help (Quick Questions Only)

1 messages · Page 12 of 1

full basin
#

You can

fervent cradle
#

my client doesnt want to

cyan quail
#

(client as in a literal person)

fervent cradle
#

ye

cyan quail
#

you could just regenerate the view and edit over the original one

fervent cradle
#

i got a weird idea

#

nvm wont work cuz i need to use while loop

cyan quail
#

please don't

fervent cradle
#

WAIT

#

i can put everything inside a while loop

cyan quail
#

...

#

sure why not

fervent cradle
#

just a dumb idea it still breaks anyways

#

i need help

cyan quail
#

well i already said

#

just generate a new instance of the view and edit over the first message

fervent cradle
#

how would that work

#

im confused

cyan quail
#

wdym

#

you already subclassed the view, no?

fervent cradle
#

generate new instance means the attributes reset right?

cyan quail
#

yeah

#

you could just add more checks to the callbacks

#

or add new arguments to the init to preload attributes

#

like py class V1(View): def __init__(self, test1=None, test2=None): super().__init__() self.test1 = test1 self.test2 = test2 so now you can optionally pass in the initial value for test1 and test2; if you don't, then they'll be None like before

fervent cradle
#

ohh

#

await self.stop() ?

#

like to stop inside the subclass

silver moat
#

it's not a coro

fervent cradle
#

wdym

#

idk what's a coro

rare ice
#

A coro is awaiting and calling a function

fervent cradle
#

ohh

#

so only self.wait() is a coro

#

ok i finally did it

#

thx @cyan quail

cyan quail
#

all good

fervent cradle
#

how do i make view.wait() persistent?

abstract frigate
#

How do i add a role?

fervent cradle
abstract frigate
fervent cradle
abstract frigate
tiny wagon
#

where should we define the SlashCommandGroup class in cogs?

tiny wagon
#

AttributeError: Option does not take min_value or max_value if not of type SlashCommandOptionType.integer or SlashCommandOptionType.number

#
async def lock_time(self, ctx, time: Option(int, 'Enter a time in Seconds', min_value=3, max_value=20, required=True)):```
#

why is it giving me error?
it worked fine when store was set to true while loading cogs
when i change to false, this error comes

fervent cradle
#

can someone tell me what are these sort of slash command options called so i can utilise it i nmy own code?

fervent cradle
#

yea got it

olive acorn
#

How do we make these commands?

prisma flicker
olive acorn
#
#I tried using this
@bot.user_command(guild_ids = [id], name = hello)
async def hello(ctx, message : discord.Message):
    await ctx.add_reaction("👋")
#

But it didn't work

#

I wanna know why does this error show up whenever I run my bot

What is this error

void fable
#

i have a line of code
super().__init__(150, 5, 5, 3, 'Dark', 'Light', 'Tank')
which returns an error

    raise TypeError(f"expected Item not {item.__class__!r}")
TypeError: expected Item not <class 'int'>

in my command but when i try it outside of my classes it works fine? my command is for a combat menu with buttons and i have my combat stats (hp, atk, etc) in a Combat view and my view in CombatView(discord.ui.View, Combat)

somber remnant
#

Okay so i think about it, it will probably work for me but what about my host ? I can't change the core file of my host :/

frank yew
#

If I delete the message with delete_original_message after a few minutes I am fine. But if I delete it after a few hours it doesn't work, could it be because it is no longer cached or something? I get the following error:

2022-08-19T07:24:21.910953+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/interactions.py", line 441, in delete_original_message
2022-08-19T07:24:21.910953+00:00 app[worker.1]:     await func
2022-08-19T07:24:21.910954+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.10/site-packages/discord/webhook/async_.py", line 213, in request
2022-08-19T07:24:21.910954+00:00 app[worker.1]:     raise HTTPException(response, data)
2022-08-19T07:24:21.910955+00:00 app[worker.1]: discord.errors.HTTPException: 401 Unauthorized (error code: 50027): Invalid Webhook Token
somber remnant
#

Nah my host Say that i can't :')

merry briar
#
import discord

class Test(discord.ui.Button):
    def __init__(self, custom_id):
        super().__init__(label  ="Test", custom_id=custom_id)

    async def callback(self, interaction: discord.Interaction):
        await interaction.response.send_message(interaction.custom_id)

How can I use such a button after restarting the bot?

errant craneBOT
#

Here's the persistent example.

fervent cradle
#
    poll = discord.Embed(title=title,description=f':thumbsup: {option1} \n\n:thumbsdown: {option2} ' , color=0x20B5E1)
        poll.timestamp = datetime.datetime.now()
        await ctx.respond(embed=poll)
        await poll.add_reaction('👍')
        await poll.add_reaction('👎')``` Why arent the reactions being added?
young bone
#

Error?

fervent cradle
#

Thats why i've came here xD

simple canopy
#

you should add them to message

fervent cradle
#

msg?

simple canopy
#

create a variable from your ctx.respond()

#

and use .add_reaction on it

fervent cradle
#

alr

fervent cradle
# simple canopy create a variable from your `ctx.respond()`
 poll = discord.Embed(title=title,description=f':thumbsup: {option1} \n\n:thumbsdown: {option2} ' , color=0x20B5E1)
        poll.timestamp = datetime.datetime.now()
        msg = await ctx.respond(embed=poll)
        await msg.add_reaction('👍')
        await msg.add_reaction('👎')``` No error? No reactions?
simple canopy
#

second

young bone
#

you need the original_message()

fervent cradle
simple canopy
#

you basically need to use msg.message, ctx.respond returns Interaction, not discord.Message

fervent cradle
#

Ah alright

proud cargo
#

how do i reply to a button press so only the person who clicked it can see it

fervent cradle
simple canopy
#

🤔

#

nothing, i suppose

#

may be im wrong, second

#

well, just msg.add_reaction should work

#

its kinda strange, but, well. It worked for me

#

🥴

cyan quail
#

it won't for the first response because, as you said, that returns an interaction

cyan quail
#

did you defer?

simple canopy
#

yes, i think that's the reason

cyan quail
#

yeah

#

because if you defer > respond then it becomes WebhookMessage

simple canopy
#

💀

#

how unintuitive

cyan quail
#

well it has to be that way GuraShrug

#

in early betas you couldn't even use respond twice like that

simple canopy
#

standing here i realize?

cyan quail
#

anyway if it's first response, you need to do await msg.original_message() to get the original message

simple canopy
#

dude was right tho, im stupid

fervent cradle
cyan quail
#

use that to get the original message object

#

like message = ...

fervent cradle
#

alr

#

Works now! Ty

naive remnant
#

How can I make a permissions error handler

cyan quail
fiery tiger
#

@cyan quail

#

I have a quick question that i don't understand in the events

cyan quail
#

go on

fiery tiger
#

on_member_remove this will be called when a member gets banned / kicked

cyan quail
#

well

fiery tiger
#

right?

cyan quail
#

whenever a member is removed from the guild

fiery tiger
#

yeh so it could be by ban / kick

cyan quail
#

they can also leave themself

fiery tiger
#

syncing with the audit log u can tell that

#

yes but using audit logs u can tell that

#

for example

cyan quail
#

i'm not sure if ban fires it because there's the separate on_member_ban event

fiery tiger
#
        async for i in member.guild.audit_logs(
            limit=1,
            after=datetime.datetime.now() - datetime.timedelta(minutes=1),
            action=discord.AuditLogAction.kick
        ):  

this will tell if a user gets kicked

#

YES that's why i was going to ask u why there's a on_member_ban

cyan quail
#

yeah, but you should sleep first

fiery tiger
#

wym sleep

cyan quail
#

asyncio.sleep

#

because audit log doesn't update instantly

fiery tiger
#

sleep what?

cyan quail
#

so you might miss the log entry

fiery tiger
#

I been always using this and it always worked 🤔

cyan quail
#

it might but there's a chance it'll miss it eventually

fiery tiger
#

how long should i sleep it for?

cyan quail
#

just a few seconds would be enough

#

nothing too long

fiery tiger
#

Yes. it's about antinuke so speed is surely the key for it haha

#

can't sleep for seconds

#

the bot will go thru some perms check and also checking if the user is whitelisted etc etc so that will slow it down a bit

cyan quail
#

fair enough

fiery tiger
#

thanks 👍

fiery tiger
simple canopy
#

you didn't install the package, or installed it to different python version/venv

#

run pip3 freeze in console

#

uh, how did you install pycord then

#

command prompt, cmd, shell

#

?tag install

obtuse juncoBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
    python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.

Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

simple canopy
#

yes

cyan quail
#

might have done pycord instead of py-cord

simple canopy
#

^

#

you installed wrong thing

#

use ```py
pip3 uninstall pycord
pip3 install py-cord

#

in cmd\

#

oui

#

je ne parle pas francais bien

#

yes

#

try now

wise willow
#

Sup! Is there any way to convert commands.FlagConverter to dict?

wise willow
cyan quail
#

field types?

#

oh i see

#

kinda

wise willow
#

Haha, I don't really know how to explain it. I need something like dataclasses.asdict()

cyan quail
#

can you give an example of what you're trying to achieve? might be easier to contextualise it

wise willow
#

Suppose we have a car flags:

class Car(commands.FlagConverter):
    name: str
    price: float
    color: str

# Assuming we initialized flags with message xd
car = Car('Test', 2500, 'Red')
data = await car.get_flags()
print(data)

It returns something like: {'name': Flag(...), 'price': Flag(...), 'color': Flag(...)}
And I am trying to find a way to convert it to: {'name': 'Test', 'price': 2500, 'color': 'Red'}

cyan quail
#

oh so you want to map it to the values they input

wise willow
#

I think so xd

#

If there is no way to do that, I think it would be a good feature to pycord.

cyan quail
#

gives various examples of its usage

wise willow
#

I've already checked that, I didn't find anything much, sadly...

cyan quail
#

how about

#

let's say you used data = await car.get_flags(), and data is {name: Flag}
you iterate through data and use car.getattr(name, None) so it defaults to None if it doesn't exist

#

oh i guess i gave wrong usage but

#

maybe like py mapping = {} for key in data: mapping[key] = getattr(car, key, None)which should result in py { "name": "Test", "price": 2500, "color": "Red" }

wise willow
#

Oh, that's a good idea! Didn't think about that, lemme try

#

It does work, but when it comes to discord.Member we get __str__() xd

cyan quail
#

ah that's its string representation... hmm idk

wise willow
#

This will work good with primitive types. I'll have to reinvent the wheel when working with discord.* types xd

cyan quail
#

well havefun

wise willow
cyan quail
#

well that's kinda the point of __str__()

#

maybe str(getattr(...))

wise willow
#

Sadly, Member.__str__() will return user nickname rather than id

cyan quail
#

could check the type beforehand and try to get another attr

#

ultimately you're just gonna have to do a ton of other processing for certain types

#

maybe not a ton but a bit more than others i guess

wise willow
#

I think the best option will be creating a new class that inherits from FlagConverter with new method to properly handle discord classes.

cyan quail
#

go for it

#

most relevant discord classes in this context will have the id attribute so it'll be fairly straight forward

wise willow
#

Yea, there are no options. Thank you for help ✌

cyan quail
#

allgood

warm kindle
#

Hello guys. How do I check the number of characters in a message?

ionic snow
#

For some reason I get some weird error saying I need to use _SpecialForm instead of str, pycord 2.1.0 I think is the version I'm using

signal stratus
#

How do i check if role is a bot role?

warm kindle
#

thanks

full basin
warm kindle
#

@full basin, how do i replace 10k with 10000 ?

signal stratus
full basin
#

Eh, yes iirc

signal stratus
#

Okay thx :D

full basin
warm kindle
full basin
#

Have you made an attempt?

#

I won't code it for you lmao

warm kindle
#

no

warm kindle
full basin
#

Then check some of the basic python functions and make an attempt 😉

warm kindle
#

I need to know what basic functions 😉

full basin
#

Google is your friend

#

#help-rules 2

signal stratus
ionic snow
#

I think it's exactly that

full basin
#

Uhh. Don't know, does it return a boolean?

signal stratus
ionic snow
#

You can use it like this I assume:

if is_bot_managed():
  #SOMETHING
#

NP 😛

signal stratus
#

Yea ik i'm only tired XD

ionic snow
fervent cradle
#

Hey, can i get of user has nitro or not has nitro?

fervent cradle
smoky forge
fervent cradle
smoky forge
#

no i am 100% sure you cant check if a user has nitro

fervent cradle
#

so i think that

smoky forge
#

you can only do so if the user meets a certain number of factors like if the user has a banner or animated avatar

#

but even then they may not have any of that and still have nitro

fervent cradle
#

mhmm okay

#
@slash_command(name='suggest', description='Suggest something for the bot')
    async def suggest(self, ctx, suggestion):
        f = open(“FelBotSuggestions.txt”, ‘w’)
        f.write(suggestion)``` Why isnt this working? Im getting errors
( was not closed
Expected expression, although the brackets are closed?
peak wing
#
  async def on_message(self, message):
    if message.author.id in self.afk:
      await message.reply(embed=discord.Embed(description=f'**Welcome back,** {message.author.mention} **We have removed your afk**', colour=0x303135))
      self.afk.remove(message.author.id)
      try:
        await message.author.edit(nick=message.author.name)
      except:
        pass

    elif message.author.id in self.afk:
      if message.author.mention in message:
        await message.send('test embed')``` i tried this bot the ``
    elif message.author.id in self.afk:`` line and under when someone is mentioned dose't work
proud pagoda
fervent cradle
lapis quarry
#

Just bumping this again if anyone has any suggestions.

#

I just ran into the same issue, this time with an option int. It doesn't enforce input to be an integer and reads it in as a string

#

This is my function header:


async def dtt(self, ctx, team: str, player: str, odds: int, game_num: Option(int, default = 1), free_bet: Option(bool, default = False), account = Option(int, default = 1)):
   # code
rugged iris
#

why cant i run the nomral commands and slash command together?

jarvis = commands.Bot(command_prefix="=", intents=intent, chunk_guilds_at_startup=False, help_command=None)```
intents are enabled also
#

i dont get any error or anything but when i try commands normaly with prefix it doesnt work but it does work applications wise

prisma flicker
rugged iris
#

intent = discord.Intents(members=True, guilds=True, message_content=True)

prisma flicker
#

and enabled in the dev portal?

rugged iris
prisma flicker
#

can you change it to this?

intent = discord.Intents.default()
intent.members=True
intent.guilds=True
intent.message_content=True```
rugged iris
#

ok a minute

coral kindle
#

why pycharm dont work for pycord

prisma flicker
prisma flicker
coral kindle
#

i installed py-cord

#

but it says

#

that

#

"not found pakage discord"

#

when i have import discord

#

i have to install discord?

prisma flicker
#

no, py-cord provides discord

fervent cradle
#

how do I make view.wait() timeout=None ?

#

cuz the view timeout is None but the view.wait() stops waiting after some time

proud cargo
#

Code:

import mysql.connector

Traceback:
ModuleNotFoundError: No module named 'mysql'

mysql-connector-python==8.0.12 is shown in pip list.

hearty mauve
#
@client.command()
async def meme(ctx):
  api = "https://meme-api.herokuapp.com/gimme"
  content = requests.get(api).content
  data = json.loads(content)

  #data = json.dumps(data, indent=4)
  #print(data)

  title = data["title"]
  link = data["postLink"]
  img = data["url"]
  likes = data["ups"]
  em = discord.Embed(description=f"[{title}]({link})", color=0x2F3136)
  em.set_image(url=img)
  em.set_footer(text=f"{likes}👍")
  await ctx.reply(embed=em)
#
import discord, json, os, random, asyncio, string, time, hostingserver
from discord.ext import commands, tasks
from datetime import datetime
from hostingserver import keep_alive
import requests
hearty mauve
lapis quarry
#

Appreciate the reply

cyan quail
lapis quarry
#

Ohhhh, dumb me

#

Thanks so much!

cyan quail
#

all good

hearty mauve
#

Ok

#

How do i uninstall agaij

cyan quail
#

pip uninstall i guess

fiery tiger
#

@cyan quail

#

Hey i got a quick question. currently on my phone

#

can i check if any role permission is being changed? if yes then how?

#

because if im not wrong permissions returns a list.

#

so something like

#

if before.permissions != after.permissions would this check if the before perms is not the same as the after perm?

cyan quail
fiery tiger
#

because the currently thing im doing is to check if 1 permission is being changed. if it is then set back

#

yes but permissions is a list

#

1 sec lemme get my laptop

cyan quail
#

well yeah

#

it'll compare the two lists

fiery tiger
#

its a pain without a mouse hahaaa

cyan quail
#

for channel permissions

fiery tiger
#

Thanks for reminding me because i totally forgot to do that

#

even tho it is in the antinuke models

#

forgot about the invite too. Will do it in a bit

#

back to role thingy

#

So this is the current way im doing it. Which is not the best way to do that's why i was asking u

warm kindle
fiery tiger
#

@cyan quail if not before.permissions and after.permissions:

cyan quail
#

just use ==

#

or iguess !=

fiery tiger
#

yeh forgot to change the code LOL

#

@cyan quail my internet is so bad that it wont even start the bot

#

currently at my grandma

#

that's not an atr error at all its just that is not loading the right way lol

cyan quail
#

maybe just relax until you're home lol

fiery tiger
#

nah we gotta get this done haha

#

a lot of work x)

fiery tiger
#

@cyan quail

#

nothing will get printed

#

ah nvm it works its just my internet bad

#

This works and it's a life saver lol

#

thanks nelo

#

How can i check-edit if a channel permission is being changed? I don't find it as a parameter for channel.edit

fervent cradle
#
@bot.slash_command(guild_ids=[x])
async def addroles(ctx):
    channel = bot.get_channel(channel_id)
    message = await channel.fetch_message(message_id)
    users = []
    for x in message.reactions:
        if x.emoji == "✅":
            users.append(x.me.id)
    for x in users:
        x.remove_roles(ctx.guild.get_role(x))
        x.add_roles(discord.utils.get(ctx.guild.get_role(x)))
    await ctx.respond(f"Successfully replaced roles for {len(users)} users")```
#

is this code wrong?

young bone
prisma flicker
fiery tiger
#

this wont work

#

not even print

rare ice
#

Then they aren’t different

fervent cradle
#

x.add_roles(discord.utils.get(ctx.guild.roles, id=x))

fiery tiger
#

I think i have some knowledge in order to change a channel permission x)

fervent cradle
#

for x in message.reactions: if x.emoji == "✅": users.append(x.author.id)

#

the error is here\

#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Reaction' object has no attribute 'author'

rare ice
#

How can I fix this error? It's when having a status loop/cycle that changes every 13-15 seconds.

  File "/home/container/main.py", line 105, in ch_pr
    await client.change_presence(activity=discord.Activity(type=activity_type, name=name))
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 1179, in change_presence
    await self.ws.change_presence(activity=activity, status=status_str)
  File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 667, in change_presence
    await self.send(sent)
  File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 627, in send
    await self.socket.send_str(data)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/client_ws.py", line 150, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 687, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 598, in _send_frame
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport```
fiery tiger
#

@rare ice I think you are wrong about u said when u replied to my message because i added a few print statements before - in - after loop and that works perfectly fine, i also tried making other changes like channel rename and stuff

#

so it must be coming from the check if before.overwrites != after.overwrites

fervent cradle
#

i dont understand what im doing werong

#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Message' object has no attribute 'reaction'

fiery tiger
fervent cradle
#

uh so how do i get reaction?

fiery tiger
#

I don't even know what you are trying to do honestly

fervent cradle
#

im trying to replace a role

#

for each user who has already reacted to a message

#

role x changed to role y

rare ice
#

you need to iterate through message.reactions first

#

to get reaction

fervent cradle
#

reaction = message.reactions[0]

#

this?

rare ice
#

?tag tryitandsee

obtuse juncoBOT
fiery tiger
#

But i can't figure out why the if statement won't work

fervent cradle
#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'remove_roles'

#

im so fucking confuse

fiery tiger
#

are u using ctx.remove_roles ?

#

@fervent cradle

meager mica
#

Is there example of sub commands I couldn't see it in GitHub like other forks

fervent cradle
#
@bot.slash_command(guild_ids=[x])
async def addroles(ctx):
    channel = bot.get_channel(channel_id)
    message = await channel.fetch_message(message_id)
    reaction = message.reactions[0]
    initial = discord.utils.get(ctx.guild.roles, id=x)
    updated = discord.utils.get(ctx.guild.roles, id=x)
    count = 0
    async for user in reaction.users():
        await user.remove_roles(initial)
        await user.add_roles(updated)
        count += 1
    await ctx.respond(f"Successfully replaced roles for {count} users")```
fervent cradle
#

its adding roles to the wrong people now

fiery tiger
#

I don't know man. its your code and you should know what it does, also i see that is a / command

fervent cradle
#

yes

fiery tiger
#

it's weird how u using ctx. I am using ctx: discord.ApplicationContext. What library are u using?

#

pycord?

fervent cradle
#

yes

fiery tiger
#

idk man

#

How can i check if a role is being added here to permissions?

#

i don't see any parameters for it in the docs

naive remnant
#

A code to get server's icon url

hearty mauve
#

Someone help

full basin
#

Kinda self explanatory

#

get is not defined

hearty mauve
#

Ik but how can i fix it

full basin
#

no idea what youre trying by get.content

hearty mauve
#

Idk either but i cant use requests

#

Because its a code blocker

full basin
#

if you dont know what your own code does, nor do i

#

you use aiohttp

#

google how to use it

hearty mauve
#

So aiohttp.get.content?

smoky forge
#

you use aiohttp as an async context manager

full basin
#

no

#

aiohttp is a library

#

google examples on how to use it

hearty mauve
smoky forge
#
# bad
r = requests.get('http://aws.random.cat/meow')
if r.status_code == 200:
    js = r.json()
    await channel.send(js['file'])

# good
async with aiohttp.ClientSession() as session:
    async with session.get('http://aws.random.cat/meow') as r:
        if r.status == 200:
            js = await r.json()
            await channel.send(js['file'])

#

just replace requests with this 👆

hearty mauve
#

Isnt there anything easier

fiery tiger
#

How can i check if a invite is being created to a certain channel?

hearty mauve
#

Audit log in server settings

smoky forge
hearty mauve
#

To make it shorter

smoky forge
#

you can define a bot session if you subclass your bot

#

that will just remove one nesting

fiery tiger
#

event?

cyan quail
#

yes

fiery tiger
#

wait

hearty mauve
#

Yes

fiery tiger
#

what

cyan quail
#

?

fiery tiger
#

isn't it on channel update? lol

cyan quail
#

no

#

it's a separate event

hearty mauve
#

Why would it be on that

fiery tiger
#

oh fuck alright

cyan quail
#

Invite has a channel attribute

fiery tiger
#

got it my bad bruh that's why it wasn't printing

#

also nelo

smoky forge
#

i have an http session defined in my bot

fiery tiger
#

How can i check if any role is being added to the channel perms roles

smoky forge
#

thats about how short you can get

cyan quail
#

that one would be on_channel_update

cyan quail
#

then check channel.permissions

fiery tiger
#

yes but what's the param for it

#

no

cyan quail
#

before, after?

#

just read the event reference

fiery tiger
#

nelo is none of those bruh listen 1 sec

cyan quail
#

it has literally everything you're looking for

#

ohok

fiery tiger
#

not really

#

here where u can add a role. I don't see this in the params for channel lol

#

that's why i been asking around

cyan quail
#

because it's under channel.permissions

#

Called whenever a guild channel is updated. e.g. changed name, topic, permissions.

fiery tiger
#

I know the event already bruh

cyan quail
#

Then what's the issue..?

fiery tiger
#

oh my god am i just bad at explaining?

#

wait .permissions

cyan quail
#

you can also use permissions_for(...) if you need to check a specific object

fiery tiger
#

i didn't see any parameters for channel perms

cyan quail
#

wdym

fiery tiger
#

alr give me ah sec

#

just gimmi 1 sec i may be high lol

cyan quail
#

i was probably wrong about .permissions, that's for other objects with simpler permissions

#

but you're definitely looking for permissions_for()

fiery tiger
#

yes because there's no atr for .permissions

#

like is not a channel param.

#

permissions for. lemme read it up

cyan quail
#

which is why im saying you should have just read further because permissions_for is also right there

fiery tiger
cyan quail
#

use channel.set_permissions

fiery tiger
#

👍

fervent cradle
#

how do you make a slash command response private?

#

like so only the author can read it

cyan quail
fervent cradle
#

in bot.slashcommand()?

cyan quail
#

no

#

when using respond

lyric root
#

is there a way to specify to discord that an ephemeral response is an error message so like it shows up red and stuff

frosty bramble
#

ye

lyric root
#

how

lyric root
#

ok cool

cyan quail
#

at least not yet anyway

lyric root
#

thank you discord very cool

#

also not salty about not being able to nest command groups

cyan quail
#

well you can have 1 nested level at least

#

like /group subgroup command

lyric root
#

huh didn't know that

#

well that takes some of the edge off at least

frosty bramble
#

so im trying to get the discord mobile icon status on a discord bot

#

but its not showing up on it?

silver moat
#

literally first google result

frosty bramble
celest lichen
#

hi, what are the actual objects stored in Guild.channels? i know it's a list, but is it of channel IDs or channel names?

celest lichen
#

ohhhh, okay

#

so like, what would the syntax be for looking at the channel ID for one be?

#

Guild.channel[3].id or something?

#

3 being a random index number

prisma flicker
#

What are you trying to do?

hushed ledge
#

One message removed from a suspended account.

night cargo
#

How would I convert :flag_bh: into an actual emoji using the api?

bleak cloud
#

is uploading files in slash commands supported?

dawn gyro
#

Does anyone have an idea on how I could get the custom emojis with the name butterfly and not the 🦋

round rivet
#

looks like the latter, there's a missing >

bleak cloud
gritty pond
#

How can i get invite link and link owner when member join?

gentle flare
#

Hi how do I get the guild id from on_member_join?

gentle flare
#

Ah thx.

ionic snow
warm kindle
ionic snow
coral kindle
#

I have problem with pycharm

cold storm
#

hey sorry im using pycord after a bit off, for somereason my slash commands arent registering

coral kindle
#

I have this

#

and this is the error

#

and i cant run my bot

cold storm
#
from discord.ext import commands
from discord.ext import tasks
#from discord.ui import Button
import requests
from requests.structures import CaseInsensitiveDict
import json
import asyncio
import os
#from pycord_btns_menus import *
from datetime import datetime
from flask import Flask, jsonify, request

#API SETUP





client = commands.Bot(command_prefix="y.")

debug_guild = "998532010257690634"
owner_id = "901372249012051988"



@client.slash_command(guild_ids=debug_guild)
async def hello(ctx):
    await ctx.respond("Hello!")

and then ofc token run, the bot runs and when i put an actiivty it displays it

coral kindle
#

Maybeee

#

hmm

#

try just client.command

cold storm
#

discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access and now this is throwing, but my token is correct and bot is running

#

i tried client cmd, same thing

loud holly
loud holly
smoky forge
loud holly
#

same with the owner_id

#

unless you cast it already in your code when you retrieve it, but best practice to leave it in int

loud holly
#

is there a faster way to mass remove role from users?
I use for loop and that's slow so I was wondering if there's another way and a better practice

true spoke
#

hey! in my project which pings me everytime a new product is , i use syncwebhook(url).send to send embeds in a discord channel. I'm trying to attach a button with the link of the product under each embed sent, so i tried to add a view element but as my code isn't in an async, i get "no running loop". Is there an equivalent of view() without it needing to have an "await"?

I'm trying to achieve something like

webhook = SyncWebhook.from_url(webhookurl)

embed=discord.Embed(title="blablah", color=0x78c5f2)

webhook.send(embed=embed, view=view)

that would attach the button defined in view under my embed

distant roost
#

how can isend an message in an on message event in a specific channel (not the channel where the message is from)

smoky forge
smoky forge
smoky forge
true spoke
loud holly
#

that's how it was before, I'll try to do what u said above 👍

mental maple
#

does hosting like from 2 device harm the bot?, i tried to use my main bot to debug my code about intents and i cant use any slashcommands that have been registered

harsh dust
#

I'm trying to remove a view from a message after 5 minutes but for some reason this doesn't work.

with save_image_data("image", rendered) as file:
    msg = await ctx.respond(file=file, view=view)

async def timer():
    await asyncio.sleep(60 * 5)
    try:
        await msg.edit(view=None)
    except:
        pass

task = self.bot.loop.create_task(timer())
await task

The view is still there after 5 minutes. With text commands this worked fine but now it's not working and I'm not sure why

tiny wagon
#

so um, i am using apscheduler for some work, it works fine when the jobs are stored in memory, but when i use sql/mongodb for storing jobs(for presistence), it gives this error:

uptime is a function with comands.command() decorater, if i remove the uptime block, error will move on to the next prefixed command, idk whats happening, i am lost

grizzled sentinel
#

ye

harsh dust
#

im not subclassing discord.ui.View, so would i just do something like this instead

view = discord.ui.View()
view.on_timeout = lambda: ...
#

nvm its async

#

but still

grizzled sentinel
#

view.on_timeout part is right, i have never used lambda so not sure about that

harsh dust
#

Ye u cant do async lambda's so it wont work anyway

frank thistle
#

Why is there no error stack raised whenever a cog fails to load?

#

One of my cogs is failing to load, and I've no idea why, no traceback in console, it tries loading and then just nothing happens and it doesnt load

young bone
frank thistle
#

Thanks

rare ice
#

@celest lichen Please don't cross post in your own thread and in here.

celest lichen
#

sorry - made the thread bc this felt too long. i'll delete the stuff here

spiral sail
#

Somebody tell me, is Bridge playing up ....again or is it just me.

#

Pycharm is giving me this error, plus Bridge commands aren't being loaded in cogs.

ionic snow
#
@bridge.bridge_command(name="Config", description="First Initialization setup", guild_ids=[0])
    async def _config(self, ctx: bridge.BridgeContext):
        # Private bot, channels are gathered from the first guild that pops up.
        channels = {int(channel.id): channel for channel in self.client.guilds[0].channels}
        if os.getenv("WAIT_CHANNEL") == "0":
            view = View()
            view.add_item(SelectManager(placeHolder="Choose a waiting channel", options=channels))
            view.add_item(SelectManager(placeHolder="Choose the Aaron Channel", options=channels))
            await ctx.reply(content="Activating first setup initialization\n"
                                    "Please follow the instructions bellow: ", view=view)

This is a command I have in a cog file ( the cog file is configured how the docs said it should be ) and it doesn't load, if anyone knows what to do let me know!

latent idol
#

Hello! I have a little issue perhaphs someone can help me, i think thaht i'm using the basic discord.py. This is my code:

@bot.command(name = "cat")
async def cat(ctx):
    user = (f'{ctx.author.display_name}')
    codi_usuari = usuari [0:5]
    channel = discord.utils.get(ctx.guild.channels, name= codi_usuari +"log")
    messages = await channel.channel.history(limit=100).flatten()
    print(messages) ```
And i get this error
```messages = await channel.channel.history(limit=100).flatten()
AttributeError: 'TextChannel' object has no attribute 'channel'```

What i need is to get all the messages from a specific channel that changes with the 5 first characters of the user. Does anyone know how to solve this?
ionic snow
#

So instead of typing channel.channel just type channel

latent idol
#

oh 🤦‍♀️ thanks!

solemn spire
#

how can I restart the bot automatically, like once a day?

ionic snow
#

there's a command I think it's bot.restart or smth

#

And then you can do a loop that activates one a day I guess

solemn spire
#

doesnt seem like it

#

only bot.start

ionic snow
#

bot.stop and then bot.start

#

When you do bot.stop and then afterwards bot.start it doesn't really close the program itself

#

I think

solemn spire
#

bot.stop isnt a thing

#

also how many messages will the bot cache

young bone
#

try stuff with the os module

ionic snow
solemn spire
#

oh well

ionic snow
#

Yeah the docs is the best tool

solemn spire
#

now will tasks work after the bot is turned off 🤔

young bone
#

you can kill the bot process with the os module and run it again

ionic snow
solemn spire
#

im gonna go with both

ionic snow
#

Whenever you do client.close I assume it'll continue where you did client.run

#

Here kind of

#

Yeah after you close the connection it'll continue from client.run, another thing you can do is when you close a connection it'll trigger the event when you close connection with discord

spiral sail
ionic snow
#

I think so

#

It worked for me but now if I try to register bridge commands it doesn't work

spiral sail
prisma flicker
#

I doubt the github build is broken

#

did you download py-cord-2.0.1.tar.gz? you just need to extract it first

ionic snow
#

I used pip

prisma flicker
#

yes I get that

ionic snow
#

pip install git+https://github.com/Pycord-Development/pycord

#

Not that link oops

signal stratus
#

How do i disable a /slash Command complete so that the command is not shown for anyone without administrator permissions?

ionic snow
#

No it's that

prisma flicker
prisma flicker
ionic snow
#

Did you test it?

prisma flicker
#

not recently

#

although master is considered "alpha" and could break at any time

#

if you're having issues you can pin to a specific commit

ionic snow
#

IDK when it worked man :/

prisma flicker
#

why not just use stable?

ionic snow
#

Same as the pypi page

prisma flicker
#

what?

ionic snow
#

The package on the pypi website is the same as the stable version

prisma flicker
#

yes

#

what's wrong with it?

ionic snow
#

It won't register bridge commands

prisma flicker
#

can you create a github issue with a minimal working example?

ionic snow
#

I tried here first to check if I'm the only one because then I would just spam a spammed issue

prisma flicker
#

well, first, can you make a new thread in #969574202413838426 and send your code

ionic snow
#

Yeah sure

spiral sail
#

@ionic snow Thanks! My bots fixed now, weird the GitHub version isn't working

ionic snow
#

NP

signal stratus
prisma flicker
#

it hides the command from anyone without that permission

ionic snow
#

@prisma flicker Posted

signal stratus
loud holly
#

is there a way other than integration, that it shows up the command on a certain channel?

ionic snow
spiral sail
ionic snow
#

Same as me xDDDD

celest lichen
#

what permission does a bot need to do permission checks on users running commands? does it need manage roles?

solemn spire
#

no permissions

coral kindle
#

my commands dont load

fiery tiger
#

uhm nothing gets printed

#

even tho the bot is ready

#

the extension also gets loaded

celest lichen
#

anyone got any idea why my emoji only function is acting like it's toggled to on in every channel? lol

#

it should be
getting called on every message,
performing an sql select for the channel id of the message sent,
then if the emoji only toggle is set to true,
run the check to see if the message contains any text,
and if it does delete it

#

but it appears to be skipping steps 2 and 3 lol

#

by the way i acknowledge this is probably an extremely slow-running implementation of this feature but i'm still quite new to python lol

real stirrup
#

how many ram would i need for a simple bot that will only be in 1 server

copper dew
real stirrup
#

thanks for the info!

rigid sable
#

How do I make it so the response to slash command is something only that user can see?

smoky forge
#

cuz its blocking otherwise

celest lichen
smoky forge
#

which one were you using

celest lichen
#

psycopg2

smoky forge
#

use asyncpg

celest lichen
#

is this important? lol idk much abt github i just see red and think bad

rigid sable
smoky forge
#

it should just be pip install asyncpg

celest lichen
#

thank you!

#

as far as usage is it mostly just putting await infront of my SQL commands?

smoky forge
#

yes

#

or you can use it as a context manager

#

like async with _ as _:

#

so it can automatically close the connection

#

or a cursor

proud pagoda
#

In https://github.com/Pycord-Development/pycord/blob/master/examples/views/persistent.py, it says:

It is recommended that the custom_id be sufficiently unique to

prevent conflicts with other buttons the bot sends.

Does this mean that the view may conflict with other instances of the same persistent view if I create the persistent view multiple times for multiple users? Do I have to create a seperate custom_id for the buttons for each user? Ping on reply please

muted pulsar
#

is there a reason to use bot by subclassing the client class compared to regular usage ?

proud pagoda
#

You can use it to override events

muted pulsar
#

what's the difference compared to bot.event decorator ?

proud pagoda
#

There's probably better reasons that I'm not aware of though

proud pagoda
prisma flicker
#

If you have multiple instances of the same view they can share the same id

proud pagoda
prisma flicker
#

I guess so

proud pagoda
#

Ok thanks

smoky forge
#

if you have a large scale bot its not gonna work with a single custom id

smoky forge
#

now that i think about it, it shouldn't have any issues

proud pagoda
#

Alright

#

Anyway, how large scale were you thinking?

smoky forge
#

actually no wait

#

let me send the example i thought of

proud pagoda
#

Alright

smoky forge
#

say you have a feature where you can create your own self role select menus, and each select menu has a "self_role" custom id, since there's gonna be different select menus for different roles, its not gonna be all the same

#

but then again the role can be passed in to a view/select subclass and there wouldn't be a need for that

proud pagoda
#

Since they'll actually be different views

smoky forge
#

ill have to test on my own to see if two different views can have the same id and if they can be added to persistent views

proud pagoda
#

Ok

muted pulsar
#

can i set footer on embed initialisation ?

smoky forge
muted pulsar
#

regrettable, thanks

young bone
#

How can I get the id of a slash command?

young bone
smoky forge
young bone
#

how can I get the command?

young bone
#

thx

young bone
smoky forge
#

don't think so? im not sure what happens if you update the parameters

#

you'll have to try out for yourself

muted pulsar
#

what's the best approach to slash commands that are supposed to send in chat, instead of being replies to the user ?
send two messages and delete the reply after a second ?

smoky forge
muted pulsar
#

and one more thing, suppose i have a db with several entries, each being id of a guild, inside of each are ids of channels with some sort of info inside it; if i want to ensure for messages to be send to correct channels, i would want to use discord.Client.get_channel(id-of-channel).send(content="message")

#

am i right ?

bronze vector
#

should be

smoky forge
#

?tag tias

obtuse juncoBOT
muted pulsar
timid frigate
#

Does Member.pending take the guild member verification level into account or just the member screening?

celest lichen
cyan quail
celest lichen
#

okay, for some reason my sql query is returning the isEmojiOnly column as a tuple ????

#

its type is boolean - i thought type conversion was automatic

#

how do i make it return the actual boolean value?

smoky forge
celest lichen
#

i seem to have fixed it by using if isemoji[0] but that feels like a kind of a bodge

#

does it always return a tuple, even if it's only selecting one value?

cyan quail
#

fetchone always returns a tuple

prisma flicker
#

Sql libs are going to return tuples

celest lichen
#

thank you, i mustve missed that when i was reading the docs

cyan quail
#

because it gets the entire row

celest lichen
#

or it wasnt mentioned

prisma flicker
#

And since it's a tuple with 1 element it's always truthy

celest lichen
#

so like

#

it gets the whole row but then filters it to just the column you selected

#

?

cyan quail
#

why don't you just

#

print the result

#

and see what happens

#

would be significantly easier to troubleshoot

celest lichen
#

i was doing that - i've solved the problem. just trying to understand how it works better so i can avoid it in future lol

cyan quail
#

it'd probably help to read the docs for whatever library you're using too

#

fetchone is similar across most i'd assume but it'll at least explain what's happening

celest lichen
#

ah yep, i see that now im looking over the docs again. i think my eyes just sort of glazed over it haha

copper dew
celest lichen
#

yeah, i'm swapping things over to asyncpg now that i have all my queries working

#

i was just worried abt the Tests Failing thing

copper dew
celest lichen
#

oh wow, asyncpg doesn't have a connection and a cursor, it's just all connection

#

that means im changing more than i thought i'd be lol

#

oh jesus, do i need to wrap almost my entire main.py in an async function?

smoky forge
#

idk i didnt make the code

amber shale
#

is it ok to put change presence in on_ready, it will update every 5 seconds

#

i have a while loop running

prisma flicker
#

don't update your presence every 5 seconds

#

you'll definitely hit rate limits

void fable
#
button.disabled = True
button.label = f"You must wait {self.combat.turn_skill - self.combat.turn} turns."
await interaction.response.edit_message(view = self)
button.disabled = False
button.label = f"Skill"
await interaction.response.edit_message(view = self)

can i do something like this without the double interaction

amber shale
tiny wagon
fervent cradle
#

i can't edit message with select menu. i've got this error
In components.0.components.0.options.0.emoji.name: Invalid emoji, but i see this emoji

how can i fix it?

dry echo
#

is there a way to use @ tasks with times so like 4pm and so on?

cyan quail
cyan quail
fervent cradle
#

emoji from server

cyan quail
#

yeah but exactly what was it

#

might have to be a different format

fervent cradle
#
Traceback (most recent call last):
  File "/Volumes/Danya disk/coding/Py-cord/HFD/venv/lib/python3.10/site-packages/discord/ui/view.py", line 375, in _scheduled_task
    await item.callback(interaction)
  File "/Volumes/Danya disk/coding/Py-cord/HFD/hfd/ui/SettingsMenu.py", line 30, in select_callback
    await interaction.response.edit_message(embed=embed.automod(interaction.user), view=AutoModMain(interaction.client))
  File "/Volumes/Danya disk/coding/Py-cord/HFD/venv/lib/python3.10/site-packages/discord/interactions.py", line 840, in edit_message
    await self._locked_response(
  File "/Volumes/Danya disk/coding/Py-cord/HFD/venv/lib/python3.10/site-packages/discord/interactions.py", line 959, in _locked_response
    await coro
  File "/Volumes/Danya disk/coding/Py-cord/HFD/venv/lib/python3.10/site-packages/discord/webhook/async_.py", line 213, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options.0.emoji.name: Invalid emoji

full error + emoji

cyan quail
#

im asking what did YOU input into the select menu code for the emoji

#

you likely need at least name:id or <name:id>

fervent cradle
#

:AutoMod:

cyan quail
#

that's your issue

fervent cradle
cyan quail
#

but is that in your code

#

doesn't look like it since it says id=None

fervent cradle
#

there isn't bot on this server

muted pulsar
#

can i implement checks at the context menu command level so that it doesn't execute the function if the check fails ?

#

checking it with this and the command still works

#

no exceptions, no nothing

coral kindle
#

???

cyan quail
cyan quail
muted pulsar
cyan quail
cyan quail
muted pulsar
#

ty

cyan quail
#

so you can pass in as many as you want

coral kindle
#

pycord or py-cord

cyan quail
#

py-cord if you're using pip

coral kindle
cyan quail
#

are you sure your bot is running on the correct python installation

coral kindle
#

yup

cyan quail
#

show the full error from your first screenshot

coral kindle
simple canopy
#

do you have dpy installed by any chance

coral kindle
simple canopy
#

yes

coral kindle
#

yes

simple canopy
#

?tag install

obtuse juncoBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
    python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.

Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

cyan quail
coral kindle
#

ok

#

thx

#

it works now

#

i have another problem

#

my command's don't load

simple canopy
#

and also, discord.Bot doesn't have prefixed commands

coral kindle
#

i don't have any error's, but i can use any of

simple canopy
#

?tag client

obtuse juncoBOT
#
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
coral kindle
#

command's don't load

#

@simple canopy

simple canopy
#

because you are using wrong bot class

coral kindle
#

but im not using prefix commands

simple canopy
#

why would you specify command_prefix then

#

😔

coral kindle
#

idk

#

xd

#

Srry for polish word's

simple canopy
#

make sure you have applications.commands scope enabled

coral kindle
#

ok

cyan quail
#

this is still changing but global slash commands can take a while to load (it's meant to be instant now but this doesn't seem to be consistent)

simple canopy
cyan quail
#

i suppose i meant "consistent across applications"

simple canopy
#

fair

coral kindle
#

still not working

#

@simple canopy

simple canopy
#

try waiting a bit
also, you can specify guild_ids=[] for command, so it will be instant for your testing guild

coral kindle
#

['123']

#

or without ''

simple canopy
#

without

coral kindle
#

still not working

#

bruuh

muted pulsar
#

I'm trying to create a decorator that checks if the message upon which the context menu is being executed belongs to the bot, but i can't find the way to get the message object from the context. am i missing something ?

coral kindle
#

@simple canopy

simple canopy
coral kindle
#

xd

#

are you from poland?

#
import discord

bot = discord.Bot()

@bot.event
async def on_connect():
    print(f' ')
    print(f'Zaladowano discorda (Connected)')
    print(f' ')

@bot.event
async def on_ready():
    print(f' ')
    print(f'Jestem gotowy do uzycia!')
    print(f' ')
    await bot.get_channel(996907722949804133).send(embed=discord.Embed(title='Success',
                                                                        description='Poprawnie zaladowano discorda!',
                                                                        color=0x55FF55))

@bot.slash_command(name='botinfo', description='Informacje o bocie!', guild_ids=[965780715985838101])
async def botinfo(ctx):
        await ctx.respond(embed=discord.Embed(title=f'AlienBot - Informacje', description=f'**Status:**\n\n> ・Py-Cord - *pycordversion*\n> ・UpTime - *uptime*\n> ・Ping - *ping*\n\n   **Statystyki:**\n\n> ・Serwery - *{len(self.bot.guilds)}*\n> ・Użytkownicy - *{len(self.bot.users)}*\n> ・Owner - *Aruuvi#9667*\n> ・Komendy: *{len(self.bot.commads)}*'))


@bot.slash_command()
async def test(ctx):
    await ctx.respond(content=f'test command')


bot.run('token')```
simple canopy
#

no, i'm from Ukraine

coral kindle
#

Oh, ok

#

idk how tto make ping and uptime

#

xd

#

@simple canopy

simple canopy
#

yes, i'm here, you can stop pinging every 2 seconds

coral kindle
#

ok, sorry xd

simple canopy
#

i'm not sure

loud holly
#

can you send in the scope thing in the dev portal pls of the ones you selected

#

wait

simple canopy
#

are you sure bot have access to channel you are running commands in?
also, be sure to, also, add bot scope

loud holly
#

do u need intents?

coral kindle
#

i added bot scope

#

and administrator permissions

#

so

#

idk

simple canopy
#

try adding intents=discord.Intents.default()

coral kindle
#

ok

simple canopy
#

and intents=intents in bot instance

loud holly
#

you need both of these btw

coral kindle
#

ok

coral kindle
#

buttt

simple canopy
#

💀

coral kindle
#

this, yea?

simple canopy
#

yes

loud holly
#

Hmmmmm

coral kindle
#

still not working...

loud holly
#

invite url problem maybe?

coral kindle
#

Nah

simple canopy
#

try restarting discord

#

¯_(ツ)_/¯

#

may be you just don't see / commands, but they are here

coral kindle
#

no

#

i have other bot's

loud holly
#

re-add your token

coral kindle
#

i did before

#

ok, i restarted discord

simple canopy
#

does your bot send the embed that is in on_ready

coral kindle
#

yes

simple canopy
coral kindle
loud holly
#

wait

#

commands.Bot

simple canopy
#

commands.Bot is for prefixed commands

loud holly
#

idk if that makes a difference

simple canopy
#

it doesn't

loud holly
bronze vector
#

{len(self.bot.guilds)}
you're not in class

dry echo
bronze vector
#

you don't have self

simple canopy
coral kindle
#

what

simple canopy
#

you can't use self. outside class

coral kindle
#

so

#

i just need to delete self.

#

??

simple canopy
#

this one should've been registered then, actually PeepoThink

simple canopy
coral kindle
#

still

simple canopy
#

idk then
may be i'm blind and don't see anything

#

i'll go and buy some food smh

dry echo
coral kindle
#

??

#

i updated? its 2.0.1

dry echo
#

ooh sorry youre right

#

does your bot invite has the application.commands scope?

coral kindle
#

yes

bronze vector
#

so I copied your code and everything worked when I changed bot = discord.Bot() to bot = commands.Bot()

#

try to do the same

coral kindle
#

ok

dry echo
#

discord.ext.commands.Bot

bronze vector
#

from discord.ext import commands

bronze vector
coral kindle
dry echo
coral kindle
bronze vector
#

yea

coral kindle
#

ok

#

i changed something

#

and it works now

#

but commands still dont load

#

i deleted discord.commands

#

and just commands.Bot

dry echo
#

did you scoll through all commands?

coral kindle
#

scoll?

dry echo
#

in discord

coral kindle
#

yes

dry echo
#

i see you have alot of them

cyan quail
#

and you can make it a list for multiple times

coral kindle
#

Nelo please help me

cyan quail
coral kindle
#
import discord
from discord.ext import commands

intents=discord.Intents.default()

bot = commands.Bot(intents=intents)

@bot.event
async def on_connect():
    print(f' ')
    print(f'Zaladowano discorda (Connected)')
    print(f' ')

@bot.event
async def on_ready():
    print(f' ')
    print(f'Jestem gotowy do uzycia!')
    print(f' ')
    await bot.get_channel(996907722949804133).send(embed=discord.Embed(title='Success',
                                                                        description='Poprawnie zaladowano discorda!',
                                                                        color=0x55FF55))

@bot.slash_command(name='botinfo', description='Informacje o bocie!', guild_ids=[965780715985838101])
async def botinfo(ctx):
        await ctx.respond(embed=discord.Embed(title=f'AlienBot - Informacje', description=f'**Status:**\n\n> ・Py-Cord - *pycordversion*\n> ・UpTime - *uptime*\n> ・Ping - *ping*\n\n   **Statystyki:**\n\n> ・Serwery - *{len(bot.guilds)}*\n> ・Użytkownicy - *{len(bot.users)}*\n> ・Owner - *Aruuvi#9667*\n> ・Komendy: *{len(bot.commands)}*'))


@bot.slash_command()
async def test(ctx):
    await ctx.respond(content=f'test command')


bot.run('token')```
cyan quail
#

....

#

don't override on_connect

coral kindle
#

so i should delete on_connect

cyan quail
#

yes

coral kindle
#

yay it works now

#

and i have another question

#

how can i set ping and uptime

dry echo
#

define datetime at on_ready() and then subtract it from datetime.now

dry echo
cyan quail
#

defaults to utc, but it supports timezone

#

...timezone MIGHT be broken though

#

last i checked was a few months ago, if it is i may give a go at fixing it

loud holly
cyan quail
#

i recall it used to raise an error for tzinfo, but i'd personally just stick to using utc anyway

fervent cradle
#

hey does anyone know how to add that like little checkmark on the selection menus for the selected option? is it an emoji or something else

fervent cradle
#

thanks

fervent cradle
#

and if u want it just for 1 option can u just set it to max 1 min 1?

proud pagoda
fervent cradle
#

well then how can u get the checkmarks there with only being able to select 1 option

#

min value = 0 and max = 1?

proud pagoda
rare ice
#

How can I fix this error? It's when having a status loop/cycle that changes every 13-15 seconds.

  File "/home/container/main.py", line 105, in ch_pr
    await client.change_presence(activity=discord.Activity(type=activity_type, name=name))
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 1179, in change_presence
    await self.ws.change_presence(activity=activity, status=status_str)
  File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 667, in change_presence
    await self.send(sent)
  File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 627, in send
    await self.socket.send_str(data)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/client_ws.py", line 150, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 687, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "/home/container/.local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 598, in _send_frame
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport```
muted pulsar
#

what would generally be the best approach to handling has_permission check ? simply adding the decorator raises the exception, i'm not sure what's the best method to add a (.respond) would be

#

subclassing and replacing the error ? not quite sure how to use try/except around decorator next to command definition

muted pulsar
coral kindle
#

How can i add fields to embed

#

.add_field(name='test', value='test') ??

young bone
#

yes

#

you need name and value

young bone
round rivet
#

oh that's an old message

#

damn it discord

fiery tiger
#

How can i edit the guild community to true/false. Community its inside the guild features

fervent cradle
#

anyone knows how to add a created_at as timestamp to embed? its not working for some reason i did ctx.message.created_at

#

Hey guys, on_guild_join doesn't work at all for me at all

#

do I need any intents for that

full basin
#

You need members intents for that iirc

smoky forge
fiery tiger
cyan quail
#

go on

fiery tiger
#

there's no mention about rules_channel, public_updates_channel in the docs

#

is it possible to set them as default?

cyan quail
#

they're right there

#

in edit

fiery tiger
#

No but like

cyan quail
#

on the ui you have to specify them

fiery tiger
cyan quail
#

so you have to do the same on the api

fiery tiger
#

it won't let me enable community if i don't mention those channels lol

smoky forge
#

so do just that

cyan quail
#

it literally says

community (bool) – Whether the guild should be a Community guild. If set to True, both rules_channel and public_updates_channel parameters are required.