#General Help

1 messages Β· Page 25 of 1

dusky karma
#

but its not a fork of dpy so lots of rewrote to do?

tropic fractal
#

I agree the stuff that just happened was completely uncool (even though I do kinda agree with the staff, but the banning for a different opinion is wrong), however the codebase is still improving and has a nice UX imo

past gate
#

i mean they did sort of, but hopefully they keep it up to date

#

i like the community

slender lintel
#

@tropic fractal do you know how id do this?

serene crystal
tropic fractal
#

not when migrating but once you've written a bot in it it is fairly streamlined

wraith shell
#

ive never had any major bugs with pycord, neither any lack of support, so i'm confused why you think so. i definitely do not agree with the server taking a political stance like this, but the module itself is perfect imo

static edge
#

i've had major bugs in pycord, but they've been fixed after i pointed them out

tropic fractal
#

did they just get banned-

past gate
#

apparently so

tropic fractal
#

I had a fatal bug fixed within minutes of reporting it

dusky karma
#

sadly I dot have the time to migrate atm

serene crystal
#

I've had bugs in NAFF, which were fixed within a day.

#

just saying.

harsh rapids
#

real programming

past gate
#

at the end of the day, just use the library you want

wraith shell
tropic fractal
#

plus who's pulling from git anyway? 2.0.0rc1 has very few or no bugs that I've encountered

past gate
#

it don't matter

static edge
#

i'd like to stay with pycord if only because i don't feel like rewriting my bots, but i'm really not a fan of outright stopping dissenting opinions because you do not agree with them. i understand there's no freedom of speech on discord but i think it should either be allowed to have a dissenting opinion, or there flatout shouldn't be politics (which is actually rule 5.1)

slender lintel
#

Wait, Pycord is being discontinued?

#

No?

static edge
#

i never said that

past gate
#

i hope not

slender lintel
#

o

wraith shell
#

pycord in general is one of the best modules ive used for discord bots - has nothing to do with the political decisions made in the server

past gate
#

if it does im moving to programming in Haskell so I can suffer endless pain

slender lintel
#

Did krittick just leave the server

serene crystal
past gate
#

@shell shuttle

#

nope

tropic fractal
#

#883236900171816970 apparently they got banned

slender lintel
#

yeah

past gate
#

he's here

crimson hinge
slender lintel
#

they did

slender lintel
past gate
#

oh

#

he did

slender lintel
#

Why did kidstrick guy leave

past gate
#

πŸ‘€

#

oh well.. life moves on

slender lintel
#

#989958162100666398 anyone?

tropic fractal
#

this'll be over in a day

wraith shell
#

this is so weird

past gate
#

πŸ˜„

static edge
wraith shell
#

i came here to get help on interactions and modals and i see this T_T

dusky karma
#

🀣

serene crystal
wraith shell
past gate
#

I was just chilling on Euro Truck and got a ping and then I saw the content of the ping and decided to keep driving

serene crystal
#

so literally all forks. ok.

past gate
#

I was like 'nah i'm good I aint dealing with that shit no ty'

slender lintel
slender lintel
serene crystal
wraith shell
slender lintel
#

#989958162100666398 if anyone can help, would be appreciated!

wraith shell
#

dpy pre-suicide was actually really nice, and i'd rather that over a horrible implementation of the same thing

serene crystal
#

You haven't tried NAFF, disnek etc.

slender lintel
#

I tried moving to dpy yesterday, Way too much to learn and change in my code

wraith shell
#

after the forks era, now its just what you prefer for slash commands

slender lintel
#

so went back to here

past gate
slender lintel
#

agreed

serene crystal
#
@slash_command(name, description, scope, permission)
async def _something(self, ctx: InteractionContext):
  code
noble umbra
#

whats wrong with it

serene crystal
#

nothing close to that.

past gate
slender lintel
#

yh

past gate
#

never really looked into it too much since i dont use dpy

wraith shell
past gate
#

dont you dare compare linux to dpy

#

linux ratios dpy anyday

static edge
#

ahem, linux/gnu

slender lintel
#

The Support is faster, The actual lib is rly bad

past gate
#

dpy community is a shit show to say the least

wraith shell
#

like i cant think of a single reason you want to restart a bot without registering commands - and pycord supports that too

past gate
#

i've said this statement before

wraith shell
#

but dpy makes you explicitly register every command

slender lintel
wraith shell
#

iirc

noble umbra
past gate
#

Β―_(ツ)_/Β―

wraith shell
#

another reason im sticking to pycord

slender lintel
#

yeah

past gate
#

speaking of other libs

slender lintel
#

#989958162100666398

past gate
#

I wonder how they check for localization in slash cmd names

#

time to go looking

slender lintel
past gate
#

like slash cmd names from different languages

wraith shell
#

ohhh you mean how they let you define it

static edge
serene crystal
past gate
#

?

slender lintel
#

even if someone tries to help its appreciated :D

wraith shell
#

well ig ill bump my qn too... #989956142757203988

daring flint
# slender lintel anyone?

You already made a Forum post. No need to spam, just wait for a response; people are from different parts of the world and may not reply immediately

rapid pawn
past gate
#

self promotion isn't allowed

slender lintel
past gate
#

i dont think so at least

noble umbra
rapid pawn
#

lmao i see

scenic leaf
#

i really need some help i reinstalled my pc and when i added all the modules this is what keeps popping up

Exception has occurred: TypeError
function() argument 'code' must be code, not str
  File "C:\Users\traag\Documents\GitHub\BBMoon\run.py", line 2, in <module>
    import discord
#

why does it do this ?

wraith shell
#

send the full traceback

scenic leaf
#

thats the full trace back

wraith shell
#

it just... stops right there?

scenic leaf
#

yes

#

see

#

these are the modules i installed

pip install spotipy
pip install beautifulsoup4
pip install yt-dlp
pip install DiscordUtils
pip install discord.py
pip install asyncio
pip install psutil
pip install mcstatus
pip install twitchAPI
pip install Pillow
pip install matplotlib
pip install PyNaCl
pip install aiodns
pip install aiohttp
pip install brotlipy
pip install chardet
pip install pymongo
pip install py-cord
pip install py-cord --pre
pip install pymongo[srv]
wraith shell
#

uninstall discord.py

#

and reinstall py-cord from github

scenic leaf
#

ill try i did try uninstall and reinstall everything Xd

#

not that tho

#

now there is no module named discord Xd

#

i did install py-cord using the github

#

and restarted the visual studio code

wraith shell
#

your pip list should show py-cord but not discord or discord.py

#

if that's true it should work

scenic leaf
#

Pip list or pip freeze ?

#

this is my pip freeze list

