#Basic Pycord Help

1 messages · Page 14 of 1

shell radish
#

how are you hosting your bot

coral lake
#

Just running straight from VSC

shell radish
#

does the bot just not run

#

or does it "break" after some time

coral lake
# shell radish does the bot just not run

So, the bot starts up, as it prints "Logged in as testoor#2791 (ID: 1090496264912773185)
------"
But when I kill the program, it throws the RuntimeError.

Correction the bot does come online

shell radish
#

ok, so that's supposed to happen?

#

you crashed your own bot

coral lake
#

And I have NO CLUE why

#

So, here's another way I tried to break it down:

EXTENTIONS = ["cogs.wallet_verify"]

intents = discord.Intents.all()
bot = discord.Bot(intents = intents)


for extension in EXTENTIONS:
    bot.load_extension(extension) 
    pass

print(bot.extensions)

@bot.event
async def on_ready():
    print("Bot is ready")

#Restart Bot
@bot.slash_command()
async def restart(ctx):
    print("hello_dally")

bot.run(TOKEN) #Cherub```
#

When I nuke, it prints "Cogs Loaded"

#

and throws RuntimeError

shell radish
#
EXTENTIONS = ["cogs.wallet_verify"]

class PersistentViewBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.all()
        super().__init__(command_prefix=commands.when_mentioned_or("!"), intents=intents)
        self.persistent_views_added = False

-       for extension in EXTENTIONS:
-           bot.load_extension(extension) 
-       print(bot.extensions)

    async def on_ready(self):
        if not self.persistent_views_added:
            #self.add_view(Create_Team())
            self.persistent_views_added = True

bot = PersistentViewBot()

+ for extension in EXTENTIONS:
+   bot.load_extension(extension) 
+ print(bot.extensions)

perhaps

#

oh

#

I also don't see why you would use if __name__ == "__main__":

#

if you are just going to ignore it

coral lake
#

I can just take that out

coral lake
#

I can't comprehend how it's able to run the bot without hitting the print statement, even. Much less why it DOES drop it when I stop the program

coral lake
#

Problem solved...I had bot.run in my module program deadinside

shell radish
#

nested bot running 💀

coral lake
#

.tag slashnoshow

sly karmaBOT
#

Application Commands Not Showing Up?

  • Uninstall libraries that conflict with the discord namespace (e.g. discord.py).
  • Invite your bot with the application.commands scope.
  • Load cogs before bot.run() (e.g. not in on_ready).
  • Do not override on_connect.
  • Update to the newest version of py-cord (see ?tag install).
  • Turn off User Settings > Accessibility > Chat Input > Use legacy chat input.
  • Share your code and errors.
solid turtle
#

AttributeError: 'NoneType' object has no attribute 'send'
i am legit sick and tired of getting this error over and over again
i keep getting this error when trying to send a message in a specific channel

BOTLOG_CHANNEL_ID = 1234567890
botLog = client.get_channel(BOTLOG_CHANNEL_ID)
await botLog.send("hi")

i tried using fetch_channel(id) instead of get_channel(id) but i got hit with this error instead:
TypeError: can't send non-None value to a just-started coroutine
i searched the internet, couldn't find anything

#

anyone knows how to fix this?

#

it was working in another bot, idk why its not working here

subtle moth
#

botLog = await fetch_channel(id)

solid turtle
#

oh

#

lemme try

limber wagonBOT
#

Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.

Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.

What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.

solid turtle
#

ty

solid turtle
#

so like:

botLog = client.get_channel(ID)
async def test(ctx):
  botLog = await client.fetch_channel(ID)
  await botLog.send("hi")
solid turtle
#

correct me if i'm wrong lol

subtle moth
#

if the entire thing is within an async function you don't need to create a new one,

botLog = client.get_channel(ID)
if botLog is None:
    botLog = await client.fetch_channel(ID)
await botLog.send("balls")
#

@solid turtle

solid turtle
#

nah the get_channel() line is out of the async function

#

anyways thanks jiggly balls

little cobalt
#
channel = client.get_channel(123)
match channel:
  case None:
    channel = await client.fetch_channel(123)

;3

red mist
#

I thought this was an insult LOL

solid turtle
little cobalt
#

async def test(ctx: discord.ApplicationContext):
  await \
  ctx.respond \
  ("text")
#

you can do so much weird stuff with python xd

red mist
#

(I am trying to find my uselss Hello World program I once wrote)

solid turtle
#

damn

#

why is this a thing

#

in what scenario would this even be helpful

#

.

little cobalt
red mist
little cobalt
#

^

solid turtle
#

ooh

#

so it counts as one line if they are joined by \ ?

little cobalt
#

yes

red mist
# red mist when your lines are too long

print("Imagine writing a super long extended message that wont fit on your screen because this is getting ridiculously long just wait lol xd UwU OwO the mommy is the queen the daddy went to get milk and I am crying in my corner of shame because I am the voxy and idk what to do with my life, see how long it gets now do you?")

red mist
#

See

solid turtle
#

are you alright?

red mist
#

Yes

#

Demonstration :)

solid turtle
#

can they also be used to join strings as well

red mist
#

Well you could just add string but yes

#

essentially it does work

