#General Help
1 messages Β· Page 25 of 1
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
@tropic fractal do you know how id do this?
not really, they have a guide on how to switch over
Not without looking at your code, I'm currently doing some upgrades to my own bot atm so can't really do that
not when migrating but once you've written a bot in it it is fairly streamlined
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
i've had major bugs in pycord, but they've been fixed after i pointed them out
did they just get banned-
this
apparently so
I had a fatal bug fixed within minutes of reporting it
sadly I dot have the time to migrate atm
real programming
at the end of the day, just use the library you want
@fiery tapir ?
plus who's pulling from git anyway? 2.0.0rc1 has very few or no bugs that I've encountered
it don't matter
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)
i never said that
i hope not
o
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
if it does im moving to programming in Haskell so I can suffer endless pain
Did krittick just leave the server
what libraries have you used?
#883236900171816970 apparently they got banned
yeah
he's here
No.
they did
alr
Why did kidstrick guy leave
#989958162100666398 anyone?
this'll be over in a day
this is so weird
i would like to help but i didn't even know modals were implemented yet, apologies
i came here to get help on interactions and modals and i see this T_T
π€£
What libraries have you used?
dpy, hikari, nextcord, and pycord
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
Oh lol
so literally all forks. ok.
I was like 'nah i'm good I aint dealing with that shit no ty'
lmao
dpy isnt a fork ;)
semantics.
nope - hikari is completely different, although i hated their approach to it and the complexity, so i went for a fork instead
#989958162100666398 if anyone can help, would be appreciated!
dpy pre-suicide was actually really nice, and i'd rather that over a horrible implementation of the same thing
You haven't tried NAFF, disnek etc.
I tried moving to dpy yesterday, Way too much to learn and change in my code
after the forks era, now its just what you prefer for slash commands
so went back to here
dpy impl of slash cmds is funky as shit
agreed
@slash_command(name, description, scope, permission)
async def _something(self, ctx: InteractionContext):
code
whats wrong with it
nothing close to that.
well the whole tree thing is a bit weird
yh
never really looked into it too much since i dont use dpy
dpy right now is like linux when compared to windows as pycord... its super complicated and possibly better for certain things and fine control, but highly unnecessary to do all the extra steps
ahem, linux/gnu
The Support is faster, The actual lib is rly bad
dpy community is a shit show to say the least
like i cant think of a single reason you want to restart a bot without registering commands - and pycord supports that too
i've said this statement before
but dpy makes you explicitly register every command
although they dont explain stuff very well, they are straight to the point and that aint good
iirc
its not too difficult to understand
maybe it isn't if you get used to it, but coming from pycord I don't see why they did it that way
Β―_(γ)_/Β―
yep the pycord community is amazing and so helpful
another reason im sticking to pycord
yeah
speaking of other libs
#989958162100666398
huh?
anyone?
like slash cmd names from different languages
ohhh you mean how they let you define it
i can try and help but i don't make any guarantees
@rapid pawn
?
alr (Im asking alot cos i've been tryna sort it all for like 3 days)
even if someone tries to help its appreciated :D
well ig ill bump my qn too... #989956142757203988
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
I dont think telling people about naff is allowed to be done in a competitor server
|| but check my bio lmao ||
self promotion isn't allowed
The 'database' one was for something else
i dont think so at least
you know what naff means in british?
the name stand for "not another freaking fork"
but what does it mean π
lmao i see
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 ?
send the full traceback
thats the full trace back
it just... stops right there?
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]
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
your pip list should show py-cord but not discord or discord.py
if that's true it should work
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
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.
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
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)
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'
bot.add_view
Use persistent views
Wrong pycord version
an example is possible?
?tag install
-
Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y -
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
aah
Here's the persistent example.
@quartz snow
Fixed this yesterday, just letting you know, my bad, my mistake
You've got multiple pycord versions installed for what i see
Oh wait you got it fixed
sorry for ping
can you disable a button based on roles ? like the same button is disables for on but other can use it
not to my knowledge, though you can do effectively the same thing by just checking their role after they press the button
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?
why does this print error
you can figure out by
except Exception as e:
print("error is", str(e))
How I get Pyncal?
pip install PyNaCL I believe
yeah ty
all good im glad people wanna help Xd
What would i use to ignore bots in this command? /membercount
I am using
{ctx.guild.member_count}
rn
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?
@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?
I think you want an event?
@commands.Cog.listener
async def on_interaction
thanks
I presume hardly anyone knows how to use dynamic cooldown?
how do i fix this ?
presumably matrix is an asynchronus function call
can you show where you initialize MATRIX?
...show me readfromfile?
also why do you have an await after the equals in DAYS
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
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
it says this
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)
okey then ill do that Xd
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
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
i mean it's just doing what you asked it to...
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
cause i used old discord.py
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
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?
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
this is a separate file that is imported into another
oh shoot sorry !
yes... and it still works
try it if you don't believe me
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
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
TypeError: Messageable.send() got an unexpected keyword argument 'embeds'
Hi All, I'm trying to use TextChannel.send with a list of Embeds. Per documentation (https://docs.pycord.dev/en/master/api.html#discord.TextChannel.send ) this should work in v2.
I'm using: py-cord 2.0.0rc1
Any ideas?
send code.
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
?tag discord.utils.
No tag discord.utils. found.
b!rtfm pyc discord.utls
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
you can add their ids to the list and then fetch them when you want to send it
yes thats what i want
ok so what do you need?
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
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
eh
b!rtfm pyc ext.tasks
discord.ext.tasks.Loop
discord.ext.tasks.Loop.__call__
discord.ext.tasks.Loop.add_exception_type
discord.ext.tasks.Loop.after_loop
discord.ext.tasks.Loop.before_loop
discord.ext.tasks.Loop.cancel
discord.ext.tasks.Loop.change_interval
discord.ext.tasks.Loop.clear_exception_types
discord.ext.tasks.Loop.current_loop
discord.ext.tasks.Loop.error
should just default to pycord tbh
Xd true Xd
suggested
okey so i should use a loop
yeah
lets see if i can make that work
you got this
never really used loops that much Xd
list.append(ctx.author)
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
a datetime.datetime object
this should get the list then send a message and delete the first name in the list after it sended the name
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 ?
.
so do something like
await ctx.respond(f"{member.id} {discord.utils.format_dt(stuff here)}")
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
Anyone know what this is erroring
vc = await message.author.voice.channel
That's correct
hmm then wierd its not working
Code?
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
You should use the commands module instead of an on_message event from what it looks like.
b!rtfm pyc discord.extcommands
discord.ext.commands.ArgumentParsingError
discord.ext.commands.AutoShardedBot
discord.ext.commands.BadArgument
discord.ext.commands.BadBoolArgument
discord.ext.commands.BadBoolArgument.argument
discord.ext.commands.BadColourArgument
discord.ext.commands.BadColourArgument.argument
discord.ext.commands.BadFlagArgument
discord.ext.commands.BadFlagArgument.flag
discord.ext.commands.BadInviteArgument
Anyone know why this doesn't work
?tag message-content
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
Where would I put this
intents = discord.Intents.default()
intents.message_content = True
bot = discord.Bot(intents=intents)
where you define your bot, but put commands.Bot instead of discord.Bot
-
Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y -
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
the last line
and use @client.command instead of @commands.command
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
No that doesn't fix it
asyncio.gather(*coros)
I have no idea what apple thought that was
so add every single coroutine in a list and then do await asyncio.gather(*listname)
any simple examples
list will have the server ids right , or function calls ?
function calls
coros = [ctx.send(ββ), ctx.author.send(ββ), ctx.edit(ββ)]
await asyncio.gather(*coros)
itβs an example, but idk why you would do that
await asyncio.sleep(1)
return value.upper()
coroutines = [
upper_cased("h"),
upper_cased("e"),
upper_cased("l"),
]
print("".join(await asyncio.gather(*coroutines)))```
more like this
does that work?
checking
I think itβs something about futures
No, you use cogs.
can you give me an example?
thank you very much
How to use discord api
Like i didn't get it
Here's the background task asyncio example.
What?
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?
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
when member joins dont send that message
- You need to use on_member_join
- You can make a variable and Set it to true or false and check if the variable is true or false before you send the message
oh ok thanks
b!rtfm pyc on_member_join
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
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
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 ?
Its possible to show it to members with specific permissions
any idea how ?
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_perms.py at master Β· Pycord-Development/pycord
but this is about usage
not actually seeing it
?
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
um, no one knows?
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")
@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?
remove *args
simple
e
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
How can i make it so the option is either attachment or string
but only one of those 2
h
i fixed my issue probably: (https://stackoverflow.com/a/71170114/15814436)
good luck everyone
why are you refering to your own lol
to show it?
in normal discords no but this is a help channel then they mostly do
what i always do is ask my question then wait
ok well we are just flooding our own questions so lets not
What does this mean?
code?
you may ignore it safely. upgrade to make it go away
How do I upgrade it?
pip install -U py-cord==2.0.0rc1
ty
What would i use to ignore bots here? I use
{ctx.guild.member_count}
right now
list comprehension of guild.members with condition not member.bot then grab the len() of it
So this?
len({ctx.guild.member_count})
read the full sentence
I dont understand it all
then you should do something else for your project
have you ever seen list comprehension?
nope lol
thanks
it says Requirement already satisfied
pip list
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
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
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
uninstall discord.py and py-cord then reinstall py-cord
The
await ctx?
everything except the first for loop
also there would be a better way to format this whole thing without sending multiple messages per guild
How?
string manipulation lol
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.
its completely wrong. i did not ask you to do that
canβt find how in docs
Could you give an example?
pip uninstall
i linked you to the place where you can learn list comprehension and you opted to do this
pip uninstall discord.py
pip uninstall py-cord==2.0.0rc1
pip install py-cord==2.0.0rc1
you dont need to specify version number when uninstalling
@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)```
Oh nice to know lol
swear to god if this is wrong π
i read the w3schoools again
this isnt even list comprehension my guy
litearly reading this..
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
@slash_command(name="membercount", description="Member Count")
async def membercount(self, ctx,):
guild = [for guild in self.bot.guilds for member in guild.members]
await ctx.respond(guild)```
the first for loop is better used outside of that list comprehension
because you want per guild member counts
im so confused, sorry..
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
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
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
soo?
await ctx.respond(len()(guild)))
i just showed the singiluar line
guild is not a list
wait it is but why have you named it guild?
eh whatever
show me the current code again please?
@slash_command(name="membercount", description="Member Count")
async def membercount(self, ctx,):
for guild in self.bot.guilds:
guild = [for member in guild.members]
await ctx.respond(guild)```
you didnt even add the condition for the list comprehension that you wanted
you wanted it to exclude bots no?
Yeah i wanna exclude bots, i thought len did that
len just counts the elements in an iterable
oh, so what would exclude bots
adding the condition not member.bot in the list comprehension
@slash_command(name="membercount", description="Member Count")
async def membercount(self, ctx,):
for guild in self.bot.guilds:
guild = [for member in guild.members if not member.bot]
await ctx.respond(guild)```
is this the correct code
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
guild = [member for member in guild.members if not member.bot]```
yes
is this finaly correct?
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
what about members =
what?
Your saying my variable name is weird right
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
for guilds in self.bot.guilds:
membercount = [member for member in membercount.members if not member.bot]
await ctx.respond(len()membercount)```
its a function man
why is it outside?
um
now we need to fix the list comprehension again
Sorry.. where would i put len?
its not a question of where you should put it but what you put in its arguments
o
i thought i had fixed that
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?
Not at pc
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
how to make a command which work on both slash command and perfix
Whatβs the event called when my bot joins a server?
I think youβd have to use bridge commands
i recommended looking them up in docs
`bot = commands.Bot(command_prefix="!")
@bot.event
async def on_ready():
print(f"{bot.user} is ready!")`
i want to disable a button in a view but the button that is clicked will not be the button to be disabled
code
durimg callback
run through self.children
for help commands, i get the context invocation through self.context right?
compare the child.label not the button interacted and disable
in rc1 there is a method that disables all children of the view
i don't think he wants all of em disabled
Child.label?
Can you give 1 example?
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
discord.Bot
thank you
Please send an example of how it should work
class discord.ScheduledEventLocation
discord.ScheduledEventLocation(value="StageChannel")?
Why dont you just try it yourself
BOY. You're so fast with links
because i was already looking at it when you posted that
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
but why is discord.py always installing?
!replit
Read this to find out how you can install Pycord in replit - https://namantech.me/pycord/installation/#replit
How to install the Py-cord library - Pycord Guide
thanks
I fiured this line is resulting it to none
m = self.bot.get_message(m_id)
But cant figure out how id fix it?
If it returns None then the message is not cached.
Oh wait i see my issue after you saying this, I used a suggestion that was made before i stored in db
I am now using an ID that is 100% stored in my database, a message that isnt deleted or anything and it isnt working? (same error)
ModuleNotFoundError: No module named 'discord.abc'
man
I said the message is not cached not that it was deleted(?
Yeah, I thought you meant the ID isnt stored, what do you mean
The message is not in the bots cache.
How do i fix that?
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
b!rtfm pyc fetch_message
discord.User.fetch_message
discord.Member.fetch_message
discord.Thread.fetch_message
discord.Webhook.fetch_message
discord.DMChannel.fetch_message
discord.SyncWebhook.fetch_message
discord.TextChannel.fetch_message
discord.GroupChannel.fetch_message
discord.VoiceChannel.fetch_message
discord.abc.Messageable.fetch_message
Alright thanks
Theres member fetch and channel.. i assume its channel then?
Try it and see β¨
m = await discord.TextChannel.fetch_message(m_id)``` Required arg id but i changed m_id to id and same error
Have you realised you need a Discord.TextChannel instance/object
Wym?
Discord.TextChannel is the whole class
You need an instance of that class
You need to get a channel instance
yes
@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?
well you need to use the channel reference that you just got
youre still using the class definition
so like discord.Channel.fetch_message since its named channel =
go learn oop
you need to learn the difference between a class and an instance
Its np now I got it to work
So if i am understanding correcttly, I need to create a new class and put the instance in the init
that is the exact opposite of what you need to do
@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?
'to create instances of a class, you call the class using class name and pass in whatever arguments its init method accepts.'
Instead of the init
Can you provide a tutoital on where i can learn about this
learn what?
OOP
is it not possible to respond with a sticker after a slash command
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!)
Why
member = "members"
You're cresting an unnecessary variable
membercount is also unnecessary
Im just using the variables to send the message bruh
It works thats all i need
You can type it inside the respond? Lmao
I did try that (Obviously) but it didnt work, i tried again now and it worked i cant renember what i had done before lol
@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')```
:)
@bot.slash_command(description="Give me image.")
@option("image", Union[str, discord.Attachment], description="Image file/url")
async def img(ctx, image: Union[str, discord.Attachment] = None):
...
TypeError: Invalid usage of typing.Union
but why? just like https://github.com/Pycord-Development/pycord/blob/a7e08f8b77e2ef1938791b3f304ad02de10be53b/examples/app_commands/slash_options.py#L38 no?
examples/app_commands/slash_options.py line 38
Union[discord.TextChannel, discord.VoiceChannel],```
what even is an invalid usage, google didnt really help
@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?
Do you even know what invaild means
yeah. tell me whats invalid over there compared to the example code in github maybe?
embeds wants a sequence
Wym
You pass a sequence of embeds
use either embed or put info into a list
So embed =
Or
. _. how have you been sending embeds normally.
The other embds I do work fine lol, probably me just forgetting smth
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
I don't think this can work?
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
Slash commands don't have unions at the moment
you probably want two separate options / subcommands
Oh, It was embeds it should have been embed
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
round
oh
{round.self.bot.latency}")
How would i use round
Its a function
Oh alr
anyone can help in #990240354802479175?
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)
Does anyone know what the problem is and how I can edit the image?
I see, thanks for info and spending time. Looks like i will add 2 seperate options and if both are present i will have to prioritize one...
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)
hmmm, I guess make the on_message a command itself by...
await bot.process_commands(message)
um tbh idk i found it on goggle
from what I've heard
think its to do with 2.0.0b5 of pycord and above
on_message makes it the priority and removes the other commands from processing
something around those lines))))
@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`.
try printing message.embeds
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() ...?
Can you default "allowed_mentions" to none() for all sends?
You can do it when setting your bot instance
that makes a lot of sense actually thank you
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
I Got it smh
this is not true if i use interaction.followup.send() instead.
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
update python
im using PyCord
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
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
you cant delete an ephemeral message
They said update python.
hey
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?
in a slash command how do you turn a bunch of mentions into a list ?
something like this
Ig he's new dev who just jumped on discord bots
guys how can i add my bot for testing?
You should add your bot to your own private server for testing, to add a bot here you need to boost the server or be a contributer #883237067923005471
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)
hi everyone how to use slash_command permission
How do i split these roles so its like:
Role1
Role2
Role3
...
Bc now its like this: Role1 Role2 Role3
instead of space use \n
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?
You're starting the bot before it is ready so the channel isn't cached.
how can i fix that?
how can I get a list with messages from all channels?
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```
THANK YOU SO MUCH
no i mean here
np :D
How can I make it so that you can click the button only once?
Any ideas on how to hide args in a slash command?
Remove it
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
guys how to disable a button after interaction
Maybe edit the message but set the parameter for the button to None?
I know barely anything about interactions
Well, I need it
have you subclassed the view thing?
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...
no
watch from here: https://youtu.be/kNUuYEWGOxA?t=1111
How can I make a space between the name and the value?
\n
i did use \n but it didn't work
would it be like this?
yep
I did use it like that however it didn't put spacing in
how do i revenrt back to an older pycord version? My bot was working fine until i updated it to the recent patch
πΏ
using prefixed commands?
where the green line is there's no spacing coming π
try adding \u200B before the new line character
ohh that's because embed removes any unneccessary spacing
Joksulaine do you know how can i revert back to an older version?
awesome thanks!
are you using prefixed commands?
yeah
have you provided the necessary intents for those to work?
intents?
?tag 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)
my bot was working fine with slash but when i reverted back to prefixed , it doesn't work at all
well did you provide the intents?
no
alright just to be clear , prefix commands are like ! or . or -? right
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
done
you managed to fix it?
nope still not working
code?
I am regretting my decision to even go to slash commands in the first place
wait a sec
you have unnecessary code
for setting the intents
what intents do you need right now?
I never have had to use intents before this
so I am oblivious to the concept as a whole
well nows a good time to learn
good practice is to turn on the intents you need
not all at once
Hmmm
also are you getting an error when you start the bot?
Nope not a single error
so you have all the privileged intents turned on then
yeah but i just need the bot to message content
okay
it still doesn't work
it doesn't even respond to any commands and stuff
neither does it show an error
in cog
@discord.command()
async def test(self, ctx):
pass
why is the command not working? using the prefix
intents?
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), intents=intents)```
add message_content intent
bruh
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
client = commands.Bot(prefix="!", intents=intents)In this line it should have been command_prefix
bro ty