aiodns==3.0.0
aiohttp==3.7.4.post0
async-timeout==3.0.1
asyncio==3.4.3
asyncio-dgram==2.1.2
attrs==21.4.0
beautifulsoup4==4.11.1
Brotli==1.0.9
brotlipy==0.7.0
certifi==2022.6.15
cffi==1.15.0
chardet==4.0.0
charset-normalizer==2.0.12
click==8.1.3
colorama==0.4.5
cycler==0.11.0
Deprecated==1.2.13
DiscordUtils==1.3.4
dnspython==2.2.1
ffmpeg-python==0.2.0
fonttools==4.33.3
frozenlist==1.3.0
future==0.18.2
idna==3.3
imageio-ffmpeg==0.4.7
kiwisolver==1.4.3
matplotlib==3.5.2
mcstatus==9.0.4
multidict==6.0.2
mutagen==1.45.1
numpy==1.23.0
orjson==3.7.3
packaging==21.3
Pillow==9.1.1
psutil==5.9.1
py-cord==1.7.3
pycares==4.2.0
pycord==0.1.1
pycparser==2.21
pycryptodomex==3.15.0
pymongo==4.1.1
PyNaCl==1.4.0
pyparsing==3.0.9
python-dateutil==2.8.2
redis==4.3.3
requests==2.28.0
six==1.16.0
soupsieve==2.3.2.post1
spotipy==2.20.0
twitchAPI==2.5.5
typing_extensions==4.2.0
urllib3==1.26.9
websockets==10.3
wrapt==1.14.1
yarl==1.7.2
yt-dlp==2022.6.22.1
#

and it still says that discord cant be found

dire cobalt
#

Since everyones in chat rn, does anyone know when the default help commands is coming back? Last I checked it wasn't ready yet or something.

slender lintel
#

Wdym?

#

Was it ever gone?

dire cobalt
#

the default /help doesn't seem to work for me. I haven't checked in a while so if it's back disregard me lol

quartz snow
#
class JoinButton(discord.ui.Button):
    def __init__(self):
        """."""

        super().__init__(
            label="test",
            style=discord.ButtonStyle.primary,
            custom_id="join",
        )

    async def callback(self, interaction: discord.Interaction):
        pass

how can I make the buttons work when restarting? (callback)

scenic leaf
#

okey i made it work had to uninstall every modle it had by hand

#

but now it says raised an error: AttributeError: module 'discord.ext.commands' has no attribute 'slash_command'

slender lintel
quartz snow
slender lintel
#

?tag install

hearty rainBOT
#
  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

  2. Install py-cord
    python -m pip install 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

Updating to release candidate:
pip install py-cord==2.0.0rc1

scenic leaf
#

aah

supple ravineBOT
#

Here's the persistent example.

slender lintel
#

@quartz snow

scenic leaf
#

YES IT WORKS !!

#

im never resetting my pc again

#

sorry for the caps btw

hoary moss
#

Fixed this yesterday, just letting you know, my bad, my mistake

slender lintel
#

Oh wait you got it fixed

#

sorry for ping

hybrid portal
#

can you disable a button based on roles ? like the same button is disables for on but other can use it

static edge
#

not to my knowledge, though you can do effectively the same thing by just checking their role after they press the button

wraith shell
#

In client.wait_for(), can you have a coroutine as check=? cause I want to react with ❌ for any messages that don't match the check function, and adding a reaction is asynchronous

#

how would I go about doing this?

slender seal
#

why does this print error

wraith shell
#

you can figure out by

except Exception as e:
    print("error is", str(e))
frigid lark
#

;3

slender seal
#

How I get Pyncal?

slender lintel
slender seal
scenic leaf
slender lintel
#

What would i use to ignore bots in this command? /membercount
I am using
{ctx.guild.member_count}
rn

languid hollow
#

Ok so I was using dynamic cooldown so that it'd change the cooldown value when the values have changed however the cooldown does not execute

#

I'm not sure what I'm doing wrong?

quartz snow
#
@discord.on_interaction(interaction)
async def on_interaction(self, interaction):
        print("interaction")

raised an error: AttributeError: module 'discord' has no attribute 'on_interaction'

what about the decorator?

slender lintel
#

@commands.Cog.listener
async def on_interaction

languid hollow
scenic leaf
#

how do i fix this ?

static edge
#

presumably matrix is an asynchronus function call

#

can you show where you initialize MATRIX?

scenic leaf
static edge
#

also why do you have an await after the equals in DAYS

scenic leaf
#

wee this code is really messy and i want it in cogs but cant cause its too messy and will only work in the main bot file haha

#

ill show readfrom file

#
async def readFromFile():
        with open(FILE) as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=',')
            matrix = []
            for row in csv_reader:
                matrix.append(row)
            return matrix
#

read from file

static edge
#

that's an asynchronus function

#

you are calling it without an await

#

therefore python is interpreting it as you literally just passing a function (i think)

#

fix is just to do MATRIX = await readfromfile()

#

...and also probably to remove the random await in front of the list comprehension

scenic leaf
#

it says this

static edge
#

well yeah, you can't do it unless it's an async function

#

therefore you have two options, you have either make it a regular, non async function (which is probably the correct choice here)

scenic leaf
#

okey then ill do that Xd

static edge
#

yeah just go with that, tldr, you can run async functions in a non async function, but you'll want to look up how

#

there's a few different ways how and the intracacies can matter

scenic leaf
#

okey for now it started without errors

#

i swear if this code was a human i would have shot it in the face πŸ˜‚
its the first thing i ever made for my bot in python haha

static edge
#

i mean it's just doing what you asked it to...

scenic leaf
#

true tho Xd

#

but i am trying to make this work in my current bot instead of my old one

#

but this current bot is more ordered with cogs and such

#

my old one isnt haha

#

i want to put it in a cog but i cant do that cause i dont know how since this code is quite messy

#

wait maybe someone here can help me make it to cogs

#

is there anyone who can help me make a old bot into cogs the bot has 488 lines of code
8 commands
8 variables
7 def functions

#

i have put it allready inside a cog its just either indentation and some stuff like async or def

#

and maybe some fixes to make it work with pycord

static edge
#

this isn't supposed to be a place to ask for help with creating/refactoring your code, so it's possible but unlikely anyone will take you up on your request

#

it's also just flat out against the rules

quartz snow
#
class JoinButton(discord.ui.Button):
    def __init__(self):
        """ . """

        super().__init__(
            label="test",
            style=discord.ButtonStyle.primary,
            custom_id="join",
        )

    async def callback(self, interaction: discord.Interaction):
        pass

how can I call a command from another cog from here?

static edge
#

if it's an invoked command, you can just call it on the imported cog. otherwise you can use the get_cog function from the bot

quartz snow
scenic leaf
static edge
#

try it if you don't believe me

#

get_cog works with any cog regardless of importing as well

quartz snow
# static edge get_cog works with any cog regardless of importing as well

button_lobby_handler

import discord
from discord.ext import commands

class JoinButton(discord.ui.Button):
    def __init__(self):
        super().__init__(
            label="test",
            style=discord.ButtonStyle.primary,
            custom_id="join",
        )

    async def callback(self, interaction: discord.Interaction):
        pass

imported into another
from cogs.button_lobby_handler import JoinButton

static edge
#

why are you showing me this code?

#

if your issue is that you don't have access to the bot, then you can just set the callback to that button in the other file

#

which bypasses even needing to get the cog or import it in any way

green compass
steady lotus
#

how does default_member_permissions work? im using default_member_permissions=discord.Permissions(manage_guild=True) but i can still run the command even without that perm

slow dome
#

?tag discord.utils.

hearty rainBOT
#