solid turtle
#
print("a sentence \
more words \
more more words \
end"
#

:OOOO

little cobalt
#
print("Hello World"); print("Hello World 2")
#

that would also work

solid turtle
#

yea that's pretty useless

#

would only be useful if youre trying to save lines or something

little cobalt
#

and no its not at one line at the terminal

red mist
#

thats 2 lines?

#

damn ok

solid turtle
#

damn

#

i should learn more python

red mist
#

same

solid turtle
#

been learning python for 3+ years but didn't know this shi existed

little cobalt
#

the match case stuff it kinda new to python

red mist
#

I didnt know the ; existed lol

little cobalt
#

it got added at 3.10

solid turtle
#

hasnt the 3.12 released already

little cobalt
#

ye

#

dont use it

red mist
#

Wait until the libs update lul

solid turtle
#

i heard we can use the same string terminators in f strings

little cobalt
#

I use 3.11

red mist
#

same

#

3.11.3 ?

solid turtle
little cobalt
#

3.11 ;3

#

3.11.0

red mist
little cobalt
#

so just 3.11

red mist
#

3.11.3

#

.3

#

0.0.3 versions ahead of you

solid turtle
#

:O

#

its 3 am i need sleep

#

havent slept in 2 days + school in 5 hours

#

😴

red mist
#

good night

#

also

#

I just wrote a new one ig

solid turtle
#

yea no im not sleeping

red mist
#
import time, random

def main():
    hello_world_list = ["H", "e", "l", "l", "o", ",", " ", "w", "o", "r", "l", "d", "!"]
    hello_world_string = ""
    for char in hello_world_list:
        ascii_code = ord(char)
        binary_code = bin(ascii_code)
        hex_code = hex(int(binary_code, 2))
        new_char = chr(int(hex_code, 16))
        hello_world_string += new_char
        time.sleep(random.uniform(0.1, 1))
    print(hello_world_string)

if __name__ == "__main__":
    main()
red mist
#

ok wait lemme eval it for you

#

there u go big man

solid turtle
#

wgat

red mist
#

now sleep

solid turtle
#

what is the point

red mist
#

there is no point

#

its useless

solid turtle
#

cudnt you just print "heelo world!"

red mist
#

I could

#

but

#

why do it that easy

#

if it can be done complicated

solid turtle
#

easy promotion

solid turtle
#

submit

#

tmr

#

havent done shit yet

red mist
#

start working.

#

5 hours.

solid turtle
#
  • its not even related to computer science
red mist
#

now

#

go

#

fucking go

solid turtle
#

OK

little cobalt
#

you can just run python --version

red mist
little cobalt
red mist
#

I want

#

I swear to god

#

I want

shell radish
# red mist ```py import time, random def main(): hello_world_list = ["H", "e", "l", "l...

should've done

import time, random

def main():
    hello_world_list = ["H", "e", "l", "l", "o", ",", " ", "w", "o", "r", "l", "d", "!"]
    hello_world_string = ""
-   for char in hello_world_list:
-       ascii_code = ord(char)
+   for index in range(len(hello_world_list):
+       ascii_code = ord(hello_world_list[index])
        binary_code = bin(ascii_code)
        hex_code = hex(int(binary_code, 2))
        new_char = chr(int(hex_code, 16))
        hello_world_string += new_char
        time.sleep(random.uniform(0.1, 1))
    print(hello_world_string)

if __name__ == "__main__":
    main()
red mist
#

Please I beg you include py in that cuz I cannot read it on phone

shell radish
red mist
#

Ohhh now I see

#

Thank you

round girder
#

having issues with the paginator raising 403 being unable to edit itself. none of my other commands that perform edits get these errors. any known issues? please @ me, this is quite frustrating.

glad spoke
grizzled loom
# round girder having issues with the paginator raising 403 being unable to edit itself. none o...

there is tons of possible reasons. simplest ones is when your bot sends a paginator message, user looks at it, is done looking, delets the message, then your bot tries to edit.
shortage of permissions is also a possible reson. settings for the room can mess it up.

but in general; @glad spoke 's advice is best: share the code in question and the error message you get and people will try to help.

shadow violet
#

Is it possible to add .webm image to an embed or is it treated the same way as videos (so not allowed)?
I'm trying to figure out why they're not being displayed despite correct url

round girder
lofty hedge
#

can you do alias for slash commands

shell radish
lofty hedge
#

shame

heavy sapphire
#

hey !
with this py str(bot.fetch_user(sentances[sentance][sentance_]["author"]))
that print
<coroutine object Client.fetch_user at 0x000001C892352A40>
why ? and how can i have name please?

subtle moth
#
user = await bot.fetch_user(...)
print(user)
heavy sapphire
devout mirage
#

erm does py-cord-dev change the import name for discord

little cobalt
#

Do you have something else installed?

devout mirage
#
vacefron.py==2.0.3
aiofiles==23.1.0
randseal==3.3.1
roleplaycog==1.0.2
py-cord-dev==2.5.0rc5
jishaku==2.5.1
advlink==0.1.0
typing-extensions==4.5.0
Pillow==9.4.0
PyNaCl==1.5.0
aiodns==3.0.0
brotlipy==0.7.0
youtube-dl==2021.12.17
Babel==2.11.0
shell radish
#

it is likely that something went awry when installing

devout mirage
#

acting up more now

#

runs fine, vscode doesnt like the dev release ig

fallow crescent
#

Hey friends. Just confirming something I asked before - how often may my bot DM a user that initiated a DM?
Am worried about the bot getting flagged as spam by Discord.

lofty parcel
#

I don't think you'll get flagged unless you massively send dms to multiple people.

fallow crescent
#

I was hoping to rely on the fact that since the user first DM'd the bot and not the other way around it wouldn't be flagged at all.
Is there a definition somewhere for what counts as "massively send"ing DMs?

lofty parcel
#

You could email discord support and get a better answer.

fallow crescent
#

Oh, I didn't know you can mail them about such things. What a lovely idea, thank you.

hybrid fossil
#

Hi there!
I need the global_name of discord.Member.
So I have to use the Master branch. Obviously an update has been made because I have an error.

#
  File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 763, in run
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 742, in runner
    await self.start(*args, **kwargs)
  File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 706, in start
    await self.connect(reconnect=reconnect)
  File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 600, in connect
    await self.ws.poll_event()
  File "/home/container/.local/lib/python3.11/site-packages/discord/gateway.py", line 604, in poll_event
    await self.received_message(msg.data)
  File "/home/container/.local/lib/python3.11/site-packages/discord/gateway.py", line 554, in received_message
    func(data)
  File "/home/container/.local/lib/python3.11/site-packages/discord/state.py", line 733, in parse_message_reaction_add
    raw = RawReactionActionEvent(data, emoji, "REACTION_ADD")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/raw_models.py", line 259, in __init__
    self.type: ReactionType = try_enum(data.get("type", 0))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: try_enum() missing 1 required positional argument: 'val'
floral ice
#

when my command takes longer to execute it times out

lofty parcel
lofty parcel
#

Read the last sentence.

floral ice
#

how do i defer it?

lofty parcel
#

If you're in a slash command, await ctx.defer()

floral ice
#

nvm found it

#

ty

fallow crescent
# lofty parcel You could email discord support and get a better answer.

Hey, just thought I'd follow up on this. Their support said they cannot comment on what exactly are their limitations, but that you should be fine if you follow this: https://discord.com/developers/docs/policy#don’t-do-anything-illegal-harmful-or-otherwise-not-cool

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

lofty parcel
#

I'm surprised by their fast response lol.

fallow crescent
#

Same!

solar arrow
#

I got an error:
'''
Traceback (most recent call last):
File "/home/[username redacted]/searchcord/test.py", line 6, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
'''

fallow crescent
#

isn't Bot specifically in discord.ext.commands?

#

discord.ext.commands.Bot()

hybrid fossil
little cobalt
limber wagonBOT
#

dynoError No tag clients found.

little cobalt
#

?tag client

limber wagonBOT
#
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
lofty parcel
solar arrow
#

I decided to just use "%" commands

#

also I fixed it

fallow crescent
#

Are there any rate limit guarantees by py-cord? Or should I do some rate limiting in my own code?

hybrid fossil
hybrid fossil
little cobalt
#

Dont use requests

lapis dock
lapis dock
#

#library-updates message

hybrid fossil
lapis dock
#

I am fairly confident

fallow crescent
hybrid fossil
edgy glen
#

How many embeds could i sent in one message?

lofty parcel
little cobalt
#

Can you show the pip list?

edgy glen
little cobalt
#

the loads is weird

edgy glen
#

Yeah

little cobalt
#

uninstall py-cord and install py-cord-dev

edgy glen
#

Thats the branche before

#

Got the same issue

#

Thats the reason why i installed py-cord

little cobalt
#

?

#

py-cord-dev is the newest version

edgy glen
#

I installed py-cord-dev.
Then i got the error
then i uninstalled py-cord-dev

Then i installed py-cord
Then i got the error too

little cobalt
#

do you use an env?

edgy glen
#

No

little cobalt
#

can you try it with a env?

edgy glen
#

Why

#

There should come the same issue

little cobalt
#

Its weird

edgy glen
#

Env is only a virtual env localy in an other directory. So there should be the same issue

shell radish
#

Pretty sure something went wrong with your python install

little cobalt
#

ye

shell radish
#

json is an stblib

edgy glen
#

XD

shell radish
#

standard library

#

that comes installed with python

edgy glen
#

Yeah

little cobalt
#

do you use the microsoft store one or the .exe from the website?

edgy glen
#

The exe

#

But the error came from the discord / was thrown from the discord library

shell radish
#

I don't use windows so probably just re-install python tbh

little cobalt
#

Run the installer .exe and try a repair or do a fresh install of it

shell radish
edgy glen
#

When u take a look to the screenshot 😂

#

Okay

#

But weird anyway

shell radish
#

halloween spoooooky

edgy glen
#

🤣

little cobalt
#

xd

edgy glen
little cobalt
#

What is the python version?

edgy glen
#

I installed python again.
I downloaded the x64 Windows installer.
Then added the tick to "Add python.exe to path" and then clicked "Install now"

#

Then I installed py-cord-dev and the error is still the same

shell radish
#

does import json and json.loads() even work

edgy glen
#

idk

#

But I fixed the error with using the embed description instead of the footer

#

But thats a crazy weird no sense fix 😂

shell radish
#

that's not the source of the issue, but ok

coral lake
#

There's no stage channel chat support? :O

rugged lodgeBOT
coral lake
#

I'm blind? :O

shell radish
#

it's on the pre-release

coral lake
#

ohh I see

shell radish
#

you can always use discord.PartialChannel.send

#

or PartialMessageable

#

something like that

coral lake
shell radish
#

*roll

coral lake
#

rooal

rugged lodgeBOT
pure carbon
#

Hi! What are the correct permissions to send message in a channel, and is there any channel-specific configuration that needs to be set?

message: discord.Message = await channel.send(message_content)

This command is returning a 403 permission denied error. However, this only happens in a particular server. Other two servers that I have the bot it works just fine. I'm pulling my hairs our trying to figure this out, so if you have any pointers for me I'd be very thankful!

#

For reference, those are the permissions I request

edgy glen
pure carbon
edgy glen
#
- Can developers create an own activity while using the discord activity shelf?```
pure carbon
#

They didn't untick that, and they don't have 2FA enabled (I saw that matters for some permissions). The bot works correctly in other servers.
I'll see if I can play around in a private server, find a way to deny that permission, and reverse engineer my way from there

edgy glen
#

Or is it just a simple text message?

pure carbon
edgy glen
#

No prob ^^

atomic fern
#

do embed field value has maximum characters? or unlimited?

brave arch
#

Yo! Is there a way to get user locale when said user instance is fetched via fetch_user / get_or_fetch_user? Type hints show that it returns type User, which doesn't have locale on it, only ClientUser has

shell radish
#

locale only comes with the interation object

brave arch
#

unfortunate

cerulean sun
#

any event listener for when somebody comments on a thread? or have to use on_message?

obsidian light
#

Anyone know why my bot stops working after first using a @bot.event command then a @bot.command() command? I added the await bot.process_commands(ctx)

obsidian light
#

My desktop wouldn't let me

little cobalt
#

why do you have bot.process_commands(ctx) at the command?

obsidian light
#

Oh idk

#

I think I was testing

#

Yeah, it still completely stops after saying that command in discord

shell radish
shell radish
#

and it shouldn’t be anywhere else

obsidian light
grim estuary
#

What is the best database to use for the bot, where the information should be stored like this:
{id: {map: {property1: value, property2: value, property3: value}, inventory: {property1: value, property2: value, property3: value}, anykey: value}, anyid: dict}

junior ember
#

how do i like

#

make a command have attachments

#

like its mandatory to add an attachment

lapis dock
coral lake
#

Is there any way to pass data when loading a bot extension BEFORE the cog starts up?

I'm attempting to dynamically name my slash command group based on the bot that's loading the extension, but I'm having trouble finding a way to do that before startup

coral lake
red mist
#

👍

coral lake
red mist
#

Oh you could do that too

coral lake
#

I just learned today that you could even assign variables to objects in that manner...that is fucking cool ahahah

#

^forgib my noob

little cobalt
#

you can even create a full custome help command with the cogs

red mist
hazy turret
#

Hello everyone,

With a slash command, you can't have the options generated dynamically, can you?
Does anyone have an idea how I can best solve this if I want to specify users for a slash command but the number of users is always different?
So it can be that one time 5 users have to be specified and the next time 10 and the next time only 7.
Does anyone have a good idea for this implementation?
Thanks in advance! 🙂

rugged lodgeBOT
#

Here's the slash autocomplete example.

coral lake
hazy turret
opal hamlet
#

how do i properly make a button owner only? because a non owner was still able to use the button

little cobalt
#

or if the user who pressed it is the same as the owner

opal hamlet
#

so no fancy decorator?

little cobalt
#

buttons are not like commands

opal hamlet
#

that... is a fair argument

#

as i already have a list of owners, i assume a simplepy if interaction.author.id in owners:should do it?

little cobalt
red mist
#

Is it possible to add 2 discord.ui.select 's to a command?

And if yes, how because I havent got the slightest of idea how.

coral lake
#

Can I make @self.points.command() work in this structure in any way, or do I have to lose the decorator and actually build the command?

class Economy(commands.Cog):
    def __init__(self, bot):
        global points_identifier
        self.bot = bot
        print("init")
    
        self.points = SlashCommandGroup(name=points_identifier, description=f"All commands related to {points_identifier}")
        self.advanced = self.points.create_subgroup("management", f"Manage {points_identifier} system")

    def create_commands(self):
        @self.points.command()
        async def add(self, ctx):
          print("function")```
red mist
# coral lake You add discord.ui.Selects to views. Class discord.ui.Select twice, add both to ...

Like this?

class MyView(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.add_item(discord.ui.Select(
            placeholder='Choose your color', 
            min_values=1, 
            max_values=1, 
            options=[
                discord.SelectOption(label='Red', description='Your favorite color is red', emoji='🔴'),
                discord.SelectOption(label='Green', description='Your favorite color is green', emoji='🟢'),
                discord.SelectOption(label='Blue', description='Your favorite color is blue', emoji='🔵'),
            ]
        ))
        self.add_item(discord.ui.Select(
            placeholder='Choose your shape', 
            min_values=1, 
            max_values=1, 
            options=[
                discord.SelectOption(label='Circle', description='Your favorite shape is a circle', emoji='⭕'),
                discord.SelectOption(label='Square', description='Your favorite shape is a square', emoji='🟩'),
                discord.SelectOption(label='Triangle', description='Your favorite shape is a triangle', emoji='🔺'),
            ]
        ))

    @discord.ui.select(custom_id="select1")
    async def on_color_select(self, select: discord.ui.Select, interaction: discord.Interaction):
        await interaction.response.send_message(f'You selected {select.values[0]} as your favorite color!')

    @discord.ui.select(custom_id="select2")
    async def on_shape_select(self, select: discord.ui.Select, interaction: discord.Interaction):
        await interaction.response.send_message(f'You selected {select.values[0]} as your favorite shape!')

class flavor(Cog):

    @add_to_group(get_current_folder())
    @discord.slash_command(name="flavor", description="testing select menu's")
    async def flavor(self, ctx: discord.ApplicationContext):
        await ctx.respond("Choose a flavor!", view=MyView())

def setup(bot):
    bot.add_cog(flavor(bot))
#

I am genuinely confused.

#

Oh wait I think I understand but fk I gotta go rn

#

brb

coral lake
# red mist Like this? ```py class MyView(discord.ui.View): def __init__(self): ...

No, you either create entirely seperate classes for the discord.ui.Selects (in the same manner that you class discord.ui.View) or you simply add your perameters to the @discord.ui.Select constructor to do everything within the view class.

The difference is that, when subclassing 2 new discord.ui.Selects, you get to use the view's class variables in those select classes (you cannot use class variables in constructors).

coral lake
noble flax
#

Is it possible to have a bot watch for a discord event and ping everyone on the interested list when the event starts?

#

(can't believe this isn't base functionality in discord)

coral lake
noble flax
#

I've never seen it occur...

#

Ever

coral lake
#

Nonetheless, it's not an @ ping

#

So there's no trace other than the initial noti AFAIK

noble flax
#

Hmmm question still stands then 🤣

#

But cheers for pointing that out

coral lake
#

Should be able to get get user.mention objects from this list and ping away

#

But yea, if anyone has ideas on how you could dynamically change the name of a Slash command cog group based on data from the Bot that is loading the module, please let me know.

The big issue is that it has to happen before the class is created...which might be impossible.

real raft
#

How can I host a Pycord bot? Although Pycord is specified in the "requirements.txt", the bot always starts without Pycord, which is why all cogs do not work
Everything works fine locally via Pycharm

lofty parcel
#

And where are you hosting your bot?

lofty parcel
real raft
#

I have tried various online host portals

lofty parcel
#

You only use py-cord... remove the other libraries...

real raft
#

thanks, i try this

lofty parcel
#

Why would you install 3 libraries to do the same

coral lake
real raft
coral lake
lofty parcel
#

How adding extra libraries will make it work lmao

real raft
#

Discord and py-cord only?

lofty parcel
#

As in, what gives the names?

lofty parcel
real raft
#

does py-cord include discord?

lofty parcel
#

No?

#

Discord is just another library

#

A total different library

coral lake
# lofty parcel As in, what gives the names?

Well, the idea is to find a way to get the bot name or ANY variabnle from the bot BEFORE the commands.Cogs class is created. If I can do this, I can use that data to access a JSON that is named according to that data to get that particular servers choice of name for their "currency"

real raft
#

I'm pretty new to this kind of thing. still learning

coral lake
#

But as is, I can't figure out ANY way to get that data dynamically before the actual class is created.

#

And since you can't subclass commands.Cogs....I'm kinda at a loss

lofty parcel
#

Wdym

coral lake
#

NGL though, Discord bots can be a great learning tool

lofty parcel
#

You can subclass cogs

real raft
#

I know the Python basics. The best way to learn is to apply the basics, for example with a Discord Bot

coral lake
lofty parcel
#

What I think of is, creating the command manually (so the name is dynamic), assigning it the callback manually and adding it manually

lofty parcel
coral lake
#

Since I couldn't use self.add_item, that is

lofty parcel
#

Subclass the command you mean?

#

I mean, if you manually create it

#

Then you add it to the bot manually

#

With uh bot.add_application_command or something like that

coral lake
#

Ohh, I see what you're saying - yea, tbh, that should work

#

I'll give that a go

lofty parcel
#

Yeah good luck lol

real raft
#

I've done a few projects like rpgs, web-scrapper and the like. but I've never used databases. neither used it to host something

coral lake
#

But it can be irritating for people who are more experienced because we do miss the basics more often...which...is frustrating for everyone.

real raft
#

I also got the Discord Bot working and am just having problems hosting it. What is the problem?

#

why such dumb answers bruh

coral lake
#

???

real raft
#

i mean dark

coral lake
#

I thought that was a pretty uplifting answer

real raft
real raft
#

Found the error. I had mixed up too much in the regs.txt, now it works.

coral lake
lofty parcel
#

Glad you figured it out

red mist
red mist
opal hamlet
#

got any tips/code examples for handling ext too large for a single embed/embed field? dont wanna send em in masses

red mist
red mist
#

Wait

#

nvm

#

I read

#

but not think

red mist
opal hamlet
#

what's Paginator again... does it make pages? maybe that'd be it

red mist
#

Oh

#

you wanna edit the embed?

opal hamlet
#

if worst comes to worst

#

edit embed > 5embeds in a message

#

its for a webscraped member list of a game faction, it will look like shit if too long

coral lake
opal hamlet
#

never used it lol, i love to ReadTheDocs ...

#

tomorrow me issue

lofty parcel
#

Its not that hard to use it tbh

#

Its just ```py
from discord.ext import pages

embeds = [discord.Embed(...), ...]
paginator = pages.Paginator(embeds, ... other kwargs)
await paginator.respond(ctx.interaction)```

fringe cape
#

i added a timeout function for my view but even if you press a button it still executes the timeout. is there stop the function from running

I just want the timeout function to not execute if the callback has gone off

#

is there a good way to do this or would i just declare a "timout" variable on init and use that to not run the ontimout function?

shell radish
fringe cape
#

oooh danke

devout mirage
#

not sure if i should open a thread for this, but what is this refering to as too long (its 3 am cut me some slack)```py
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.1.components.0.options: Must be between 1 and 25 in length.

shell radish
devout mirage
#

i have a select menu on row index 1, ill check it

pure carbon
#

Bit of a stupid question: the docs suggest using a few flavors of database, but it doesn't explicitly recommend any particular driver. Am I right to assume async versions are preferred E.g. sqlalchemy[asyncio]
with asyncpg?
If you know of any "well built" open source bot I could use as reference of best practices feel free to send them my way. Thank you

lapis dock
grizzled imp
#

@errant trout my bots are crashing since ##1947

here is some traceback if you want to take a look

rugged lodgeBOT
errant trout
#

Oh no

#

...I'll fix at home

lofty parcel
#

If you switch to py-cord-dev you can get it working

#

Master is broken lolz

grizzled imp
#

yeah i did

lofty hedge
#

i got a question when youre individually chunking a singel guild

#

and more stuff is processing after that, such as a print("guild is chunked") on a task, would that ever get triggered immediately or wait until the guils is chunked

#
@tasks.loop(seconds=60)
async def checkroles():
    await CLIENT.wait_until_ready()
    print("inside checkroles")
    try:
        main_server = await CLIENT.fetch_guild(938836203275452436)

        await main_server.chunk(cache=True)

        print(f"main server: {main_server}")
        print(main_server.self_role)
        if main_server.chunked:
            print("main server is chunked")
        else:
            print("main server is not chunked")
        beta_server = await CLIENT.fetch_guild(975586060308480070)
        await beta_server.chunk(cache=True)

        print(f"beta server: {beta_server}")
        print(beta_server.members)
        if beta_server.chunked:
            print("beta server is chunked")
        else:
            print("beta server is not chunked")
        print("got servers")
        trial_mod_main = main_server.get_role(992610751724400692)
        mod_main = main_server.get_role(967559301742886955)
        admin_main = main_server.get_role(1005985486705270976)
        print(f"trial mod role: {trial_mod_main}")
        for trial_mod in trial_mod_main.members:
            print(f"trial mod: {trial_mod}")
        
    except Exception as e:
        print(e)

checkroles.start()``` like ie keeps triggering the else
#

the whole issue is im trying to get all members that has a role in a server, and it keeps returning empty. I've used the members property on the bot object and printed that out and it's just an empty list and doesnt actually return anything.

It's printing out inside checkroles
main server: 24/7 Casino
24/7 Utilities
main server is not chunked
beta server: 24/7 casino beta bot
[]
beta server is not chunked
got servers
trial mod role: Trial Moderator
24/7 Utilities#8842 -> ONLINE | 29ms

#
intents = discord.Intents.default()

# intents.members = True
intents.members = True
intents.message_content = True
# intents.members = True

CLIENT = discord.Bot(intents=intents, chunk_guilds_at_startup=True)``` this is how im defining the bot / intents. and members is enabled on the discord developer portal
limber wagonBOT
#

Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.

Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.

What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.

lofty hedge
# little cobalt ?tag get_x

i get that, but if im doing get_role and if that role wasnt in the bot cache, it wouldnt print out nothing right? but it does print out the role name

little cobalt
#

It returns None

lofty hedge
#

trial mod role: Trial Moderator well here it's printing out the role name

molten ocean
#

How do I get a user's badges

red mist
#

I didnt know it was called either, but that should allow you to get them

#

user.public_flags should usually just do it

opal hamlet
#

how can i add a delete_after to a paginator.respond msg?

lofty parcel
opal hamlet
#

i found that paginator.send has delete_after, but when supplying it with the standard slash_command ctx(after await ctx.defer()) it just errors: TypeError: expected Context not <class 'discord.commands.context.ApplicationContext'>

#

maybe i just gotta write a delete after func?

lofty parcel
#

Cause it expects a commands.Context

lofty parcel
#

It's like 2 lines

opal hamlet
#

that's fair...

#

but anyways, how'd i supply it with commands.Context? do i like, have to specify ctx:discord.commands.Context as a arg?

little cobalt
opal hamlet
#

nah doesnt work

#

had that before

little cobalt
#

(self, ctx: discord.ApplicationContext):
...

await paginator.send(ctx.interaction, delete_after=10)

what is with something like that?

opal hamlet
#

nope

TypeError: expected Context not <class 'discord.interactions.Interaction'>

little cobalt
#

its at the example like that

little cobalt
#

change the send to respond

opal hamlet
#

then delete_after doesnt work as keyword

#

it works via respond yes, but i am just curious if there isnt a way to do delete_after

deft kestrel
#

How can I make the bot turn off its microphone in the voice channel?

deft kestrel
junior ember
#

Is there anyway to make my bot commands not available in dms

deft kestrel
junior ember
#

Ah

#

Do i put it in the command

#

Wait no

#

Do i put it above bot.slash_command

echo wraith
#

But above async def

molten ocean
#
@commands.command()
  async def memberinfo(self, ctx, user: discord.User):
      embed = discord.Embed(title=f"{user.display_name}",color=discord.Color.yellow())
      embed.set_thumbnail(url=user.display_avatar)
      embed.add_field(name="Account Creation Date", value=user.created_at.strftime("%b %d %Y"))
      embed.add_field(name="Joined at", value=discord.Member.joined_at)
      await ctx.send(embed=embed)

it shows "<member 'joined_at' of 'Member' objects>" in the embed. any idea?

heavy sky
#

and make user discord.Member instead of discord.User

lofty parcel
#

This is why you need to know how to read your own code really_bruh

opal hamlet
#

also comment/document

#

totally not me that scrapped an 500 line Cog cuz i couldnt figure out what the fuck i wanted to achieve with half the code

molten ocean
#

Sorry 😅

wintry pawn
#

for some reason my IDE doesn't see pycord as discord library. After installing pycord, it still makes me install discord package

little cobalt
#

PyCharm is using a env

wintry pawn
little cobalt
#

The list of the packages

wintry pawn
#

Oh, k

wintry pawn
shell radish
#

?tag notpycord

limber wagonBOT
#

The official name of the library is py-cord. When installing the library use py-cord, pycord (without the hyphen) is a completely different package.

wintry pawn
#

damn

#

now it works, thanks!

little cobalt
wintry pawn
little cobalt
#

you should uninstall py-cord and install py-cord-dev instead

#

py-cord-dev got a lot of bug fixes

wintry pawn
#

okay

#

btw, how fast can I edit messages and not get ratelimited?

little cobalt
#

uh, 1 sec.

wintry pawn
#

I just want to make a bot that acts like a currency graph, and though it will be edited every hour, I don't want to wait so long to test things

lofty parcel
#

Then edit every 5 or 10 seconds

wintry pawn
#

alright, thanks

plush marten
#

Hello.

#

Is it possible to, disable a specified button with name: 'view_votes' when a different button get's clicked?

#

I am currently using self.disable_all_items() but it does not seem to work.

lofty parcel
plush marten
lofty parcel
tiny fractal
#

is there a rate limit to rebooting the bot? mine stopped registering all commands all together

tiny fractal
little cobalt
#

how many commands and how many times did you reboot the bot?

tiny fractal
#

and probably rebooted like 10 times

little cobalt
#

F

#

and how many commands do you have? x3

#

the problem is that you can only do 100 commands every day and after that you can kinda shutdown the bot because you got the ratelimit from discord

tiny fractal
#

22

#

how is that not in an error response?

little cobalt
#

But I also wonder how you load the cogs ;3

tiny fractal
#
for cog in cogs_list:
    bot.load_extension(f"cogs.{cog}")
little cobalt
#

do you do it at the on_ready event?

tiny fractal
#

negative

little cobalt
#

good

tiny fractal
#

every other aspect of the bot works, i can change bot.activity, all embeds from events from each cog works

little cobalt
#

oh, they changed it a bit?

deft kestrel
#

i need help with else statements lol

tiny fractal
#

so by creates per day. does rebooting the server equal a create per command

#

each reboot

#

oh it is... oh man that is really stupid

tiny fractal
# little cobalt oh, they changed it a bit?
if bot.is_ws_ratelimited():
        print("WebSocket is currently rate limited")
    else:
        print("WebSocket is not rate limited")

just ran this. and it says WebSocket is not rate limited...

lapis dock
tiny fractal
#

on 2.4.1

lapis dock
#

👍

#

.tag slashnoshow

sly karmaBOT
#

Application Commands Not Showing Up?

  • Uninstall libraries that conflict with the discord namespace (e.g. discord.py).
  • Invite your bot with the application.commands scope.
  • Load cogs before bot.run() (e.g. not in on_ready).
  • Do not override on_connect.
  • Update to the newest version of py-cord (see ?tag install).
  • Turn off User Settings > Accessibility > Chat Input > Use legacy chat input.
  • Share your code and errors.
lapis dock
tiny fractal
#

yep all is true

lapis dock
#

Is it possible you have multiple instances of your bot running?

tiny fractal
#

at the time, there was. i forgot to shutdown the bot on the prod server before i ran the one in vscode to test a new command

#

it was working for quite some time, until one restart. just stopped registering commands

lapis dock
#

If you have not yet also please restart your discord client. Sometimes it is just a visual or caching issue.

tiny fractal
#

one sec

#

thats not it either

#

noone else in the server can use em either

lapis dock
#

Can you restart you bot without loading any commands (IE comment out cog loading) then restart again with everything as normal (Load cogs)

tiny fractal
#

no dice

#

i've never seen this before lol

#

want to buy: percussive maintenance on discord

lapis dock
#

I dont think you are ratlimited as I believe discord would return an error if you were.

tiny fractal
#

thats what i though too

#

i did reboot the bot several times in rapid succession, because testing json data from an API

tiny fractal
#

the bot

little cobalt
#

(I saw the edit)

lapis dock
#

Im out of ideas 🫤 . You could try creating another bot and using its token just to ensure that it is not the code causing the issue.

little cobalt
#

I would just wait like 10-20 minutes and try it with a simple command again

#

If its not a ratelimit

tiny fractal
#

i'm going to accuse javascript of this. some how, some way, somewhere, javascript is always responsible

tiny fractal
lapis dock
#

Did you add the applications.commands scope

tiny fractal
#

ope nope

#

though, i never once selected that scope originally for the first bot

#

selected the scope. same error

lapis dock
#

I guess it should be enabled by default when you enable bot

tiny fractal
#

yea, bot with administrator

#

ooh you know what

#

i accidentally had a debug_guilds id

#

ok so with the new bot from the portal it works now

#

also, i only added the debug_guilds id AFTER this issue started, for testing

lapis dock
#

I think it might just be best to wait for a while and hope that the issue is with discord. sorry :(

tiny fractal
#

all good. workin now. cheers

#

computers are hard

heady zenith
#

Is it possible to have a custom status for the bot?

surreal birch
#

How is it possible to have invite.inviter as null on invite create event?

solid sapphire
#

Is it possible to create Button with callback function without using a @discord.ui.button decorator?

surreal birch
#

yes

#

just set the callback using button.callback = <func>

solid sapphire
#

I though callback there was a method, not a property

#

I'll try, thanks!

surreal birch
#

An example from my code:

class TicketCloseSelectView(discord.ui.View):
    def __init__(self, client, user, channel: discord.TextChannel):
        super().__init__(timeout=None)
        self.client = client

        staff_select = discord.ui.Select(discord.ComponentType.string_select)
        for member in channel.members:
            if member.bot or member.id == user.id: continue
            staff_select.add_option(label=member.display_name, value=member.name)

        async def callback(interaction: discord.Interaction):
            nonlocal self, staff_select
            placeholders = {
                "bot": self.client,
                "server": interaction.guild,
                "user": interaction.user,
                "yetkili": staff_select.values[0]
            }

            content, embed = self.client.get_message_from_config("settings.ticket-system.messages.review-message", **placeholders)
            await interaction.response.edit_message(content=content, embeds=[e[0] for e in embed], files=[file for e in embed for file in e[1]], view=TicketCloseRateView(self.client, staff_select.values[0]))

        staff_select.callback = callback
        self.add_item(staff_select)
#

Pretty useful trick if you have to make dynamically set names. You can also extend button class and use it but i prefer this way as it is more simplistic

solid sapphire
#

but how can I pass there a button that is clicked?

surreal birch
kind grove
#

if a slash command option has required=False and no value is provided when running the command, what is the value set to? None?

kind grove
tiny fractal
#
self.bot.get_guild(GUILD_ID).voice_channels

why do i get "NoneType" Object has no attribute 'voice_channels' for this?

#

can't even use get_channel

tiny fractal
#

so apparently you cannot use those attributes and functions unless decorated as @commands.slash_command() and takes ctx as an argument, even though ctx never gets used..

limber wagonBOT
#

Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.

Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.

What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.

tiny fractal
valid panther
#

Good morning

mint solar
#

Why is my slash_command errors Unknown Interaction?

lofty parcel
mint solar
lofty parcel
mint solar
#

oh okay

round heart
#

~~Has anyone encountered any issues in 2.5-dev with using dropdowns that modify the original message?

e.g. When selecting a dropdown, the message is edited, but then not being able to select anything with the dropdown again~~

Okay, just tested it. That works as expected. Still trying to track down why Paginator dropdowns are failing when it's updated

round heart
#

Am I going senile?

ApplicationCommandInvokeError
Application Command raised an exception: AttributeError: 'ChainSelector' object has no attribute '_view'
Stack
await paginator.respond(ctx.interaction, ephemeral=True)
    /commands/addressbook.py Line 116

view.add_item(ChainSelector())
    /views/Addressbook.py Line 259

for chain, entries in self.view.cog.get_non_global_entries().items() if entries
    /views/Addressbook.py Line 373

... I see no reference to any _view. I'm guessing it's the auto-inherited _view from discord.ui.Item, but I still don't get why it's complaining here.

celest flame
#

hey guys , does anybody know how to get rid of this warning? i've tried using initial_response = await ctx.send(content="Processing your request...") and it still shows the warning

lofty parcel
#

Its ctx.respond

lofty parcel
#

Not ctx.send

little cobalt
#

lul

celest flame
lofty parcel
#

i was forst zervy >:(

celest flame
kind olive
#

is there a way to way to have a button prompt a slash command?

lofty parcel
kind olive
lofty parcel
#

Just copy the callback into the button

kind olive
#

wdym

lofty parcel
#

Copy your slash command code and paste it in the button callback

kind olive
#

what

#

nevermind

sage tendon
#

context?

#

also why am i only seeing year-old tweets without a twitter account

edgy nest
#

its my reaction to you posting that here

sage tendon
#

I'm sorry

#

I didn't realise

deft hull
#

Is it possible to fetch a list of a User's friends from the api

valid panther
#

I'm testing context-menus and I don't know if I'm doing it wrong but I don't get it in my app onclick section.

valid panther
lofty parcel
#

And it isn't showing up?

#

You right clicked the message then > apps?

valid panther
lofty parcel
#

Then what bruh

valid panther
#

only work @discord.user_command

lofty parcel
#

That's the context menu you're creating

lofty parcel
valid panther
lofty parcel
#

Is the cog being loaded?

valid panther
lofty parcel
#

Can you show a screen recording of what's happening

valid panther
#

1s

lofty parcel
#

Not the message.

valid panther
#

okay okay

#

Sorry for the inconvenience

valid panther
#

@lofty parcel Can I limit who sees the commands in context menu?

#
    @commands.guild_only() # Only Guild
    @commands.has_permissions(administrator=True, ban_members=True, kick_members=True, manage_messages=True) # Who can use it
    @discord.user_command(name="User")
    async def on_click_user(self, ctx, member: discord.Member):
        embed = await self.format_embed_user(ctx, member)
        await ctx.respond(embed=embed, ephemeral=True, delete_after=60)
lofty parcel
#

You can use @discord.defult_permissions

#

Or manually edit it through the integrations tab

valid panther
#

I have done a test as such the user gets the command, but obviously it no longer lets you run

lofty parcel
#

I'd add Internal checks and the ones discord give

#

So both commands.has_permissions and discord.default_permissions

tall shale
#

PLEASE HELP ME GUYS HOW I GET CTX.AUTHOR IN CLASS MYMODAL

lofty parcel
#

They use interaction which is discord.Interaction

#

.rtfm discord.Interaction

lofty parcel
#

Read the docs and find out what you need

tall shale
#

How get?

tall shale
#

.rtfm discord.Interaction

tall shale
clear aurora
#

Is there a global way to use 'await self.bot.wait_until_ready' so that I don't have to include it in every 'tasks.loop'?

shell radish
#

start the tasks in on_ready

clear aurora
#

i start the tasks in a cog

#

in an extra class

brave arch
#

is there a way to get a jump url to a slash command response?
i'm using it as response = await context.respond(embed=embed) in a slash command, but response has message as None, and no jump_url

#

i only found the original_response coro, but it performs a request to api under the hood?

lofty parcel
brave arch
#

nah it's much easier, since interaction ID is the message ID, you can just construct url yourself as f"https://discord.com/channels/{result.guild_id}/{result.channel_id}/{result.id}"

lofty parcel
#

Whatever you wanna use is OK

brave arch
#

result is an interaction returned by respond etc.

red mist
#

Because Jesus Christ I'm NGL, any "website" web app or community ig wants you to register and use their app or else they won't let you pass

plush marten
#

Hiya.

#

Is @discord.default_permissions(manage_channels=True) also possible with a role?

#

That the command is only visible to those who have role xx?

lapis dock
lapis dock
woeful oak
#

Would there be any problems if I use the same custom_ID for multipe persistent views?

I am currently doing for 2 and they seem completely fine

little cobalt
woeful oak
#

(The class only contains 1 button)

little cobalt
#

1 ID would be fine than

woeful oak
#

Thank you

woeful oak
little cobalt
#

you would get a error for using the same id

languid hazel
#

Um I have a question : for the decorator @discord.default_permissions(), when I pass discord.Permissions.all() in the decorator, I get a TypeError : default_permissions() takes 0 positionnal arguments but 1 were given. What's wrong with what I did ?

little cobalt
#

you have to add a permission to it

languid hazel
#

Wdym

#

discord.Permissions.all() is basically all the permissions enabled, isn't it ?

#

That's what I did, in clear :

@discord.default_permissions(discord.Permissions.all())
little cobalt
#

why do you not just add administrator=True?

languid hazel
#

It's confusing

little cobalt
#

I just dont know if it works for the slash command permission

languid hazel
#

Okay

#

I'll do with admin perms, thank you ¯⁠\\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯

little cobalt
#

It might work has_permissions but with default_permissions the permissions can be changed

#

at the server

little cobalt
#

has_permissions is like "hard coded" while default_permissions is it not

languid hazel
#

...

#

X)

#

I don't understand

#

How can an admin of a server modify the perms for using a command ?

little cobalt
#

they can change the command permission if they want to

languid hazel
#

Okay, thanks for helpin

little cobalt
#

Server>Settings>Integrations>The Bot

#

@languid hazel

languid hazel
#

Oooh that's new I never seen that

#

Thanks 😊

hazy turret
#

Hello,
is it somehow possible to dynamically add another option to select another channel?
That I can first select a channel and then maybe another channel and if I have selected this one then maybe another one and so on?

@bot.slash_command(name="channel")
@option(
    "channel",
    Union[discord.TextChannel, discord.VoiceChannel],
    # You can specify allowed channel types by passing a union of them like this.
    description="Select a channel",
)
async def select_channel(
    ctx: discord.ApplicationContext,
    channel: Union[discord.TextChannel, discord.VoiceChannel],
):
    await ctx.respond(f"Hi! You selected {channel.mention} channel.")
languid hazel
#

I think you have to edit the message and changing the view of it

little cobalt
hazy turret
hazy turret
hazy turret
#

Is it possible to always start the task on a certain day of the week at a certain time?

@tasks.loop(time=time(23, 0))```
real raft
#

does it still make sense to make commands with a prefix or should you make all commands with a slash

little cobalt
subtle moth
pale igloo
#

Is it possible to record audio from each user separately in a voice chat?

valid panther
#

Does anyone have an example of an automod?

dawn prism
#

Hi, i have a quick question.
I have a task that loads each day to do a backup on my database.

Unfortunately, the task launch when i start my bot but i just want it to "be enabled" at first. Is there a way that when i run my bot, the first time the task execute its code is 1 day after ?

ripe pine
#

#1172489261879140442

real raft
#

how to use hybrid commands with pycord

real raft
#

thy

valid panther
#

I have created a new thread so that if anyone has problems with the automod, we can share problems and solve them. #1172512655198662727

sage tendon
#

yes as i said
if the bot cant DM or kick the user, will it just keep going or abort the entire current function if i dont use a try except

#

solved :>

lofty parcel
dawn prism
lofty parcel
#

Thats the only thing i can think off lmao

dawn prism
#

x)

#

Thanks anyway !

lofty parcel
#

Some asyncio.sleep wouldn't be that bad

#

Like on the @task.before_loop coro

dawn prism
#

i see, but i think the boolean var is easier and maybe a bit better

lofty parcel
#

Yes, probably

plush marten
#

Hello.

#

My Button after an x amount of time, just stops working.

#

Code: class ReactionView(discord.ui.View): @discord.ui.button(label="Get Session Role!", style=discord.ButtonStyle.primary, custom_id="s_role") async def start_ssu(self, button, interaction): role = interaction.guild.get_role(.....) if role in interaction.user.roles: await interaction.user.remove_roles(role) await interaction.response.send_message("Role removed!", ephemeral = True) else: await interaction.user.add_roles(role) await interaction.response.send_message("Role added!", ephemeral = True)

lofty parcel
#

Next time dont crosspost. Only ask in one channel.

lapis dock
rugged lodgeBOT
#

Here's the persistent example.

sour musk
#

Heya, i cant wait long time
I have
@bot.listen()
async def on_message(message)

@bot.event()
async def on message (message)

And the first affects the work of the second

lofty parcel
#

Dont crosspost.

deft kestrel
#

hello, could i fetch the activity when someone starts playing something?

#

example my bot is in the srver and it has started already, when someone starts playing minecraft for example, it sends to the console

lapis dock
molten ocean
#

How to see the number of bots in a server

deft kestrel
tiny fractal
#

do SlashCommandGroups need the guild_ids applied to it. just noticed my new cog isn't being registered with its slashcommandgroup

little cobalt
tiny fractal
#

weird. bots only in one guild anyway, but stopped registering commands

lofty parcel
tiny fractal
lofty parcel
#

Is it being loaded

little cobalt
#

other question

#

how do you load the cogs

tiny fractal
#
for cog in cogs_list:
    bot.load_extension(f"cogs.{cog}")

and yea the cogs on_ready fires

little cobalt
#

so you load them at the on_ready event?

tiny fractal
#

no

little cobalt
#

ok

tiny fractal
#

i had something similar happen the other day with normal slashcommands, and i had to delete the bot from the developer portal and create a new one to get it working again

little cobalt
#

do you spam the API a lot?

tiny fractal
#

i mean, i reboot the bot in testing, but i have

if bot.is_ws_ratelimited():
        print("WebSocket is currently rate limited")
    else:
        print("WebSocket is not rate limited")

and i've never been rate limited

#

plus i'd imagine i'd get some sort of error if i was ratelimited, but no errors appear

lofty parcel
#

How many commands do you have

tiny fractal
#

about 30

lofty parcel
#

Have you tried setting guild_ids to the commands

#

And see if they register

tiny fractal
#

all slashcommand have that, then i started expirementing with slashcommandgroups. i have one cog with 3 slashcommandgroup commands, that register instantly without the guild_ids

#

the second commandgroup cog, no luck.

#

i tried
term = SlashCommandGroup(name="term", description="Terminology commands", guild_ids=[GUILD_ID])

#

but it did nothing

#

does each @term.command() also need the guild_ids too?

#

OMG

#

im such an IDIOT

#

i accidentally nested all of the commands inside the cogs on_ready

#

feel free to pin that im an idiot lol

grizzled loom
tiny fractal
valid panther
#

Has anyone here used the automod?

sage tendon
#

why async for if its a def?

lofty parcel
sage tendon
#

but i can just treat it like a normal for if i dont need any fancy extras right?

lofty parcel
#

You can flatten it into a list

sage tendon
#

dont need to for just this, no?

little cobalt
#

you dont need a reason

sage tendon
#

i want one tho

little cobalt
#

;3

sage tendon
#

:3

little cobalt
#

lul

lofty parcel
#

How the hell do I turn a local image into a bytes obj

#
little cobalt
lofty parcel
#

Oh what I was thinking wasnt that bad then

#

I'll try

little cobalt
#

well xd

little cobalt
lofty parcel
#

Uh, u tell me

little cobalt
#

nvm xd

little cobalt
#

that was what I get

#

just try it out xd

pale igloo
#

When making a slash command, should i use ctx: discord.Interaction or discord.ApplicationContext? Im not really sure what the difference is, and when I should use which. From the docs it looks like they mostly do the same thing. And my code still works when I switch between them

lofty parcel
#

discord.Interaction is when you receive interaction in views

#

And typehinting doesn't affect your code, just what your IDE autocompletes for you

pale igloo
#

alright thanks

grim nymph
#

lets say i have a channel called 1 but @everyone is unable to read that channel, would it be able to make the bot change the permissions of @everyone so it can read the channel and then change it back if possible? Could you also link this in the documenation so i can understand the documenation more. Thanks in advance

little cobalt
#

#help-rules

grim nymph
#

my apologies buddy

stray pasture
#

Will this library continue to be supported, or most effort are placed in pycord 3 ?

shell radish
stray pasture
#

perfect thank you !

pale igloo
#

Is there anyway to get audio from a sink before I end the recording? My bot requires that I can get the audio in a voicechat about every second. Another idea i had is to stop and start the recording in quick succession, but im not sure if that will cause gaps in the audio

heady zenith
#

Pycord is also uses logging?

pale igloo
lapis dock
sly karmaBOT
junior ember
#

File "C:\Users\ethan\Downloads\asdada.py", line 30, in on_message
message.guild.default_role: discord.PermissionOverwrite(read_messages=False),
AttributeError: 'NoneType' object has no attribute 'default_role'
how fix

junior ember
#

so hwo fix!!!

little cobalt
#

hwo?

lapis dock
#

Your guild is none. That all we know from what you provided

deft kestrel
#

Does anyone have experience with creating application commands through the API?

sage tendon
#

Does display_avatar work for default avatars too?

lofty parcel
#

Yes

sage tendon
#

nice thx

little cobalt
#

?tag intents

limber wagonBOT
#

Pycord Docs - Intents
Discord API Docs - Gateway Intents

import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
deft kestrel
#

it works but when i click the I'm Sender button it wont update the embed with my name

#

im expecting for the embed to say sender: @deft kestrel

shell radish
sage tendon
#

doesnt it return the default avatar of that user?

lapis dock
#

You need to update the view when you disable the button
IE in your edit message add view=view

woeful oak
#

How to register a Persistent View from another file (from cog)

On Disabling then enabling a Persistent View (through a command), it no longer works (used <view>.enable_all_items())
So I'm trying to register it again as a Persistent View. How to do that from a different file that doesn't have the bot object available?

lofty parcel
woeful oak
lofty parcel
woeful oak
#

Yes

lofty parcel
#

Just pass the bot object to the cog

#
def __init__(self, bot):
     self.bot = bot


....


def setup(bot):
    bot.add_cog(MyCog(bot))```
woeful oak
#

Ohh thank you

charred radish
#

So I have a main.py file. In the Folder (where the main,py file is located) I have a src folder in the "src" folder I have a "commands" folder and in the "commands" folder I have a "slash" and a "prefix" folder (slash is for slash commands and prefix is for prefix commands) How can I make that the Python files getting loaded when launching the main.py file? Im sorry for this question, I made discord bots with python like 2 years ago and switches to Javascript so I lost a bit knowledge.

lofty parcel
#

Ignore the guy. He gone

sage tendon
#

uh yea what do

little cobalt
#

do you test py-cord 3 or what?

sage tendon
#

yes#

#

all i did until now wwas change discord to pycord

little cobalt
#

dont use py-cord 3

sage tendon
#

i just wanna test and mess around a little

#

so what do

shell radish
sage tendon
#

no way 💀

echo wraith
#

?client

little cobalt
echo wraith
glad garnet
shell radish
sage tendon
#

why the fuck did I send that here

shell radish
deft bronze
#

any way to use something like "ephemeral" but with bridgecommand?

shell radish
#

only responses to interations can be ephemeral, so text-based commands simply cannot be ephemeral

red mist
young cove
#

Are there ways to accept an image upload (not a url) from a user other than by reading their message or through a slash command? Like from a modal or a prompt after pressing a button?

sage tendon
#

what other ways would there be lol

#

either you read the message attachment or make a slash command with an option
theres no other option to get a picture from a user

tawny root
#

Hey so I want to get the ids of a member by using member.roles however when I try to index the list it returns it retursn a string when I want to return an id how do I do this thanks in advance.

valid panther
#

How can I dynamically load commands into an embed without making a name:id ?

#

the ids change every time I update something and it's a bit cumbersome

subtle moth
#

iirc the id only changes when you delete the command and remake it

rugged lodgeBOT
shell radish
#

@valid panther

valid panther
#

thxx

shell radish
#

yw

sage tendon
#

I use this code to kick bots, which always select one of two sets of roles. For some reason, a lot of the time, it won't actually kick them until I manually update them long after they already picked their roles
And code further down from the screenshot also does not execute after members selected their onboarding roles
I tried everything and it just seems like an issue with member updates not working correctly rather than my code, so, what do

sage tendon
#

since sometimes it does work without a forced user update

echo wraith
#

How do I set a default permission to a group?

#
    mod_group = SlashCommandGroup(name="mode", description="Moderation commands")
    mod_group.default_member_permissions = discord.Permissions(administrator=True)
    mod_group.guild_only = True

does not work

autumn gust
#

why doesn't this work

#
    channel = bot.get_channel(1121763166976749630)
    for i in range(10):
        await channel.send(f"test {i}")
#

it has a NoneType issue

#

is there a typo somewhere that I made or?

echo wraith
autumn gust
autumn gust
#

or

#

nvm

#

but how do I call into that channel then?

echo wraith
autumn gust
#

ye

lofty parcel
echo wraith
# autumn gust ye

do it in 2 lines
channel = await bot.fetch_channel
await channel.send

autumn gust
#

ah

autumn gust
#

alright might need some help again, how do I make something like, I type in a seperate terminal (on my machine), which feeds the message (string) over to the bot (another file) which then sends the message to a channel (channel.send(variable))

#

roughly like this

shell radish
#

you can definitely do this with websockets

autumn gust
shell radish
#

by creating a separate program that can relay the information to the bot through a websocket. The bot can receive the information and execute on it

autumn gust
#

uhhhh

#

so like, how do I create a websocket

#

?

shell radish
#

there are many ways to create one

autumn gust
#

nvm I think I found it

shell radish
#

I do not know how your bot is structured or how your bot works or what type of information you are relaying. I recommend researching yourself.

autumn gust
#

aaah that seems so complicated

#

I'm just relaying a string

#

which changes

#

ie I read input from a user in a terminal, which gets sent over to the bot

young skiff
#

How to put a custom presence without "playing" or "watching"?

lofty parcel
deft kestrel
#

Does anyone know how to enable/disable the mention raid detection? If its already enabled, it just gives a 404 not found error when trying to edit the rule.

young skiff
#

I tried with CustomActivity

await bot.change_presence(activity=discord.CustomActivity(name='Custom status'))```
but it doesn't work, nor does any error appear
deft kestrel
#

Online, dnd etc

tiny fractal
#
pagination_view = PaginationView()
pagination_view.data = list_of_items
await pagination_view.send(ctx)

I have a slash command executing the code above. While it does respond with the correct data requested, it also throws "The application did not respond" before hand.
Does the slashcommand need to respond with something always? was hoping to avoid that as the response is in the pages

young skiff
placid shard
loud kayak
#

When subclassing commands.HelpCommand, how would I filter commands from ones a user can and cannot use based on command permission checks like the default one does?

chrome plover
#

For some reason, recently today, images in embeds are acting weird..

#

First image is me on my pc

#

on phone

#

And sometimes even on pc for a few seconds it'll be IN the embed then after a few seconds its OUT of the embed?? Like what's happening, I haven't changed any code, possibly smth to do with disc?

little cobalt
chrome plover
#
            lb_embed.set_image(url=f"attachment://profile.png")
            dfile = discord.File(bytes,"profile.png")
            lb_embed.set_footer(text = f'Page {self.current_page}/{math.ceil(len(self.data) / self.sep)}')
#

Btw its happening for all my embeds

#

I haven't changed anything

little cobalt
#

and how do you send the message?

#

and what is your py-cord version?

chrome plover
#

But I'm pretty sure its smth to do with discord, its behaving really abnormally, how its twitching in and out sometimes.. I just wanted to see if anyone else is facing this issue

valid panther
# shell radish <@280334313667559425>

I'm trying the documentation you have passed me, but I don't understand why it comes out duplicated:I'm trying the documentation you have passed me, but I don't understand why it comes out duplicated:

        for command in self.bot.walk_application_commands():

            embed.add_field(name=f"{command.name}",
                            value= f"❯ </{command.qualified_name}:{command.id}> - {command.description}\n"
                                      f"ID: {command.id}\n"
                                      f"Patents: {command.parent}",

                            inline=False)
lofty parcel