My bot is Killed
ty for the help man
Is there a way to edit a embed field instead of just adding a new one with changed information?
And like this it also doesnt work
But why D:::
And like this is also doesnt workkkk AHGRHGRHG plss hellppp :C
Online is a list π
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
wdym
On you if statement
you were looping through online var which a value return from guild members
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
what error are you getting
@half marsh
but why lol
dunno
that cant be the case
I heard that there is a new format
but how
look
for i in online:
if i.status == discord.Status.offline:
online.remove(i)
elif i.bot:
online.remove(i)
do this
cant you just do a list comprehension again?
infact you could easily condense all this to list comprehension
users = len([user for user in ctx.guild.members if not user.bot and user.status != discord.Status.offline])
improper list comprehension
sorry put brackets in
^
len([])
Thanks it works now
Iβm on mobile itβs kinda difficult
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)
wait wouldnβt it work though
in some functions you donβt need brackets necessarily
dunno
try what I posted
it gets the number of non-bot members that are not offline
bro I cannot type correctly
what error are you getting
or whatβs the result of the command
wait you put brackets after len
I hope you all behave π
itβs len() not len[()]
π§ββοΈ
Still doesnt work lol
does it give you an error in the console
Nope
so the command works? but just not giving the correct number
or does it not work at all
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
try putting brackets after the opening parentheses
and closing parentheses
of len()
so len([ ])
Just like how you define your botcount
you do need the brackets I just couldnβt test it
yeah
YEA FINALY
THANK YOU :D
lets gooo np
Hi, how can I get the author of my interaction
It is a button
becuase interaction.author doesnt work
interaction.user
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
I suggest you to not using a global variable as it can conflicting each other
But for your problem you havent set your line variable
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
hmmm is that so
ty
if you mean direct download then probably not, but if you have a url for it you can just add an outgoing link button
Here's the tic tac toe example.
Veri kuul example
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'