dynoError No tag discord.utils. found.

slow dome
#

b!rtfm pyc discord.utls

scenic leaf
#

i want a command but i need help making it Xd
i want to add member names to a list when they do !me
and every half hour i want the bot to send a message with their name

#

i know i need to use a list

slow dome
scenic leaf
#

yes thats what i want

slow dome
#

ok so what do you need?

scenic leaf
#

i do have

@commands.command()
    async def me(self, ctx: commands.Context):
        await ctx.send(f'me {ctx.author.name}!')
#

the command

#

and name = []

#

now i need to store the name and send it each half hour

slow dome
#

b!rtfm ext.tasks

open bearBOT
# slow dome b!rtfm ext.tasks

I couldn't find a documentation with the name ext.tasks! Maybe you used to command wrong? Correct Usage: <prefix>rtfm <docs> [<term>] (eg. b!rtfm py cool)
List of Documentations you can search:
python
pycord
discord.py
yarsaw
nextcord
disnake

scenic leaf
#

eh

slow dome
#

b!rtfm pyc ext.tasks

slow dome
scenic leaf
#

Xd true Xd

slow dome
#

suggested

scenic leaf
#

okey so i should use a loop

slow dome
scenic leaf
#

lets see if i can make that work

slow dome
#

you got this

scenic leaf
#

never really used loops that much Xd

slow dome
#

there's a table below. type the letter you want it

#

to be

scenic leaf
#

how do i add the name to the list ?

#

name = []

slow dome
#

list.append(ctx.author)

scenic leaf
#
async def sending(self):
        await self.wait_for_ready()
        channel = self.get_channel(channelslist)
        firsthost = namelist[0]
        await channel.send(f'/host {firsthost}')
        del namelist[:1]
#

the loop function

slow dome
#

a datetime.datetime object

scenic leaf
#

this should get the list then send a message and delete the first name in the list after it sended the name

slow dome
#

why would a member have a timestamp

#

Member.created_at returns a datetime.datetime

scenic leaf
#

okey 1 Question
1 how to get the position of your name in the list
lets say i do !me
and i wanna do !Position to get my position in the list how do i get that ?

slow dome
#

so do something like

await ctx.respond(f"{member.id} {discord.utils.format_dt(stuff here)}")
slow dome
scenic leaf
#

thanks !

#

you guy are really helpfull thank you guys so much !

slow dome
#

np

#

np

scenic leaf
#

okey i have a question for now i made it work but how do i do a little calculation
i have this
myposition = namelist.index(ctx.author.name)
this will return the position of my name in a list
lets say my position is 2
but i want to do like myposition X 30
so myposition times 30
that will return 60

#

how do i do that ?

#

i thought it was like myposition*30

slender seal
#

Anyone know what this is erroring

sudden path
sudden path
scenic leaf
#

hmm then wierd its not working

sudden path
#

Code?

woven hemlock
#

How should I keep the interaction context through a modal that may take too long to reply?

#

the interaction seems to be 404 by the time it gets a http response in my case

#

resolved, used defer within the modal callback, seems to work fine now

steep verge
#

b!rtfm pyc discord.extcommands

slender seal
#

Anyone know why this doesn't work

slow dome
hearty rainBOT
#

As of Pycord Beta 5, Discord API v10 requires message content intent to receive message content. This affects the traditional commands. Not enabling this intent will result in the messages' content, embeds, and components being empty.

You will need to enable the intent on the developer portal, as well as in your code:

intents = discord.Intents.default()
intents.message_content = True
bot = discord.Bot(intents=intents)

Docs: https://docs.pycord.dev/en/master/api.html#discord.Intents.message_content

slender seal
slow dome
slow dome
#

update pycord

#

?tag install

hearty rainBOT
#
  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

  2. Install py-cord
    python -m pip install 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

Updating to release candidate:
pip install py-cord==2.0.0rc1

slow dome
#

the last line

slow dome
tepid anvil
#

Hi @slow dome , what is the best way to run same function parallelly on all the server's that the bot is in.

#

currently im using onready and going through one by one

slender seal
slow dome
#

I have no idea what apple thought that was

slow dome
tepid anvil
#

list will have the server ids right , or function calls ?

slow dome
slow dome
#

it’s an example, but idk why you would do that

tepid anvil
slow dome
#

does that work?

tepid anvil
slow dome
#

I think it’s something about futures

bleak ibex
#

i have 1 problem, i have 1 file and contains 1 file which is A.py and main file will be main.py, if i include @client.command or @client.event in A.py folder then in main.py just to import it and call the function without declaring @client.command or @client.event correct?

sudden path
#

No, you use cogs.

bleak ibex
supple ravineBOT
#

Here's the slash cog example.

#

Here's the slash cog groups example.

bleak ibex
golden stone
#

How to use discord api
Like i didn't get it

supple ravineBOT
#

Here's the background task asyncio example.

sudden path
woven hemlock
#

How should I prevent my bot from infinitely thinking despite fulfilling a interaction followup?

#

I'm using the followup (after a defer) to edit the original message

#

The interaction is by all means fulfilled yet the bot continues to think

#

can followup.edit_message(id) not fulfill the interaction?

smoky fog
#

Hi

#

how i can make a command : !start and when i start this command:
While True:
when a member joins:
inv_user = await tracker.fetch_inviter(member)
inviter = member.guild.get_member(inv_user.id)
channel = bot.get_channel(channel_id)
await channel.send("{member.mention} Has Joined!, He Was Invited By:{inviter.mention}

#

the question is

#

how i make when i say

#

!stop

simple bisonBOT
# smoky fog !stop
λ…Έλž˜κ°€ μž¬μƒ 쀑이지 μ•Šμ•„μš”!
smoky fog
#

when member joins dont send that message

slender lintel
smoky fog
#

oh ok thanks

slender lintel
#

b!rtfm pyc on_member_join

open bearBOT
scenic leaf
# sudden path Code?
if myposition*30 == 0:
            await ctx.send(f'you will be hosted next make sure your live!')
        else:
            await ctx.send(f'you will be hosted in {myposition*30}! make sure your live!')
#

myposition is a list so i get my position in a list like
im position 2 that times 30 so it should return 60

#

but it doesnt

glass nova
#

Hey. Im pretty sure there was a post about it somewhere which i cant find because of my buggy app (searching stops it lol). But its pretty straightforward:

Each and everytime i receive an interaction, i respond. But that makes it very dirty with lots of ephemeral messages and all. I just dont wanna respond with sending a message. Defering is an option but it will eventually be an error after 15 mins? How do i just do nothing

ocean shale
#

is there a way to mark a slash command to not be shown to all users but only to ones that have a certain role ?

slender lintel
slender lintel
ocean shale
#

not actually seeing it

slender lintel
#

?

ocean shale
#

the code above checks if the user can use the command

#

my question was about a user being able to see the command when they start typing

#

so for example when I type / here

#

I get a pop-up of commands I can type

#

if I don't have permission to run this command for example

#

i should not even see it as a suggestion

#

that is what I was asking

scenic leaf
#
Starting Bot...
Startup Complete
Ignoring exception in command setstreamer:
Traceback (most recent call last):
  File "C:\Users\traag\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "C:\Users\traag\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 852, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
TypeError: Streamerslot.Setstreamer() got an unexpected keyword argument 'args'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\traag\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\traag\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\traag\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Streamerslot.Setstreamer() got an unexpected keyword argument 'args'

why do i get this error ?

#

this is the code i wanna run

 @commands.slash_command(name = "setstreamer", description= "will manually set a featured streamer", Guild_ids=config.Guilds)
    async def Setstreamer(self, ctx, *args):
        roles = [role.name for role in ctx.message.author.roles]
        if self.ADMIN_ROLE in roles:
            today = datetime.datetime.today()
            value = args
            f = open("featured.html", "w")
slender lintel
#
@slash_command(name="suggestaccept",description="Accept a suggestion")
    async def suggestaccept(self,ctx, m_id: discord.Option(str, description="Message id."),new_embed:discord.Option(str, description="New embed")):
     m = self.bot.get_message(m_id)
     await m.edit(new_embed=new_embed)
     await ctx.respond('Accepted suggestion by {interaction.user}')``` Nonetype has no attrubite edit?
scenic leaf
#

i need the args

#

cause i have to do /setstreamer blackbull

scenic leaf
#

when i do async def Setstreamer(self, ctx, args):
it does work but it sends just the b of blackbull

#

Xd

#

and i do need the args or change the name to something but its just not working

glass nova
#

How can i make it so the option is either attachment or string

#

but only one of those 2

glass nova
scenic leaf
slender lintel
#

to show it?

scenic leaf
#

why ?

#

people can read Xd

#

lots of people do read back

slender lintel
#

well i didnt know?

#

nobody normaly looks back

scenic leaf
#

in normal discords no but this is a help channel then they mostly do

#

what i always do is ask my question then wait

slender lintel
#

ok well we are just flooding our own questions so lets not

scenic leaf
#

if no one responded to it ask it again if there is like lots of flooded stuff Xd

#

Xd

icy sluice
#

What does this mean?

slender lintel
#

code?

crimson gale
slender lintel
icy sluice
crimson gale
#

pip install -U py-cord==2.0.0rc1

icy sluice
#

ty

slender lintel
#

What would i use to ignore bots here? I use
{ctx.guild.member_count}
right now

crimson gale
#

list comprehension of guild.members with condition not member.bot then grab the len() of it

slender lintel
crimson gale
#

read the full sentence

slender lintel
#

I dont understand it all

crimson gale
#

then you should do something else for your project

#

have you ever seen list comprehension?

slender lintel
#

nope lol

crimson gale
slender lintel
#

thanks

icy sluice
crimson gale
#

pip list

icy sluice
#
Package            Version
------------------ -----------
aiohttp            3.7.4.post0
akinator.py        5.0.0
astunparse         1.6.3
async-timeout      3.0.1
attrs              21.4.0
beautifulsoup4     4.10.0
braceexpand        0.1.7
certifi            2021.10.8
cffi               1.14.6
chardet            4.0.0
charset-normalizer 2.0.9
click              8.1.3
discord.py         1.7.3
giphy-client       1.0.0
humanfriendly      10.0
idna               3.3
import-expression  1.1.4
jishaku            2.3.2
lavalink           3.1.4
multidict          6.0.2
pip                22.1.2
psutil             5.9.0
py-cord            2.0.0rc1
pycparser          2.20
python-dateutil    2.8.2
python-dotenv      0.20.0
pytube             11.0.2
qrcode             7.3.1
requests           2.28.0
setuptools         58.1.0
six                1.15.0
soupsieve          2.3.1
speedtest-cli      2.1.3
topggpy            1.4.0
typing_extensions  4.2.0
urllib3            1.26.7
wheel              0.37.1
wikipedia          1.4.0
yarl               1.7.2
slender lintel
# crimson gale https://www.w3schools.com/python/python_lists_comprehension.asp here you go

I tried

@slash_command(name="membercount", description="Member Count")
    async def membercount(self, ctx,):
      for guild in self.bot.guilds:
          for member in guild.members:
              yield member
              await ctx.respond(f'The server {ctx.guild.name} has len(){guild.members} members')```
error:
discord.errors.ExtensionFailed: Extension 'commands.membercount' raised an error: TypeError: Callback must be a coroutine.
The docs dosent say anything about this being a coroutine?
#

@crimson gale

crimson gale
#

what in the goddamn did you make out of my simple instruction?

#

just what

#

this is more complicated than what i had instructed you to do

#

you dont need the second for loop for anything

#

or specifically the thing i listed

crimson gale
slender lintel
#

The
await ctx?

crimson gale
#

also there would be a better way to format this whole thing without sending multiple messages per guild

crimson gale
#

string manipulation lol

slender lintel
#

Could you please give an example im rly conufused lol

#
for member in members:
              yield member
              await ctx.respond(f'The server {ctx.guild.name} has len(){guild.members} members')```
#

i got that

#

but i think its wrong.

crimson gale
#

its completely wrong. i did not ask you to do that

icy sluice
slender lintel
crimson gale
#

pip uninstall

crimson gale
slender lintel
crimson gale
#

you dont need to specify version number when uninstalling

slender lintel
#
@slash_command(name="membercount", description="Member Count")
    async def membercount(self, ctx,):
      for guild in self.bot.guilds:
          for member in guild.members:
              yield member
              await ctx.respond(guild.members)```
slender lintel
slender lintel
#

i read the w3schoools again

crimson gale
#

this isnt even list comprehension my guy

slender lintel
#

litearly reading this..

crimson gale
#

Without list comprehension you will have to write a for statement with a conditional test inside:

#

read the document

#

scroll to the next example

#

also the yield keyword shouldnt be used in that context

#

its wrong

#

all of this couldve been avoided had you known basic python

#

or read the page

slender lintel
crimson gale
#

the first for loop is better used outside of that list comprehension

#

because you want per guild member counts

slender lintel
crimson gale
#

move the first loop outside of the list comprehension

#

how hard is that to understand?

#

if youre having this much trouble with basic python, you really shouldnt be using pycord as it requires you to know of several advanced concepts that build off of the basic foundation

#

seriously, consider doing something else as your starter project

slender lintel
#
async def membercount(self, ctx,):
        for guild in self.bot.guilds:
            guild = [for member in guild.members]
            await ctx.respond(guild)```
#

I know basic python

crimson gale
#

you might wanna unindent that await line

#

and add the condition to the list comprehension that filters out bots

#

wait no, dont unindent the await line

#

though you will have to unindent it for a better implementation that uses less messages

slender lintel
crimson gale
#
  1. no, 2. why the excess pair of parenthesis?
#
  1. thats not even a list
slender lintel
crimson gale
#

guild is not a list

#

wait it is but why have you named it guild?

#

eh whatever

#

show me the current code again please?

slender lintel
crimson gale
#

you didnt even add the condition for the list comprehension that you wanted

#

you wanted it to exclude bots no?

slender lintel
#

Yeah i wanna exclude bots, i thought len did that

crimson gale
#

len just counts the elements in an iterable

slender lintel
#

oh, so what would exclude bots

crimson gale
#

adding the condition not member.bot in the list comprehension

slender lintel
#

is this the correct code

crimson gale
#

also youre missing the expression part of the list comprehension

#

you have the loop and the optional condition

#

but the expression is missing

#

just type member before the for keyword in there

slender lintel
crimson gale
#

yes

slender lintel
#

is this finaly correct?

crimson gale
#

also i dont like the name youve decided to give the list but thats just a nitpick

#

and bad practice since it overshadows a variable

slender lintel
#

what about members =

crimson gale
#

what?

slender lintel
crimson gale
#

because it overshadows an already existing variable name (in this case guild from the for loop)

#

and you might want that still

#

but members is fine

#

and you wanted specifically a member count with the bots excluded

#

you will still need len

slender lintel
crimson gale
#

its a function man

#

why is it outside?

#

um

#

now we need to fix the list comprehension again

slender lintel
crimson gale
#

its not a question of where you should put it but what you put in its arguments

slender lintel
#

o

crimson gale
#

and fix the list comprehension

#

your variable renaming broke it

slender lintel
#

i thought i had fixed that

crimson gale
#

well not from what i can see

#

you did fix it but you broke it as well

#

is what happened

#

you managed to fix it yet?

slender lintel
slender lintel
#

hey

#
import os

os.system("python3 -m pip install py-cord")

import discord
from discord.ext import commands

intents = discord.Intents.all()
bot = commands.Bot(command_prefix=">", intents=intents)

@bot.slash_command()
async def ping(ctx):
    await ctx.send("pong")

bot.run("token")```
#

AttributeError: 'Bot' object has no attribute 'slash_command'

#

nvm

#

i used python3 -m pip install py-cord==2.0.0b7 and it worked

silent pawn
#

how to make a command which work on both slash command and perfix

icy sluice
#

What’s the event called when my bot joins a server?

icy sluice
#

i recommended looking them up in docs

silent pawn
#

`bot = commands.Bot(command_prefix="!")

@bot.event
async def on_ready():
print(f"{bot.user} is ready!")`

finite cliff
#

i want to disable a button in a view but the button that is clicked will not be the button to be disabled

crimson gale
#

code

languid hollow
#

run through self.children

steady lotus
#

for help commands, i get the context invocation through self.context right?

languid hollow
#

compare the child.label not the button interacted and disable

crimson gale
#

in rc1 there is a method that disables all children of the view

languid hollow
#

i don't think he wants all of em disabled

finite cliff
#

Can you give 1 example?

languid hollow
#

yes the button name

#

sure

#
for child in self.children:
    if child.label != "Announcement": 
        child.disabled = True            
#

child.label is the button label that you added during the creation of the button

#

i love how hardly anyone knows much about advance cooldown, me suffering

finite cliff
#

Oki

#

Thanks

slender lintel
#

AttributeError: module 'discord.commands' has no attribute 'Bot'
ξΊ§

crimson gale
#

discord.Bot

slender lintel
#

thank you

teal shadow
#

Please send an example of how it should work

class discord.ScheduledEventLocation
sudden path
#

discord.ScheduledEventLocation(value="StageChannel")?

#

Why dont you just try it yourself

crimson gale
#

theres also documentation that you maybe should try reading for yourself

sudden path
#

BOY. You're so fast with links

crimson gale
#

because i was already looking at it when you posted that

slender lintel
#

can someone help me?

    from discord.ext import tasks, commands
ImportError: cannot import name 'tasks' from 'discord.ext' (unknown location)```
#

im trying to run it on repl it

#

fixed it by reinstalling it

frigid lark
robust nebulaBOT
slender lintel
#

thanks

slender lintel
sudden path
#

If it returns None then the message is not cached.

slender lintel
slender lintel
#

ModuleNotFoundError: No module named 'discord.abc'

#

man

sudden path
slender lintel
sudden path
#

The message is not in the bots cache.

slender lintel
#

How do i fix that?

sudden path
#

Fetch the message instead. Which makes an api call

#

b!rtfm fetch_message

open bearBOT
# sudden path b!rtfm fetch_message

I couldn't find a documentation with the name fetch_message! Maybe you used to command wrong? Correct Usage: <prefix>rtfm <docs> [<term>] (eg. b!rtfm py cool)
List of Documentations you can search:
python
pycord
discord.py
yarsaw
nextcord
disnake

sudden path
#

b!rtfm pyc fetch_message

slender lintel
slender lintel
sudden path
#

Depends on where you're fetching the message

#

Use common sense

slender lintel
sudden path
#

Try it and see ✨

slender lintel
sudden path
#

Have you realised you need a Discord.TextChannel instance/object

sudden path
#

Discord.TextChannel is the whole class

#

You need an instance of that class

#

You need to get a channel instance

slender lintel
#

Like channel = self.bot.get_channel('idofchannel')

#

or am i being stupid

crimson gale
#

yes

slender lintel
# sudden path You need an instance of that class
 @slash_command(name="suggestaccept",description="Accept a suggestion")
    async def suggestaccept(self,ctx, m_id: discord.Option(str, description="Message id."),new_embed:discord.Option(str, description="New embed")):
        if ctx.author.guild_permissions.administrator:
         channel = self.bot.get_channel('987396375069224960')
         m = await discord.TextChannel.fetch_message(m_id)
         await m.edit(new_embed=new_embed)
         await ctx.respond('Accepted suggestion by {interaction.user}')``` Same error, What have i done wrong?
crimson gale
#

well you need to use the channel reference that you just got

#

youre still using the class definition

slender lintel
crimson gale
#

go learn oop

crimson gale
slender seal
#

Its np now I got it to work

slender lintel
crimson gale
#

that is the exact opposite of what you need to do

crude temple
#
@commands.has_role('Admin')
@bot.command()
async def add(ctx):

is there any way to simulate this in pycord so that the command add stays disabled for users not having that role?

slender lintel
crimson gale
#

but in this case no

#

you get the instance from the get_channel method

slender lintel
crimson gale
#

because you shouldnt

#

thats for the library to use

slender lintel
crimson gale
#

learn what?

slender lintel
#

OOP

crimson gale
#

just google

#

you have the entire internet at your disposal

steady lotus
#

is it not possible to respond with a sticker after a slash command

slender lintel
# crimson gale and fix the list comprehension
user_count = len([members for members in ctx.guild.members if not member.bot])
        membercount = f'{ctx.guild.name} has'
        member = 'members'
        await ctx.respond (f'{membercount} {user_count} {member}')``` I got it sorted (I think the way i responded is a little messy but it works!)
sudden path
#

Why
member = "members"

#

You're cresting an unnecessary variable

#

membercount is also unnecessary

slender lintel
#

It works thats all i need

sudden path
#

You can type it inside the respond? Lmao

slender lintel
#
@slash_command(name="membercount", description="Member Count")
    async def membercount(self, ctx,):
        user_count = len([members for members in ctx.guild.members if not members.bot])
        await ctx.respond (f'{ctx.guild.name} has {user_count} members')```
#

:)