Haha funny π
Url buttons don't have a callback. So you don't create them with a decorator
i finally got it ty
Hi just wanted to ask is it possible to combine ephemeral=True with delete_after?
It isn't ig
Try once
it is not possible since an ephemeral message isnt a message
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
instead of ctx.send hi make it ctx.respond
This works for only 1 button, how do i expand this to work for 2 buttons
maybe you set user to a different value somewhere
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
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.
how are you loading the cogs
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])
so which one doesn't work
you can't have two functions with the same name
because the later one overrites the other
np
What are pages extension used for?
Click button to navigate through pages
So would it work as like a select menu, then it changes the embed
https://docs.pycord.dev/en/master/ext/pages/index.html#paginatormenu would this be what im looking for
@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?
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
Thats where i had the issue, I was struggling to edit it depending on the choice cause all i saw on the examples were
but i cant see where thats indicating what option do respond to
@sudden path
You already mentioned me once
oh sorry i didnt notice i had reply ping on
i switched it off now
if self.values[0] == "something":
...```
What is the [0] meaning
self.values returns a list
await interaction.response.send_message(f"Hey")``` This is what im tryna say, How would i have different responses per option
I just told you
Is there a way to loop through all @tasks.loop() tasks of my discord bot?
@slender lintel do you know the basicΒ΄s of python?
yes, im looking at what he said
if self.values[0] == "straberry":
await interaction.response.send_message("Hey")```
would this work?
That is basic if, elif statement
Yeah so.. this?
if self.values[0] == "straberry":
await interaction.response.send_message("Hey")
elif select.values[0] == "Choclate":
await interaction.response.send_message("Hello")```
is this right?
ook
you spelled both "strawberry" and "chocolate" very wrong
yes i know, π i just ended up copy and pasting them xDD
What am i doing wrong here? error: interaction failed
code:
if self.values[0] == "Vanilla":
await interaction.response.send_message("e")
elif select.values[1] == "Chocolate":
await interaction.response.send_message("Helo")
elif select.values[2] == "Strawberry":
await interaction.response.send_message("Hello")```
I tried only 0s
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.
I wonder if a switch would make sense there
?
It's just how the indentation looks when they copied from their editor
And discord (or they) trimmed the whitespace from the first line
match self.values[0]:
case "Vanilla":
...
case "Chocolate":
...
case "Strawberry":
...
That's a match case statement
new in Python 3.10
I still use 3.8.5 ;3
isnt the default for match statements just case _:?
I keep getting 'MyView' object has no attribute 'values'
would self.options work?
Ah alright (Btw i am tryna understand this code too, not just copy and pasting as i gotta learn from it)
That's good