crimson gale
#

defer = response

#

use followup

glass nova
supple ravineBOT
#

examples/app_commands/slash_options.py line 38

Union[discord.TextChannel, discord.VoiceChannel],```
glass nova
#

what even is an invalid usage, google didnt really help

slender lintel
#
  @slash_command(name="info", description="Sends bot ping")
  async def ping(self, ctx):
    guilds = len(list(self.bot.guilds))
    info = discord.Embed(title="FelBot Infomation", description=f"Here is some infomation about me!\nI am in {guilds} servers \n My ping is {self.bot.latency}")
    await ctx.respond(embeds=info)```
Application Command raised an exception: ValueError: embeds cannot exceed maximum of 10 elements
#

why?

slender lintel
glass nova
#

yeah. tell me whats invalid over there compared to the example code in github maybe?

slender lintel
noble umbra
#

You pass a sequence of embeds

slender lintel
#

So embed =

#

Or

#

. _. how have you been sending embeds normally.

#

The other embds I do work fine lol, probably me just forgetting smth

noble umbra
#

Have a look at the other embeds and see what you are doing differently there

#

It might be a good plan to do this before asking for help, try to solve it on your own, the error isn't that cryptic

slender lintel
#

because you can only have either string, or an attachment

#

unlike the textchannels and voicechannels

#

because those get all the textchannels and voicechannels in teh guild

#

ill write a small program to test it out real quick

noble umbra
#

Slash commands don't have unions at the moment

#

you probably want two separate options / subcommands

slender lintel
#
    info = discord.Embed(title="FelBot Infomation", description=f"Here is some infomation about me!\nI am in {guilds} servers \n My ping is {self.bot.latency}")``` What would i use to round the ping
#

I had it before, but forgot what i used

#

basically with how this is setup i think you can only have either a str, or a discord.Attachment.

#

you cant have both since there wouldnt be a place to input either

slender lintel
#

oh

slender lintel
noble umbra
#

Its a function

slender lintel
#

Oh alr

languid hollow
#

anyone can help in #990240354802479175?

tulip pelican
#

Is there a way to check which prefix and which alias was used to activate a command? (without having to deal with the content string, bcz of complications with aliases)

odd pike
#

Does anyone know what the problem is and how I can edit the image?

glass nova
runic flare
#

Haven't used py-cord or d.py in a while and now i'm trying to make a simple bot yet none of the commands, atm just the ping command, are registering

code:

import discord
import os
from datetime import datetime
from dotenv import load_dotenv
from discord.ext import commands

load_dotenv()

intents = discord.Intents.all()
intents.message_content = True

PREFIX = os.getenv("PREFIX")
TOKEN = os.getenv('TOKEN')
owners = [304024578009595907, 219323433719300105]
client = commands.Bot(intents=intents, owner_ids=set(
    owners), case_insensitive=True, command_prefix=PREFIX)

# for filename in os.listdir('./utils'):
#     if filename.endswith('.py'):
#         client.load_extension(f'cogs.{filename[:-3]}')


@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')


@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content == "test":
        await message.channel.send("shut up whore")


@client.command()
async def ping(ctx):
    embed = discord.Embed(
        title="Ping!", description=f"{ctx.author.mention} pong!", color=0x9270fa)
    embed.add_field(name="Ping", value=f"{round(client.latency * 1000)}ms")
    embed.timestamp = datetime.utcnow()
    embed.set_footer(text="Latency of bot")
    await ctx.send(embed=embed)

client.run(TOKEN)
languid hollow
#

hmmm, I guess make the on_message a command itself by...

#
await bot.process_commands(message)
runic flare
#

ok that worked but ive never had to do that before

#

is that new

languid hollow
#

um tbh idk i found it on goggle

languid hollow
past gate
#

think its to do with 2.0.0b5 of pycord and above

languid hollow
#

on_message makes it the priority and removes the other commands from processing

#

something around those lines))))

green compass
#

@slow dome or anyone else who could help.
Here is a simplified code fragment that shows the error TypeError: Messageable.send() got an unexpected keyword argument 'embeds' - if this code succeed it would repost whatever embeds were included in the message that had a reaction added to it (obviously not a useful scenario):

@client.event
async def on_raw_reaction_add(payload):
    current_channel = client.get_channel( payload.channel_id )
    message = await current_channel.fetch_message(payload.message_id)
    
    # ERROR ON THIS LINE
    # TypeError: Messageable.send() got an unexpected keyword argument 'embeds'
    msg = await current_channel.send(embeds=message.embeds)

    return
``` So, it seems like `embeds` is not a supported parameter on `TextChannel.send()` even though the documentation (https://docs.pycord.dev/en/master/api.html#discord.TextChannel.send) states that is should be supported in v2, and I'm running `py-cord  2.0.0rc1`.
green compass
#

Thank you @slow dome. I tried this and get embeds=[], i.e., an empty list. Thinking that could be the problem, I created an embed and added it to the list, with the same error.
I'm no expert, but as I understand it, this error should indicated that the embeds parameter is not support on TextChannel.send() ...?

tulip pelican
#

Can you default "allowed_mentions" to none() for all sends?

sudden path
tulip pelican
#

what's the param?

#

oh yea I'm stupid sorry

#

lol

runic flare
woven hemlock
#

Anyone know why interaction.followup.edit_message(id) doesn't resolve the interaction after interaction.response.defer()?

#

the edit is made but the bot is kept in a 'thinking' state

slender lintel
#

I Got it smh

woven hemlock
frigid palm
#

can someone help me with this?

SyntaxError: Non-UTF-8 code starting with '\xf6' in file C:\Users\Administrator\Desktop\CloudLife.net\slash.py on line 53, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details
frigid palm
#

im using PyCord

scenic leaf
#

im used to use delete_after= in embeds cant i do that in a interaction ?
await interaction.response.send_message(embed=embed, ephemeral=True, delete_after=60)
cause if i do this it fails

steady lotus
#

i noticed when manually creating a slashcommand class instance, passing cog as a parameter doesnt do anything as the command initialisation sets cog to None

#

is this on purpose

slender lintel
sudden path
slender lintel
#

hey

ornate creek
ancient gazelle
#

Hey Guys, I have a problem, I want to create a role in a server and I want it to be at the highest possible by the bot in the role hierarchy in the server. Any help with that?

upbeat hill
#

in a slash command how do you turn a bunch of mentions into a list ?

#

something like this

slender lintel
cosmic stone
#

guys how can i add my bot for testing?

solar berry
tulip pelican
#

Does anyone know if Member.premium_since is given to an on_member_remove event if they were previously boosting?

#

Does fetching a channel cache that channel? (If chunking is disable)

elfin lintel
#

hi everyone how to use slash_command permission

dawn wagon
#

How do i split these roles so its like:
Role1
Role2
Role3
...

Bc now its like this: Role1 Role2 Role3

quiet siren
#

I want my bot to send messages every hour but for some reason this error pops up:
PS C:\Users\MRS\Desktop\DefenderBot> & C:/Users/MRS/AppData/Local/Programs/Python/Python310/python.exe c:/Users/MRS/Desktop/DefenderBot/Commands.py test None <discord.embeds.Embed object at 0x000002BEE83B8E50> Unhandled exception in internal background task 'send_message'. Traceback (most recent call last): File "C:\Users\MRS\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 176, in _loop await self.coro(*args, **kwargs) File "c:\Users\MRS\Desktop\DefenderBot\Commands.py", line 675, in send_message await channel.send(embed = partnersHourlyEmbed) AttributeError: 'NoneType' object has no attribute 'send' Bot is ready!
What am i doing wrong?

sudden path
#

You're starting the bot before it is ready so the channel isn't cached.

quartz snow
#

how can I get a list with messages from all channels?

supple ravineBOT
#

examples/background_task.py lines 28 to 36

@tasks.loop(time=time(3, 0, tzinfo=timezone.utc))  # Task that runs every day at 3 AM UTC
async def time_task(self):
    channel = self.get_channel(1234567)  # Your Channel ID goes here
    await channel.send("It's 3 AM!")

@my_background_task.before_loop
@time_task.before_loop
async def before_my_task(self):
    await self.wait_until_ready()  # Wait until the bot logs in```
dawn wagon
red tendon
dawn wagon
#

Oh ok wait

#

Thanks it works now

red tendon
#

np :D

odd pike
#

How can I make it so that you can click the button only once?

ocean timber
#

Any ideas on how to hide args in a slash command?

frigid lark
azure quest
# quartz snow how can I get a list with messages from all channels?
for channel in guild.text_channels:
  async for message in channel.history(limit=None) #limit none will iterate over all msgs in channel
    pass #do stuff

You can then use lists inside a dict if you want to organise msgs in the channels and store them via built-in functions within the loop

messages = {
  "11204812185015": [message, message], #discord.TextChannel.id, discord.Message
  "40283424024884": [message]
}

I would suggest making this a function

sleek grove
#

guys how to disable a button after interaction

azure quest
#

Maybe edit the message but set the parameter for the button to None?

#

I know barely anything about interactions

ocean timber
quiet siren
#

i suggest watching this video: https://www.youtube.com/watch?v=kNUuYEWGOxA

This is the Ultimate Python Guide on Buttons with Discord.py or Pycord. In this video, I talk about how to create buttons in discord.py or pycord and how to respond to button clicks along with everything about Views. After watching this you'll know everything about Buttons and Views in discord.py or pycord.

This video might also apply to other...

β–Ά Play video
sleek grove
quiet siren
languid hollow
#

How can I make a space between the name and the value?

crimson gale
#

\n

languid hollow
#

i did use \n but it didn't work

languid hollow
crimson gale
#

yep

languid hollow
#

I did use it like that however it didn't put spacing in

languid hollow
knotty niche
#

how do i revenrt back to an older pycord version? My bot was working fine until i updated it to the recent patch

#

πŸ—Ώ

crimson gale
#

using prefixed commands?

languid hollow
#

where the green line is there's no spacing coming 😭

crimson gale
#

try adding \u200B before the new line character

knotty niche
knotty niche
languid hollow
crimson gale
knotty niche
crimson gale
#

have you provided the necessary intents for those to work?

knotty niche
#

intents?

crimson gale
#

?tag intents

hearty rainBOT
#
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)
knotty niche
#

my bot was working fine with slash but when i reverted back to prefixed , it doesn't work at all

crimson gale
#

well did you provide the intents?

knotty niche
#

no

crimson gale
#

then provide them

#

messages and message_content

#

refer to the above

knotty niche
crimson gale
#

prefix commands are commands that depend on a message with a prefix

#

thus you need messages and message_content intents for prefixed commands to work

crimson gale
#

you managed to fix it?

knotty niche
crimson gale
#

code?

knotty niche
#

I am regretting my decision to even go to slash commands in the first place

knotty niche
knotty niche
crimson gale
#

you have unnecessary code

#

for setting the intents

#

what intents do you need right now?

knotty niche
#

I never have had to use intents before this

#

so I am oblivious to the concept as a whole

crimson gale
#

well nows a good time to learn

#

good practice is to turn on the intents you need

#

not all at once

knotty niche
#

Hmmm

crimson gale
#

also are you getting an error when you start the bot?

knotty niche
#

Nope not a single error

crimson gale
#

so you have all the privileged intents turned on then

knotty niche
crimson gale
#

it should work

#

though you should remove unnecessary intents

knotty niche
#

okay

knotty niche
#

it doesn't even respond to any commands and stuff

#

neither does it show an error

quartz snow
#

in cog

@discord.command()
async def test(self, ctx): 
    pass

why is the command not working? using the prefix

crimson gale
#

intents?

quartz snow
#
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), intents=intents)```
crimson gale
#

add message_content intent

knotty niche
#

I swear i will kill myself

#

you know what was wrong?

#

πŸ—Ώ I got it

#

I forgot to put command_ before prefix

#

πŸ’€ πŸ’€

#

I have been plauged with this shit for 2 days now

crimson gale
#

wat?

#

oh right

knotty niche
# knotty niche

client = commands.Bot(prefix="!", intents=intents)In this line it should have been command_prefix

trim glen
#

My bot is Killed

knotty niche
trim glen
dawn wagon
#

Why does the bot not answer me. Theres no error

#

But like this it works

split vortex
#

Is there a way to edit a embed field instead of just adding a new one with changed information?

dawn wagon
#

And like this it also doesnt work

#

But why D:::

#

And like this is also doesnt workkkk AHGRHGRHG plss hellppp :C

half marsh
steady lotus
#

for pages, if i run the same command twice after each other, the buttons for the first command dont respond, i get discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message instead

dawn wagon
half marsh
#

you were looping through online var which a value return from guild members

dawn wagon
#

hΓΆ

#

?

#

im dumb

#

xd

#

i dont get what you mean

graceful robin
#

Slash command doesn't register

It worked before but now I put it in a cog and it doesn't work, everything else in that cog works

#

help

forest talon
dawn wagon
dawn wagon
#

thats the problem xd

graceful robin
#

ah ik what happened

#

discord.Status.offline doesnt work for some reason

dawn wagon
#

but why lol

graceful robin
#

dunno

dawn wagon
#

that cant be the case

graceful robin
#

I heard that there is a new format

dawn wagon
#

Like this it works

#

But i only wanna see online USERS not BOTS

graceful robin
#

you know

#

you can just make one loop

dawn wagon
#

but how

graceful robin
#

look

#
for i in online:
  if i.status == discord.Status.offline:
    online.remove(i)
  elif i.bot:
    online.remove(i)
#

do this

crimson gale
#

cant you just do a list comprehension again?

#

infact you could easily condense all this to list comprehension

forest talon
#

users = len([user for user in ctx.guild.members if not user.bot and user.status != discord.Status.offline])

crimson gale
#

improper list comprehension

forest talon
#

sorry put brackets in

crimson gale
#

^

forest talon
#

len([])

forest talon
#

I’m on mobile it’s kinda difficult

graceful robin
#

Slash command doesn't register

It worked before but now I put it in a cog and it doesn't work, everything else in that cog works
(the warn command)

forest talon
#

in some functions you don’t need brackets necessarily

dawn wagon
#

No bruh nevermind

#

Still doesnt work

crimson gale
#

dunno

forest talon
#

it gets the number of non-bot members that are not offline

#

bro I cannot type correctly

dawn wagon
#

like this

#

It still doesnt work

#

though

forest talon
#

what error are you getting

#

or what’s the result of the command

#

wait you put brackets after len

vivid nacelle
#

I hope you all behave πŸ‘€

forest talon
#

it’s len() not len[()]

forest talon
dawn wagon
#

Still doesnt work lol

forest talon
#

does it give you an error in the console

dawn wagon
#

Nope

forest talon
#

so the command works? but just not giving the correct number

#

or does it not work at all

dawn wagon
#

Doesnt work at all

#
@commands.command()
    async def serverinfo(self, ctx):
        botcount = [bot.mention for bot in ctx.guild.members if bot.bot]
        online = len(user for user in ctx.guild.members if not user.bot and user.status != discord.Status.offline)

        # Define embed
        embed = discord.Embed(title=f"Serverinformation ⟢ {ctx.guild.name}",
                                      description=f"Heres all the Information about this Server ({ctx.guild.name}).",
                                      color=0xa0522d)
        embed.add_field(name='Created On β–Ό', value=ctx.guild.created_at.strftime("%d. %B %Y at %H:%M"), inline=False)
        embed.add_field(name='Owner β–Ό', value=f"{ctx.guild.owner.mention}", inline=False)
        members = 0
        for member in ctx.guild.members:
            if not member.bot:
                members += 1
        embed.add_field(name='Members β–Ό', value=f'{members} Members | {online} Online | {len(botcount)} Bots', inline=False)
        embed.add_field(name='Role Count β–Ό', value=f'{len(ctx.message.guild.roles)} Roles')
        embed.add_field(name='Channels β–Ό',
                        value=f'{len(ctx.guild.text_channels)} Text | {len(ctx.guild.voice_channels)} Voice | {len(ctx.guild.categories)} Categories',
                        inline=False)
        guild_invite = await ctx.channel.create_invite()
        embed.add_field(name='Server ID β–Ό', value=f"{ctx.guild.id}", inline=False)
        embed.add_field(name='Invite β–Ό', value=f"[Here]({guild_invite}) is the server invite", inline=False)
        embed.set_thumbnail(url=str(ctx.guild.icon.url)),

        x = datetime.datetime.now()
        embed.set_footer(text='Send by AKIRU β€’ {}'.format(x.strftime("%d/%m/%Y at %H:%M")))

        #Send Embed
        await ctx.send(embed=embed)
#

Theres the whole code

forest talon
#

try putting brackets after the opening parentheses

#

and closing parentheses

#

of len()

#

so len([ ])

half marsh
#

Just like how you define your botcount

forest talon
#

you do need the brackets I just couldn’t test it

dawn wagon
#

like this

#

?

forest talon
#

yeah

dawn wagon
#

YEA FINALY
THANK YOU :D

forest talon
#

lets gooo np

slender lintel
#

Hi, how can I get the author of my interaction

#

It is a button

#

becuase interaction.author doesnt work

forest talon
#

interaction.user

slender lintel
#

ok

#

lemme try

#

ye works now

#

πŸ™‚

knotty niche
#

Ok, so this when i try to send the line to be printed with await ctx.send(line), it keeps showing an error but if i print the line it in fact shows that it is filled with something. Can someone help

half marsh
#

But for your problem you havent set your line variable

slender lintel
#

Ok so i have a question about the possibilities of BUTTONS, can i embed a .pdf file into a button so that when a person clicks the button they download the pdf

knotty niche
forest talon
supple ravineBOT
#

Here's the tic tac toe example.

half marsh
slender lintel
#

yeah i knew about the links and so on but i though about downloading it

#

@discord.ui.button(
TypeError: button() got an unexpected keyword argument 'url'

sudden path
#

Url buttons don't have a callback. So you don't create them with a decorator

knotty niche
slender lintel
#

Hi just wanted to ask is it possible to combine ephemeral=True with delete_after?

crimson gale
slender lintel
#

is it possible to send stickers in pycord

#
newbot(user=interaction.user)
somewhere in newbot:
print(f"[+] Client Being Started By: {user.name}#{user.discriminator}")
#

<class 'AttributeError'> main.py 287
'str' object has no attribute 'name'

#

how do i disable this permenant "hoi4 bot is thinking" shit

slender lintel
#

This works for only 1 button, how do i expand this to work for 2 buttons

forest talon
graceful robin
#

slash command doesn't register

It worked before but now I put it in a cog and it doesn't work, everything else in that cog works
(the warn command)

no errors

slow dome
#

p.tag idw

supple ravineBOT
# slow dome p.tag idw

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

graceful robin
slow dome
graceful robin
#

everything else in that cog works

#
if __name__ == "__main__":
    for filename in os.listdir("./cogs"):
        if filename.endswith(".py"):
            client.load_extension("cogs." + filename[:-3])
slow dome
#

so which one doesn't work

graceful robin
#

the warn command

#

its really weird

slow dome
#

you can't have two functions with the same name

#

because the later one overrites the other

graceful robin
#

I swear that I called the other one warnings 😳

#

Thanks

slow dome
#

np

slender lintel
#

What are pages extension used for?

slow dome
slender lintel
slow dome
#

uhh they are buttons, but basically

#

yes

slender lintel
#

@slow dome

slender lintel
#

@slow dome
I want something like this (Obviously this is just an example from another bot so you understand)

#

and it edits the embed

#

Is there any examples on the repo?

#

anyone?

sudden path
#

Why don't you just create a dropdown and edit the message depending on the choice

#

Group pages are to store multiple pages aka embeds in a category

slender lintel
#

@sudden path

sudden path
#

You already mentioned me once

slender lintel
#

i switched it off now

sudden path
#
if self.values[0] == "something":
   ...```
slender lintel
sudden path
#

self.values returns a list

slender lintel
sudden path
#

I just told you

steep bluff
#

Is there a way to loop through all @tasks.loop() tasks of my discord bot?

frigid lark
#

@slender lintel do you know the basicΒ΄s of python?

slender lintel
#
if self.values[0] == "straberry":
   await interaction.response.send_message("Hey")```
#

would this work?

frigid lark
slender lintel
#

is this right?

frigid lark
#

try it

#

and you will see

slender lintel
#

ook

old plover
#

you spelled both "strawberry" and "chocolate" very wrong

slender lintel
slender lintel
#

I tried only 0s

sudden path
#

You only do it with 0

#

self.values will always return a list with one element if the max is 1

#

And you don't indent elif statements.

#

This is basic python.

slender lintel
#

I can do most stuff fine in pycord smh

#

just not selectmenus

sudden path
#

If statements are basic python.

#

And doesn't look like you know how to use them.

old plover
#

I wonder if a switch would make sense there

slender lintel
south ermine
#

And discord (or they) trimmed the whitespace from the first line

old plover
#
match self.values[0]:
  case "Vanilla":
    ...
  case "Chocolate":
    ...
  case "Strawberry":
    ...
#

That's a match case statement

#

new in Python 3.10

frigid lark
slender lintel
#

isnt the default for match statements just case _:?

slender lintel
#

would self.options work?

old plover
#

it'd be select.values

#

no

#

select.values

slender lintel
old plover
#

That's good