#Basic Pycord Help (Quick Questions Only)
1 messages Β· Page 41 of 1
Lol
it is :P
OH LORD
but yeah, general
Any idea why message isn't ephemeral here?
talking random shi in here is an offense
You can ask Lala for a ban 
oh yeah
we forgo- gets banned
No or I'll cry if I get an error
The response from slash cmd isn't ephemeral?
Yea
okay that was the last one
some stuff is missing
Hm
It's like a normal message that everyone can see for some reason
like what
like a pc
No clue why :D
ah
us discussing our pain as jokes cuz we men (assuming)
makes sense
Ahh totally yes, and we abt to get banned
no cyap
nononono wait wait wait wait
general, now
do you defer the response before executing this code part?
you can't change the ephemeral state after the first response
discord/interactions.py line 595
async def defer(self, *, ephemeral: bool = False, invisible: bool = True) -> None:```
What does invisible do
Hm?
instead of just acking the button, it would send a "response" with thinking
it isn't important / used for slash commands
Ok
can some1 help with modals and select menus?
Im trying to get a modal to open when i click one of my selects
Refer to the docs or guide
Here's the modal dialogs example.
doesnt help is the guide done tried
Here's the dropdown example.
read both of the links
It should perfectly help
Hi! Quick question!
Question:
How can I pass a user as a parameter of a "slash command"?
What I've tried:
- on the discord -> /mycommand @mention_to_a_user
What I expect:
- An object as ctx.author where I can get info from like the nickname
What I got:
- @252222431411245151 (this is a random number but it is really close to what I got in the python code)
user: discord.Option(discord.Member, "Select a user")```
.rtfm discord.Option
is this like a converter?
Iβm pretty sure they get oauth info from their web and use that to check
OH! It's perfect thank you!
1)Override the callback function for the button
2) set self.disable = True
3)self.interaction.edit(view=your_view)
This is pycord help. Not "suspect about other bots code"
quickly need help with a close button a ticket bot, i have select menus to open them but when i close it, its just sends the transcript not deleting the channel
Cant help without code
I repeatedly get this error, discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'Embed' which I've never encountered before, any possible reasons?
Code
slightly long
import discord
from discord.ext import commands
import aiohttp
import json
class Verify(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.config = json.load(open("config.json", "r"))
@commands.slash_command(
name="verify",
description="Allows you to verify yourself using your Minecraft username."
)
async def verify(self, ctx, name: discord.Option(str, "In-Game Name", required=True)):
await ctx.defer()
async with aiohttp.ClientSession() as session:
try:
mojang_api = await(await session.get(f"https://api.mojang.com/users/profiles/minecraft/{name}")).json()
hypixel_api = await(await session.get(f"https://api.hypixel.net/player?key={self.config.get('hypixelAPIkey')}&uuid={mojang_api['id']}")).json()
except:
embed = discord.Embed(
title="An error has occured!", description = "", color=discord.Color.RED()
)
await ctx.respond(embed=embed)
return
if hypixel_api["success"] != True:
embed = discord.Embed(
title="An error has occured!", description = f"The reason for this error was:\n`{hypixel_api['cause']}`", color=discord.Color.RED()
)
else:
try:
discord = hypixel_api["player"]["socialMedia"]["links"]["DISCORD"]
if discord == (f"{ctx.author.name}#{ctx.author.discriminator}"):
embed = discord.Embed(
title="You have been verified!", description = f"Your account has now been linked with `{name}`", color=discord.Color.GREEN()
)
else:
embed = discord.Embed(
title = f"The linked discord is not you!", description = f"The linked discord is `{discord}`", color=discord.Color.RED()
)
except:
embed = discord.Embed(
title = "Unable to find a linked discord", description = "Please make sure you have linked your discord to your Hypixel account.\nIf this error persues, contact staff.", color=discord.Color.RED()
)
await ctx.respond(embed=embed)
def setup(bot):
bot.add_cog(Verify(bot))
chat wall W
def __init__(self):
super().__init__(timeout=None)
@discord.ui.select(
custom_id="support",
placeholder="Choose a Ticket option",
options=[
discord.SelectOption(
label="Premium Purchase",
emoji="π₯",
value="support3"
)
]
)
async def callback(self, select, interaction):
if "support1" in interaction.data['values']:
if interaction.channel.id == TICKET_CHANNEL:
guild = bot.get_guild(GUILD_ID)
for ticket in guild.channels:
if str(interaction.user.id) in ticket.name:
embed = discord.Embed(title=f"You can only open one Ticket!", description=f"Here is your opened Ticket --> {ticket.mention}", color=0xff0000)
await interaction.response.send_message(embed=embed, ephemeral=True)
return
category = bot.get_channel(CATEGORY_ID1)
ticket_channel = await guild.create_text_channel(f"ticket-{interaction.user.id}", category=category,
topic=f"Ticket from {interaction.user} \nUser-ID: {interaction.user.id}")
await ticket_channel.set_permissions(guild.get_role(TEAM_ROLE1), send_messages=True, read_messages=True, add_reactions=False,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True)
await ticket_channel.set_permissions(interaction.user, send_messages=True, read_messages=True, add_reactions=False,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True)
await ticket_channel.set_permissions(guild.default_role, send_messages=False, read_messages=False, view_channel=False)
embed = discord.Embed(description=f'Welcome {interaction.user.mention}!\n'
'Hello, How can we help you?',
color=0xe800ff)
await ticket_channel.send(embed=embed, view=TicketClose())
embed = discord.Embed(description=f'π¬ Ticket was Created! Look here --> {ticket_channel.mention}',
color=0xe800ff)
await interaction.response.send_message(embed=embed, ephemeral=True)
return ``` TICKET PART!
You've named some variable discord
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label='Close Ticket',
style=discord.ButtonStyle.red,
emoji='β³',)
async def button_callback(self, button, interaction):
if "ticket-" in interaction.channel.name:
channel - bot.get_channel(LOG_CHANNEL)
closed = interaction.channel.name
fileName = f"{interaction.channel.name}.txt"
with open(fileName, "w") as file:
async for msg in interaction.channel.history(limit=None, oldest_first=True):
file.write(f"{msg.author.display_name}: {msg.clean_content}\n")
embed = discord.Embed(
description=f'Ticket closes automatically in 5 seconds!',
color=0xe800ff)
embed2 = discord.Embed(title="Ticket Closed!", description=f"Ticket-Name: {closed}\n Closed-From: {ctx.author.display_name}\n Transcript: ", color=discord.colour.Color.orange())
file = discord.File(fileName)
await channel.send(embed=embed2)
await asyncio.sleep(1)
await channel.send(file=file)
await interaction.send(embed=embed)
await asyncio.sleep(5)
await interaction.channel.delete()``` close
And that overrides the library import
You shouldn't name your variables the same as a library's name
oh im a dumbass, thanks for opening my eyes
dark open ticket
dark close button
Do you get any errors or what doesn't work exactly
nope.
Hey! How can I get the object needed to mention someone from the context object? I was taking a look to https://docs.pycord.dev/en/stable/api/application_commands.html#context-objects but I don't find it... I only want to ctx.respond(mention)
hi, just want to confirm.. is it possible to create aliases for slash_command?
something like this...
@bot.slash_command(guild_ids=[xxxxx], aliases=['cp', 'close', 'end', 'stop'])
Just like that
Mention the command author?
ctx.author.mention as ctx.author returns a discord.Member object which has a mention attribute.
hi i have a question
oh thank you!
No
what is wrong in my code?
class MyModal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
@discord.ui.select(
custom_id="Propozycje",
placeholder="Jaka propozycje skladasz?",
options=[
discord.SelectOption(
label="Survival 1.19.2",
emoji="",
value="Propozycje"
)
]
)
async def callback(self, interaction: discord.Interaction):
if "Propozycje" in interaction.data['values']:
embed = discord.Embed(title="Modal Results")
embed.add_field(name="Short Input", value=self.children[0].value)
embed.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_modal(MyModal(title="esssa"))
@propozycje.command(description="Send in a channel the panel for opening tickets.")
@commands.has_permissions(administrator=True)
async def panel(self, ctx, channel: Option(discord.TextChannel, "gdzie ma byc wyslane"),
modal = MyModal()
await ctx.send_modal(modal)
await ctx.respond(f"Panel sent in {channel.mention}.", ephemeral=True)```
error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: __init__() missing 1 required keyword-only argument: 'title'```
idk why, i add the title
but i think not there
ok thanks!
You never passed a title on your super init or passed it as a kwarg when creating an instance
super(title="so?").init(timeout=None)
like this?
Title along with timeout
aa, thanks
is there anyway to run a function anytime a slash command is ran?
or do i have to add the function into every slash commands code?
Who tf pinged 
im sorry
@discord.ui.select(
custom_id="Propozycje",
placeholder="Jaka propozycje skladasz?",
options=[
discord.SelectOption(
label="Survival 1.19.2",
emoji="",
value="Propozycje")])
async def callback(self, interaction: discord.Interaction):
if "Propozycje" in interaction.data['values']:
embed = discord.Embed(title="Modal Results")
embed.add_field(name="Short Input", value=self.children[0].value)
embed.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_modal(MyModal(title="esssa"))```
can this work?
Om
You can have a workaround
.rtfm on_application_command
discord.Bot.on_application_command_auto_complete
discord.Bot.on_application_command_error
discord.AutoShardedBot.on_application_command_auto_complete
discord.AutoShardedBot.on_application_command_error
discord.on_application_command
discord.on_application_command_completion
discord.on_application_command_error
bridge.Bot.on_application_command_auto_complete
bridge.Bot.on_application_command_error
bridge.AutoShardedBot.on_application_command_auto_complete
bridge.AutoShardedBot.on_application_command_error
Bot.on_application_command_auto_complete
Bot.on_application_command_error
AutoShardedBot.on_application_command_auto_complete
AutoShardedBot.on_application_command_error
Add a listener for on_application_command_completion
And run your function
You can also do it by listening for on_application_command. But don't forget to process the app cmds if using that
now me
off topic but that means itβs not wick, wick never asks you to scan any QR codes
I think we'd rather be off topic than let some guy get his account compromised by scanning a qr code 

This is more about SQLite, but when you do a remove querry like this, does it lock the database in write while searching for a Guild to delete, or it will only lock the database while removing a Guild that it was found ?
database is only locked for different connections iirc
if the entire bot uses the same connection you're fine
oh but it does have multiple connections
Should i just use one connection for the hole bot and not open a new connection for each request in the database ( as I do now )
I am doing that for all requests
@Cog.listener()
async def on_raw_reaction_add(self, payload: RawReactionActionEvent):
if (
payload.message_id != self.role_message_id
or payload.user_id == self.bot.user.id
):
return
try:
role_id = self.emoji_to_role[payload.emoji]
except KeyError as e:
print(e)
return
guild = self.bot.get_guild(payload.guild_id)
role = guild.get_role(role_id)
if role is None or guild is None:
print(role, guild)
return print("ok")
for role in payload.member.roles:
print(role.name)
if role.id == 1045132418836865074:
return
try:
print("adding")
await payload.member.add_roles(role)
except Exception as e:
print(e)```
cant figure out why this is not working (reaction roles)
that print function is running (last fourth line)
your for role in ... is overriding the value of role
Is there a way you can provide extra blank lines between two fields in an embed?
Pretty sure no
But try adding a field with a blank name and value
Try with a single space too
I was thinking of doing that too, although I thought I'd run into an error saying I need to put some value there lol. Oh well, space should work since it's technically a value (I think). I'll try and let you know.
Or you can put extra new line characters \n\n at the end in the upper field
Follow new line character with a space or smth
There are also some characters called whitespace characters
https://qwerty.dev/whitespace/
Try these too
This also didn't work.
(Also tried with a space)
It says there's a value required, space isn't accepted as a value apparently.
Is bridge Commands are stable and good for production?
If it's in the stable version of pycord, it's of course going to be stable
And should it support all those things which available in normal Commands?
These also didn't work.
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'AddToQueueButton' object has no attribute 'to_components'
Hi can someone tell me why it says that?
Not if you don't show any code
import discord
from libs.discord_assets.modals import WaitlistModal
class AddToQueueButton(discord.ui.Button):
# def __init__(self):
# super().__init__(timeout=None)
@discord.ui.button(label="Enter Waitlist", style=discord.ButtonStyle.green, emoji="β")
async def button_callback(self, button, interaction):
await interaction.response.send_modal(WaitlistModal(title="Enter your email/username:"))
Why is the super init commented out?
import discord
class WaitlistModal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Enter your e-Mail:"))
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message(content=f"Successfully added **{self.children[0].value}** to the waitlist.")```
oh becuz its not yet ready for timeout=None
Well your button obviously won't work if you don't initialize the superclass..
oh
ok im stupid
i forgot how super init works π
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'AddToQueueButton' object has no attribute 'to_components'
but it still does say it
AttributeError: 'AddToQueueButton' object has no attribute 'to_components'
doesnt make sense
might be cuz of file name
doesnt matter
im stupid i forgot to use discord.ui.view
Try a blank png emoji
That should always work
Oh
https://cdn.discordapp.com/emojis/938021114481872936.png?size=1024&quality=lossless
In case anyone needs a link of a blank emoji
It tells me I can't have autocomplete with a list bigger than 25, any fixes for that?
Well its not broken
So there's no fix
why i have in a modal a error, but all work?
embed = discord.Embed(description=f"WiadomosΔ: {self.children[0].value}", color=0x428af5)
embed.set_author(name=interaction.user.display_name, url=f"https://discord.com/users/{interaction.user.id}", icon_url=interaction.user.display_avatar)
db = sqlite3.connect('main.db')
cursor = db.cursor()
cursor.execute(f"SELECT channel_id FROM propozycje WHERE guild_id = {interaction.guild.id}")
result = cursor.fetchone()
channel = interaction.client.get_channel(result[0])
msg = await channel.send(embeds=[embed])
await msg.add_reaction("")
await msg.add_reaction("")
await msg.add_reaction("")
await msg.create_thread(name="Komentarz", auto_archive_duration=60)```
Because you never responded to the interaction
a
get_member only works if the member is cached, use fetch_member instead
fetch_member is a coroutine
Yeah, reading the error helps
but thats per guild
like i can have 100 commands in one guild and 100 in another
yes
ok
I'm migrating discord-pyv2.0 to pycord latest version i have over 200 cmds which using hybrid_commands and those are in a cogs so should bridge Commands support cogs? Any example? And can i create bridge cmd using AutoShardedBot ??
But how can I use them in cogs ??
Just like you use anything else in a cog
Also what about sharding ??
use AutoShardedBot
Auto sharded bot with bridge cmd ??
yes?
Ig I'm disturbing you sorry for that, but im little bit confused
There is mentioned that bridge is a extension of pycord
And if i create Bridge Bot then i can able to create bridge cmd
Or i can include directly bridge cmd ??
Then how can I shard the bot ???
is bridge have AutoShardedBot?? Its own class
why did you send a friend request?
By mistake sry
np
I seen your name it's Indian so i see your profile that's why
yeah i am π
So bridge ext have a different AutoShardedBot Class ??
Iirc ??
Read the docs
Alr thnx it help me alot
And read #help-rules
It is broken
Traceback (most recent call last):
File "/home/einar/.local/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/home/einar/.local/lib/python3.10/site-packages/discord/bot.py", line 1045, in on_interaction
await self.process_application_commands(interaction)
File "/home/einar/.local/lib/python3.10/site-packages/discord/bot.py", line 726, in process_application_commands
await self.sync_commands()
File "/home/einar/.local/lib/python3.10/site-packages/discord/bot.py", line 629, in sync_commands
registered_commands = await self.register_commands(
File "/home/einar/.local/lib/python3.10/site-packages/discord/bot.py", line 529, in register_commands
registered = await register("bulk", data, _log=False)
File "/home/einar/.local/lib/python3.10/site-packages/discord/http.py", line 359, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 1.options.0.choices: Must be 25 or fewer in length.
In 9.options.0.choices: Must be 25 or fewer in length.
In 10.options.0.choices: Must be 25 or fewer in length.
The error tells you exactly what's wrong
Yeah it's too long...
So it isn't broken
I'm aware of that, I want it bigger. How do I make it bigger?
You can't
Alright
So you say its broken because it doesn't work the way you want it to
It says Must be reading the error message would show that you obv can't do it
I never said it initially, I just asked how to bypass or get around it aka fixes.
There's none
Then you used the word broken and I used it as well so it might be more understandable for ya
There's a limit
Just because an error message says I can't do it, doesn't mean I cant π
Yeah I realized
π what logic is that...
The error messages are made by people, it tells you what the error is and why it isn't possible and possibly what you've done wrong.
Sometimes the error message might trigger even though there's no error and similar odd case scenarios where they aren't accurate.
That's the logic mate
Tf
That is not at all how error messages work
Its literally a Discord limitation. The library works with discords limitations
Then please tell me
My soul is crying
Yeah and people made the Discord API, some bypasses might've been sending data in 2 rounds instead of one.
I don't know
That's why I asked
Errors are triggered because something went wrong when running your code
Library devs don't just give you an error for fun sometimes
Bypassing and misusing the API is against the developer tos
Yes, though something might go wrong even though there's nothing wrong.
Sure, if there's a bug within the library. But in this case it isn't
There's no bugs lmao from library side on this
If you didn't have more than 25 options and it still gave you the error, then yes, that would've been a bug. But in this case it's very clear that you are using too many options
I'm not saying there is, I'm saying it could've been.
There's limitations that you must abide by
Dude I understand that why y'all keep saying it to me
I just wondered and y'all be attacking me
Because you want to bypass it at all costs
Did I say "I want to bypass it at all costs"
I wondered if there was a way to have more, a bypass or something liek that
I mean. It looks like you want to bypass it at all costs because you kept insisting on it.
Insisting on?
It was literally "this is broken it doesn't let me have more than 25 options. Can I bypass it? This is broken. Let me bypass it. There could be a bypass or workaround because this is "broken" there must be a fix"
I never said that, now you're putting words in my mouth and that's just disrespectful
Am I?
I said I want it bigger, never said "Can I bypass it This is broken. Let me bypass it"
Am I?
You did say you wanted to bypass it or a work around
That's not "Let me bypass it"
I asked how, didn't say I wanted to bypass it
If you ask how, you want to
If you're going to quote me @full basin do it properly without changing the words and context
You don't ask just to know
Ahem
I asked how to get around it and how to bypass. Not that I wanted it
Dude y'all gotta read your own messages
You asking means you want to see if you can lmao
Even though "can" and "how" are not synonymous I never wanted to see if I can.
Y'all fr putting words in my mouth, then arguing over shit I didn't say.
I'm done with this shit, so just stop telling me how I as in ME meant something. You can't put different meanings into someone else's words.
fr
Basic Help (Quick questions only)
Hi there, I wanted to know how slash commands work (the whole path to sort of your bot receiving the request to the API processing it, and finally you getting the desired response from the bot).
I've noticed some bots respond faster to slash commands than others. What does that actually depend on?
This isn't really the right place to ask since PyCord is a wrapper for the Discord API. If you want to figure out how everything works behind the scenes you should read https://discord.com/developers/docs/getting-started
And the response time of a command typically depends on your latency between Discord's servers and your bot's server
Which is mostly dependant on network speed and the location of your server
The best location (from what I've seen) is anywhere in US West or US Central
And the speed of the command execution itself is also a factor, of course. If you're doing a bunch of heavy operations or network requests in your command, it's obviously going to take longer.
US East/Central is best
Discordβs servers are in Virginia
I see. Lastly, I just wanted to know if the processing work in the same way for both slash commands and prefix ones.
I mean, not entirely. Prefix commands is just your bot reading messages and executing code if the message contains a specific string. Slash commands are a lot more user friendly, and work differently as well since they need to be registered through Discord's API.
But if you're talking speed, there isn't going to be a difference
slash commands rely on Interactions dispatched by Discord while Prefixed are just bots sending messages in response to users.
Also using slash commands should theoritically have no problem with ratelimits, while prefixed do run into the ratelimit issue.
Ah, that makes much more sense than what I thought. Thank you for the information, I genuinely appreciate it.
slash commands are still ratelimited lol
Not really :/
Not like prefix commands
theoretically
class MyView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None) # timeout of the view must be set to None
@discord.ui.select(
placeholder="Czego dotyczy propozycja?",
min_values=0,
max_values=1,
options=[
discord.SelectOption(
label="Serwer(dc)", description="ZΕΓ³z propozycje dotyczΔ
ce Naszego Discorda!", emoji=":NearMC_logo:"
),
discord.SelectOption(
label="Survival 1.19.2", description="ZΕΓ³z propozycje dotyczΔ
ce Survivala!", emoji=":VestMC_GrassBlock:"
),
],
)```
why it dont work?
.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.
i dont have errors D:
Then explain how it doesn't work
or what doesn't work. What is your code doing and what is it supposed to do.
translation?
have you checked examples on how select menus are supposed to work?
Here's the dropdown example.
Why my bot not have the messages contents?
?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
But it's already activated
show code
I set them all to have an idea of ββwhich ones have
I need the messages contents for a event
If the messages intent is false, you will not receive any messages
How is the client class used.
To declare tidier
I don't know what that means
In 2.0.0 was work
I start the bot in a different way so I need it to look like this
I'll try the traditional way
Agin don`t work
Is there a version of discordpy that has the Bot Argument when running the bot?
This isn't discordpy
I don't know what that means
This is pycord tho
If I don't know what you are doing, I cannot help you.
@silver moat No have content message of members but have the message content of self
what
I just noticed that
discord rejects requests to their api whenever I use a user token
but for bots everything works fine
My bot doesn't have the centeude of messages from users only from itself
We will not help you
ok
Read the ToS of Discord
ya
Enable message content intents
It's already
In the developer portal?
Too
And your casing on the parameter in your super init is wrong
it's not supposed to be capital i on intents=
Now not even the intents it recognizes
?
what is the "problem" shown by your IDE
there is a light bulb. what does it say
Ways to change the code
I ordered to print the contents of the messages in the console but it prints empty
on the bottom of your IDE, do you see something like this? Can you click it and show me what pops up?
.
What is your current code?
It's only in this bot in this version, because I have another one that is working
I'm trying to find out what's wrong with your code. :)
Can I send a github link here?
yes
I'm uploading the latest code
just ping me after you sent it.
I'm Brazilian and some folders are in Portuguese
@silver moat
https://github.com/Marciel404/Markuus/blob/main/utils/loader.py#L20
should be
intents = intents,
utils/loader.py line 20
Intents = intents,```
bruh, that's literally what I said
nice
If I leave it with a lowercase "i" it doesn't even recognize the intents
it will
I don't know what error you are experiencing until you show me
I already told you, it doesn't show the content of the deleted message
Only when it's from the bot itself
you still didn't turn on message intent
https://docs.pycord.dev/en/master/intents.html
https://discord.com/developers/docs/topics/gateway#gateway-intents
import discord
from discord.ext import commands
# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content
intents = discord.Intents.default()
# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True # Required for prefix commands >= 2.0.0b5
# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()
# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
In version 1.5 comes the introduction of Intents. This is a radical change in how bots are written. An intent basically allows a bot to subscribe to specific buckets of events. The events that corr...
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
It should look like:
intents = discord.Intents(
bans = True,
guild = True,
....
)
``` when you are importing them
I fixed it, the "commands.Bot" is broken
I needed to use "from discord import Bot"
@silver moat
what?
Could you type pip list in terminal and send output.
^
???
@orchid grotto this
I have done
@orchid grotto do you know basic python?
that is not the full pip list
I've fixed it, you don't have to try to help me anymore
ok have a good day.
Well I built a whole bot system and a library
Too
The way you claim to have "fixed" it is not an issue with PyCord, which means you probably have conflicting libraries or some other issue
How I make it show all the options of an command option? Like this:
Here's the slash options example.
Hey! I'm just trying the commands feature on Pycord/Discord and I found that commands that I deleted from my bot can still be executed... How is that possible?
discord cache issue
Is there a way to clean the cache?
refresh your discord client
hmm ig discord api is being stupid again
try running an empty bot
which should de-register everything
and then try running your normal bot
Just tried... Didn't work either
Maybe I should just create a new bot(application)...?
just wait some time
So just one question, how do you test your bots?
yes that is the problem
that they are working hahaha
they shouldn't be working... I even deleted the pycache just to be sure
maybe reset your token
yw
k
hi, I'm trying to call the values defined on a separate file for @commands.has_any_role() but I can't seem to work?
this one works...
@commands.has_any_role('admin', 1234, 5678)
but not:
roles = ['admin', 1234, 5678]
...
@commands.has_any_role(roles)```
is there a way to achieve this?
Try *roles
hey this does not give any error also does not work can anyone help me out?
@client.event
async def on_message(message):
for x in c.staff_roles_name:
print(x)
if f"@{x}" in message.content:
await message.channel.send('You mentioned me!')```
Anybody want Calamari?
What is c and staff roles name
Send all relevant code
its config file which i imported
it has the role names in a list
@client.event
async def on_message(message):
if f"@aa" in message.content:
await message.channel.send('You mentioned me!')```
And see if the event is even fired
So the event is not fired
prolly
https://docs.pycord.dev/en/master/intents.html
https://discord.com/developers/docs/topics/gateway#gateway-intents
import discord
from discord.ext import commands
# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content
intents = discord.Intents.default()
# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True # Required for prefix commands >= 2.0.0b5
# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()
# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
In version 1.5 comes the introduction of Intents. This is a radical change in how bots are written. An intent basically allows a bot to subscribe to specific buckets of events. The events that corr...
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
You sure you got the required intents?
im not too familer with intents but i got
intents.members = True
intents.message_content = True```
Try with Intents.all()
ok
that didnt fix but the event fires it just isen't able to detect the ping
that i need to figure out, i tried with just aa and worked
Well mentions are <@id>
Try with the angled braces
ok
Trying to make a bot that can add roles through a dropdown menu, but I'm getting 403 Forbidden (error code: 50013): Missing Permissions. Is this an intents problem or something else?
it worked! thanks 
Haha np
It's a scope issue ig
Do you have the app cmds scope
I'll try that
In all the guilds your bot is
Still getting the same error unfortunately.
Does your bot have perms to add roles? And is your bot's highest role above the role you are trying to assign?
Nope, I did not. And now it works. Thank you!
AttributeError: 'NoneType' object has no attribute 'guild_permissions'```
Getting this error
```py
@client.event
async def on_message(message):
idd = str(message).split("<")[0].split(">")[0].split("@")
user = client.get_user(idd[0])
if user.guild_permissions.manage_messages:
for x in c.staff_roles_id:
print(x)
f = str(f'<@&{x}>')
g = str(message.content)
print(f'f: {f}, g: {g}')
if f in g:
em = discord.Embed(description=c.staff_ping_msg, color=discord.Colour.red(), timestamp=message.created_at)
await message.channel.send(message.author.mention, embed=em)```
i need to check if the user has manage_messages perms
im getting this error
AttributeError: 'method' object has no attribute '__discord_ui_model_type__'```
when doing this
```py
if "apple" in usable:
self.apple = discord.ui.button(label="Apple", style=discord.ButtonStyle.green)(self.apple)```
Why are you trying to call the button class?
use fetch_user instead, get_user only works if the user is cached
is there a way to make a message command that only works on specific users' messages?
as in, only shows up on their messages, not just checking who sent the message and sending an error if it's the wrong person
getting this now if user.guild_permissions.manage_messages: AttributeError: 'User' object has no attribute 'guild_permissions'
@client.event
async def on_message(message):
idd = str(message.content).removeprefix("<@").removesuffix(">")
print(message.content)
print(idd)
user = await client.fetch_user(idd)
if user.guild_permissions.manage_messages:
for x in c.staff_roles_id:
print(x)
f = str(f'<@&{x}>')
g = str(message.content)
print(f'f: {f}, g: {g}')
if f in g:
em = discord.Embed(description=c.staff_ping_msg, color=discord.Colour.red(), timestamp=message.created_at)
await message.channel.send(message.author.mention, embed=em)```
No worries
You need a Member object not a User object. Instead of client.fetch_user do message.guild.fetch_member
oh thank you!! that worked. also i had a question how do i make commands so that even after days or bot restart the dropdown menu works im trying to make an faq thing
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/persistent.py at master Β· Pycord-Development/pycord
See that
AttributeError: 'Interaction' object has no attribute 'send_message'```
getting this error, also is this the right way to sned ephemeral in interaction?
```py
@client.slash_command(name='faq')
async def prepare(ctx: commands.Context):
view = View()
select = Select(
placeholder='Select faq to get more info!',
options=[
discord.SelectOption(label='test', emoji=':CH_Heart:')])
async def callback(interaction: discord.Interaction):
await interaction.response.defer()
test_embed = discord.Embed(
description=f'skmaskmascm',
colour=discord.Colour.blue()
)
if select.values[0] == 'test':
await interaction.send_message(embed=test_embed, ephemeral=True)
view.add_item(select)
select.callback = callback
normal_embed = discord.Embed(
description='normal msg here',
colour=discord.Colour.blue()
)
await ctx.respond(embed=normal_embed, view=view)```
read the docs
Hi guys, somehow i cant get an task loop to work
@tasks.loop(seconds=5)
async def work(self):
print("klappt")
i tried a few things already like
self.work.start() -> in __init__() of the cog
work.start() -> somewhere in the cog
nothing at all, like in the first example https://guide.pycord.dev/extensions/tasks
This is just an poc, because i want to run a different function, but i cant even get this to work - what am i missing?
it tells you. learn to read error messages
I have a quick question.
How can you shard a bridge bot?
Hey, how do we get default discord profile picture of an user because when user has a default discord generated profile picture we get NoneType
this ^
.rtfm default_avatar
^member.display_avatar
Is this too much for the "quick question" Channel?
whats the diffrence in client n bot
?tag client
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
any ideas what might be the problem?
already tried removing the reason="..." part but got the same error
seems like a lib bug
great
could be already fixed in https://github.com/Pycord-Development/pycord/pull/1809 tho
π
Please put your code in a code block:
```py
Here is your Code
```
That makes reading code in Discord a lot easier:
print("This is an example.")
Ignoring exception in on_ready
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 743, in _load_from_module_spec
setup(self)
File "/home/container/.local/lib/python3.9/site-packages/jishaku/cog.py", line 70, in setup
bot.add_cog(Jishaku(bot=bot)) # type: ignore[reportUnusedCoroutine]
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 616, in add_cog
cog = cog._inject(self)
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 527, in _inject
raise e
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 521, in _inject
bot.add_command(command)
AttributeError: 'Bot' object has no attribute 'add_command'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "/home/container/main.py", line 15, in on_ready
bot.load_extension('jishaku')
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 867, in load_extension
self._load_from_module_spec(spec, name)
File "/home/container/.local/lib/python3.9/site-packages/discord/cog.py", line 748, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'jishaku' raised an error: AttributeError: 'Bot' object has no attribute 'add_command'```
uhm can someone explain this? I just trying to install https://github.com/Gorialis/jishaku
isnt thiss a question for a separate thread?
Idk
Basic Pycord Help
Ah and @west vault maybe put (Quick questions only) at the end like it said before
Or I just delete this thread. Gosh this is so annoying
Create a separate thread please.
Hello. I am quite new to Python and Pycord. I am trying to create a command and as part of this command, the bot will need to add two roles. The code I am using is as follows.
await ctx.author.add_roles(1051226883099984002, 1051229654792536096)
However when running the command, it is proving me with the following error.
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'int' object has no attribute 'id'
Full Error:
https://pastebin.com/8gX5uKj4
Help would be apricated.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
currently you have two role IDs, but you need two role objects
also please do not cross-post and stay in your thread
and also if you are new to Python, pls learn the basicΒ΄s first
Oh okay. Thanks.
so baso?
await ctx.author.add_roles(ctx.guild.get_role(1051226883099984002), ctx.guild.get_role(1051229654792536096))
Dont want to annoy anyone here, should i post this question as a separate thread? I dont know if this is a basic problem or more advanced?
Yeah, make a thread.
author.avatar.url
Mhm that or just use discord.Object(id) rather then get_role(id)
How are we supposed to know? You're not showing how you define it
Hi! Quick question:
Is it possible to build a Mention out of a User Id?
E.G: I have a user called Foo#2341, so I store that in my database as a String. How can I get mention Foo in a message?
Yes
<@userid> is their mention
And can I get the UserId from the name+discriminator?
Is there a reason you can't just store their ID as well?
Not at all haha if that's they way then perfect
Is there a way to get the discrimator out of the User Id?
You can use https://docs.pycord.dev/en/stable/api/clients.html#discord.Bot.fetch_user or https://docs.pycord.dev/en/stable/api/clients.html#discord.Bot.get_user to get a user object from an ID
That's... perfect 
get_user gets a user directly from the bot's cache, fetch_user gets it from Discord's API, so best practice is to always try get_user first, if that returns None, use fetch_user
.rtfm get_or_fetch
Hey! Stupid question incoming. I've recently discovered the amazing Options documentation for slash commands... Is there a way to set up dynamic options as an argument of a slash command?
What do you mean by "dynamic" options?
I'm having a big headache here.
Trying to figure cogs but the moment i change anything in the sample code, it just stops working and the slash commands stop showing up.
Figured it out
By dynamic options I mean like discord.Option(discord.Member, "Select a user") it is dynamic as each time a user joins the list gets updated, Can I do that with my own info?
You can get a similar effect using autocomplete https://docs.pycord.dev/en/stable/api/application_commands.html#discord.Option.autocomplete
Is it possible to set just a custom status without the playing/watching? just the text
No
Ok thanks
Don't use time.sleep, and don't use requests. These will both block the event loop and your bot won't be able to execute any other commands while it's waiting
time.sleep can be replaced with asyncio.sleep
how come i cant install it sm
use python 3.8 or above
oh awesome
hmm
should be pip3
ah
throws an error this time
Show the output of python3 --version and pip3 --version
yo wtf
Try python3 -m pip instead of pip3. Your pip installation seems to be broken
Or google the error you're getting to see if there's an easy fix π€·ββοΈ
python3 -m pip throws the same error
i have 0 idea what im meant to do icl
google is not very helpful either
it seems like a python3.11 issue
Well, have you printed the response or read the docs?...
await ctx.response("test", file=discord.File("tel.png"))
'InteractionResponse' object is not callable
it is impossible to send photos?
ctx.response?
The method is respond
is there any way to prevent my bot from being shut down using control c? ive tried
try:
bot.run(TOKEN)
except KeyboardInterrupt:
print(e)
but the except never gets called
Why would you want to prevent that?
its not exactly that i want to completely prevent it, i just want to make sure everything is saved to the database before exit
If you're subclassing, you can just override the close method.
class MyBot(discord.Client):
# ...
async def close(self):
# shutdown logic here
await super().close()
Just don't forget to call the super.close
Modern problems require modern solutions. 
Basic Pycord Help (Quick questions only)
Can we just not change the thread name anymore after this?
Basic Pycord Help (Quick Questions Only)
ok that change is ok
I don't really see a point in changing it at all, it's not like people are going to read the name anyways. Just like no one reads #help-rules, or #rules, or #how-to-get-help
Yay! Consistent capitalization!
Is it possible to create different cooldown times for different servers using commands.cooldown, or do I need to create my own cooldown system?
You need dynamic cooldown
Here's the cooldown example.
Tysm 
I had my first bot coded with all commands in the main file, later i saw how a friend of mine who coded with discord.js had every command in a different file and just called it from the main. I wanted to ask what is a better way to approach coding for a new bot, how would that work with python?
There is feature named βcogsβ, that basically does what you said
Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful
You can split cogs in separate files or have them all in one
Sorry if this question doesn't belong here, id imagine this is a basic enough question where it's not really specific,
However... I can't seem to understand why this presents an ERROR : "UnboundLocalError: local variable 'x' referenced before assignment"
This does not happen in any other programming language that I have used, but it seems Python is unable to handle this ?
global x
Thank you, I found a different solution as my application for this was for a class "self.x"
ok
why dis?
https://stackoverflow.com/questions/64473926/discord-py-oserror-winerror-121-the-semaphore-timeout-period-has-expired
Check this to see if it solves your issue. Is this a one time error or does it constantly happen?
one time just today cuz i kept the bot running for like 8hrs+
Overall I dont think it is a pycord issue but rather something with permissions or how something is set up on your PC
Ok thanks, i've heard of them but never understood why they should be used, this guide helped!
hello i am looking for help async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
^^^^^^^^^^^^^^
thats my error
heres my code
?tag codeblock
Please put your code in a code block:
```py
Here is your Code
```
That makes reading code in Discord a lot easier:
print("This is an example.")
thanks
@bot.slash_command(guild_ids = servers, name = 'timeout', description = "mutes/timeouts a member")
@commands.has_permissions(moderate_members = True)
async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
if member.id == ctx.author.id:
await ctx.respond("You can't timeout yourself!")
return
if member.guild_permissions.moderate_members:
await ctx.respond("You can't do this, this person is a moderator!")
return
duration = timedelta(days = days, hours = hours, minutes = minutes, seconds = seconds)
if duration >= timedelta(days = 28): #added to check if time exceeds 28 days
await ctx.respond("I can't mute someone for more than 28 days!", ephemeral = True) #responds, but only the author can see the response
return
if reason == None:
await member.timeout_for(duration)
await ctx.respond(f"<@{member.id}> has been timed out for {days} days, {hours} hours, {minutes} minutes, and {seconds} seconds by <@{ctx.author.id}>.")
else:
await member.timeout_for(duration, reason = reason)
await ctx.respond(f"<@{member.id}> has been timed out for {days} days, {hours} hours, {minutes} minutes, and {seconds} seconds by <@{ctx.author.id}> for '{reason}'.")
it was working the day before
and before in general dose anyone know that problem i am having with my code
check to see if the person sending (ctx.user.id) is owner of the guild using ctx.guild.owner_id (havent tested this)
dose anyone know the problem to my coding error
ok
i will find somewhere else to ask ig
where should i ask tho (person who deleted their message)
ignore that idiot.
Just wait till someone answers with an actual answer.
ok ig
Can you show the actual traceback
Cause that makes no sense
like the error message
wdym by "traceback"
Yes, the error..
ok
thats the error
async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
^^^^^^^^^^^^^^
@astral mist do you know basic python?
What you're providing makes no sense
Send the whole error
line 90, in <module>
async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
^^^^^^^^^^^^^^
send a screenshot from the console
that was still not the whole traceback...
its the whole error
Ah yes, python throws the error and makes you guess what it is
line 90, in <module>
async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
^^^^^^^^^^^^^^
this is what i got from debugging the code
why dose something work fine and then after a week just not budge
Is the moneykpatch allowed? to change status from bot (web to mobile)?
Is there anyway to connect to minecraft? (through some sort of API, main point is i cant find one)
first search result...? https://wiki.vg/Mojang_API
also uhh
anyone who's installed 2.3.2, what shows when you print discord.__version__ or discord.version_info?
π you must've searched smth else then
We don't write code for you. Make an attempt.
Could someone help me find something about creating channels (preferably pravite channels in API reference?, The new website is confusing me a bit (v2.3 or whatever)
.rtfm create_invite
Hey π
I'm creating modals and I need to force the user the type a int (number only) in a InputText, can I add input validation ? Am I using the good ui component ?
you mean you have something else installed than py-cord?
You can't validate such input until the user submits the modal
^
Nope
For exemple you can validate the lenght with a min/max
But nothing for the type ?
No
π¦
Modals are very limited atm
Okey π
only text input for modals also the limit are 5 fields
Okey thanks
could you help me with 1 thing rq, sending my modals in a certain channel?
fetch the channel and send the modal
thank you
Dose anyone know what to do
What is your error? That message is impossible to read
?tag codeblock
Please put your code in a code block:
```py
Here is your Code
```
That makes reading code in Discord a lot easier:
print("This is an example.")
including errors^
But itβs a error how do I put it in that
Code block?
line 90, in <module>
async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
^^^^^^^^^^^^^^
this is what i got from debugging the code
Here u go
There is no way that is the full error you are getting
It is
there is traceback above, send the whole thing
Then you either have some weird error handling going on, or you're not sending the entire thing
Ok the trace back is the error right
The traceback is the full output of the error
wait one sec my code editor is loading
Traceback (most recent call last):
line 90, in <module>
async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
^^^^^^^^^^^^^^
AttributeError: 'SlashCommand' object has no attribute 'Member'
is this it
yes
Yes please
alright
@bot.slash_command(guild_ids = servers, name = 'timeout', description = "mutes/timeouts a member")
@commands.has_permissions(moderate_members = True)
async def timeout(ctx, member: Option(discord.Member, required = True), reason: Option(str, required = False), days: Option(int, max_value = 27, default = 0, required = False), hours: Option(int, default = 0, required = False), minutes: Option(int, default = 0, required = False), seconds: Option(int, default = 0, required = False)): #setting each value with a default value of 0 reduces a lot of the code
if member.id == ctx.author.id:
await ctx.respond("You can't timeout yourself!")
return
if member.guild_permissions.moderate_members:
await ctx.respond("You can't do this, this person is a moderator!")
return
duration = timedelta(days = days, hours = hours, minutes = minutes, seconds = seconds)
if duration >= timedelta(days = 28): #added to check if time exceeds 28 days
await ctx.respond("I can't mute someone for more than 28 days!", ephemeral = True) #responds, but only the author can see the response
return
if reason == None:
await member.timeout_for(duration)
await ctx.respond(f"<@{member.id}> has been timed out for {days} days, {hours} hours, {minutes} minutes, and {seconds} seconds by <@{ctx.author.id}>.")
else:
await member.timeout_for(duration, reason = reason)
await ctx.respond(f"<@{member.id}> has been timed out for {days} days, {hours} hours, {minutes} minutes, and {seconds} seconds by <@{ctx.author.id}> for '{reason}'.")
heres the code
Which version of PyCord are you using?
how do i check that
Are you using Windows or Linux?
windows
Run pip3 freeze | findstr py-cord
py-cord==2.3.2
btw my code was working before
i tried debugging and now i have
even tho it worked before
Well, all of those errors are pretty self-explanatory.
Looks like you've done something to mess up the formatting of your file. You probably forgot to close a parenthesis or something
fine but it worked before
You must have done something, files don't just change on their own π€·ββοΈ
yep true well it works now i just reverted to my old code that i stored on github
You could have checked what the difference between new code and old code is 
Is there a way to stop recording a voice channel to save the output, while keeping the main voice recording going? So that you can save a certain part of it then move on.
I made a slash command and it works but it still says the application doesnt react. why?
How to make multiple options required in bridge?
Do i have to do discord.options for every individual or can be done in one go.
Hi, my bot printed this, what is it about and how can i fix it if it needs fixing
PS C:\Users\Zalama\OneDrive\Documents\GitHub\Grinder_Co> & C:/Users/Zalama/AppData/Local/Programs/Python/Python310/python.exe c:/Users/Zalama/OneDrive/Documents/GitHub/Grinder_Co/main.py
Traceback (most recent call last):
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 786, in _load_from_module_spec
setup(self)
File "c:\Users\Zalama\OneDrive\Documents\GitHub\Grinder_Co\data\cogs\edit.py", line 344, in setup
bot.add_cog(edits(bot))
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 656, in add_cog
cog = cog._inject(self)
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 548, in _inject
command._set_cog(self)
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 603, in _set_cog
self.cog = cog
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 830, in cog
self._validate_parameters()
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 708, in _validate_parameters
self.options: list[Option] = self._parse_options(params)
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 748, in _parse_options
option = Option(option)
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\options.py", line 216, in __init__
raise exc
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\options.py", line 211, in __init__
self.input_type = SlashCommandOptionType.from_datatype(input_type)
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\enums.py", line 791, in from_datatype
if issubclass(datatype, str):
TypeError: issubclass() arg 1 must be a class
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\Zalama\OneDrive\Documents\GitHub\Grinder_Co\main.py", line 36, in <module>
bot.load_extension(f"data.cogs.{filename[:-3]}")
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Zalama\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 791, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'data.cogs.edit' raised an error: TypeError: issubclass() arg 1 must be a class
PS C:\Users\Zalama\OneDrive\Documents\GitHub\Grinder_Co>
getting
error
Code
class edits(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.slash_command(name="edit",description="Edit Order")
@commands.has_any_role("Owner", "COO", "Director", "Manager", "Supervisor", "Developer", "Developer")
async def edit(self, ctx:discord.ApplicationContext, order_id : option("Order ID",str,required=True), action: option("action",str,discription="what you want to change",choices=["priority","cancel","discount","info","amount"],required=True), *, change:option("Change",str,required=False,default=None)):
if order_id.isnumeric() == False:
Is there a way I can avoid global sync by putting my guild id on just 1 place or do I have to put it in every command?
Idk why but every time I want to execute a command it prints:
but I don't have any event that would print this
class Hello:
def __init__(self):
self.message = "Hello, World"
def print_message(self):
print(self.message)
print_message()
how to give print_message access to self?
use find tool in ur ide
Can't you just do Hello().print_message()
no π
@slash_command(
name="ping", description="Get latency of bot.", guilds_ids=get_guilds()
)```
i want to give guild ids as return of after calling a function
def get_guilds(self):
return self.guilds```
I don't think you can...
oh no
maybe via the cog's command invoke thing.. I have no idea
if that even exists
debug_guilds
Pass it in the bot class
isn't it guild_ids? Im using bridge.Bot btw
debug_guilds in the bot class
guild_ids in commands
np
?tag codeblock
Please put your code in a code block:
```py
Here is your Code
```
That makes reading code in Discord a lot easier:
print("This is an example.")
where in the code did u create a channel...
Yes
r u sure channel doesnt exist
r u sure channel doesnt exist?
@fervent cradleprint the type of message.channel
if that's discord.DMChannel, try if not message.guild: instead of isinstance
When I execute a command that replies with an ephemeral message the console prints "Error" why is that?
which editor are you using?
there could be some even t hat runs on application command
or something like that
what error?
"error" doesnt help us to help u
already fixed it, was a mistake on my end sry xd
Ok
hey this was already answered but how do i get the user_id of all members in a channel
in a voice channel*
I have a small question, move_to to move a person from voice lounge works only with Member and not User ?
You can't move a non-server member, can you?
if it is not on the server in question yes I could not... And even with bot.get_user(id) it doesn't work
Because you need a Member object
bot.get_user gives you a User object iirc
.rtfm Bot.get_user
Indeed.
that's the problem :/ how to get one by searching a member on the server ?
.rtfm Guild.get_member
thank you very much ^^ it helped me a lot
await interaction.guild.create_text_channel(name="test",category_id = 1052267160724049970 )```, Im getting error ypeError: Guild.create_text_channel() got an unexpected keyword argument 'category_id', Im unsure of where id decide the cateogory
use category.create_text_channel
so would replacing guild with category fix this?
and should i define catogoery?
yes
π
AttributeError: 'Interaction' object has no attribute 'category' category = "Tickets"
await interaction.category.create_text_channel(name="test")
Definitely not how it works
Yep i relieased
I tried category = (id) inside the brackets but that hasnt worked either (like in first msg)
.rtfm Category
discord.abc.GuildChannel.category
discord.AuditLogEntry.category
discord.ChannelType.category
discord.AuditLogActionCategory
discord.AuditLogActionCategory.create
discord.AuditLogActionCategory.delete
discord.AuditLogActionCategory.update
discord.Guild.by_category
discord.Guild.create_category
discord.Guild.create_category_channel
discord.Thread.category
discord.Thread.category_id
discord.StageChannel.category
discord.StageChannel.category_id
discord.TextChannel.category
discord.TextChannel.category_id
discord.ForumChannel.category
discord.ForumChannel.category_id
discord.VoiceChannel.category
discord.VoiceChannel.category_id
Is something with the slash commands? I create a new basic slash command and cannot see the command at the server
Thanks
Prefix commands are fine but not slash commands
It takes a while to register slash commands
Not anymore and also not like 20h
Im still struggling here, I've googled & tried troubleshooting myself but i cant seem to figure it out.
You need to put in the category Object in it π
Get the category via get_channel()
Thats old code, i've got a bunch of different soultions i've tried from google
Ill try this
.rtfm Guild.create_text_channel
I've gotten it to create the channel fine, its the category
Aight
category= category object
Okay ty
Not category_id
Im unfamilar with get channel, would it be something like category = get_channel(id here)
Ah wait i might have it
await interaction.guild.create_category_channel(name="test",category=interaction.category )``` Whats been done wrong?
Sorry, I havent done this before
is there a way to have the bot send a message that only a specific person can see?
?tag ephemeral
An 'ephemeral' message is one that's only visible to the person who invoked a command. If you ever got a command error with a blue background, this is an example of one.
To do this, set ephemeral=True when you first use an ApplicationContext. (This includes .defer()ing it; the choice of whether a message is ephemeral or not must be made up front. If you .respond() to a deferred message, setting the ephemeral flag at that time will have no effect.)
This is the equivalent of hidden=True if you're coming from interactions.py
Dms?
Create category channel does not have a category argument.
await interaction.guild.create_text_channel(name="test",category=category )``` would this be correct
Yes
Here's the modal dialogs example.
``` Wheres the missing param?
async def callback(self, interaction: discord.Interaction) π
Oh thank you!
@discord.ui.button(label="General Support",style=discord.ButtonStyle.success, emoji="π")
async def button_callback(self,button, interaction: discord.Interaction):
category = self.get_channel(1052267160724049970)```
AttributeError: 'Support' object has no attribute 'get_channel', I presume this is because get channel may be in the wrong place?
interaction.client.get_channel(1052267160724049970) π
Thank you (in my case its bot)
Did you figure your issue out?
No I have create a help subject π
Okay
is there docs to adding activity satus to ur pycord bot
NVM i found it
@discord.ui.button should be indented at the same indent line as your __init__
You didn't even do what I said
def __init__()
@discord.ui.button()```
Same line as the __init__
No
it should align the indentation of def __init__
Is it possible when I have Autocomplite options to disable the freehand input that you can only select the options?
asking for a friend- how to fix this?
use latest pycord version if you are using python 3.11
class NewButtons(discord.ui.View):
@discord.ui.button(label="Close Ticket",style=discord.ButtonStyle.red, emoji="β")
async def button_callback(self,button, interaction: discord.Interaction):
await NewChannel.delete(self)
class Support(discord.ui.View):
@discord.ui.button(label="General Support",style=discord.ButtonStyle.success, emoji="π")
async def button_callback(self,button, interaction: discord.Interaction):
category = interaction.client.get_channel(1052267160724049970)
NewChannel = await interaction.guild.create_text_channel(name=f"Ticket",category=category)
await NewChannel.send(embed = StartMsg, view=NewButtons())
class ticket(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.slash_command(name="ticket")
async def ticket(self,ctx):
await ctx.respond(embed=SupportTicket, view=Support())
def setup(bot):
bot.add_cog(ticket(bot))``` What can i do here? It thinks NewChannel isnt defined because its above where its defined, but if i move it it messes up
NewChannel is not defined. Its defined in another class
C:\Users\Administrator\Desktop\BoostBot>python main.py Traceback (most recent call last): File "C:\Users\Administrator\Desktop\BoostBot\main.py", line 11, in <module> from discord.ext import commands File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands__init__.py", line 18, in <module> from .flags import * File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\flags.py", line 71, in <module> @dataclass ^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1221, in dataclass return wrap(cls) ^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1211, in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 959, in _process_class cls_fields.append(_get_field(cls, name, type, kw_only)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 816, in _get_field raise ValueError(f'mutable default {type(f.default)} for field ' ValueError: mutable default <class 'discord.utils._MissingSentinel'> for field name is not allowed: use default_factory
any idea?
was after that
Use the latest pycord version for 3.11
How would i fetch it then? Because its a new channel each time.
Show pip list
how?
"pip list"
in powershell/cmd promt
C:\Users\Administrator\Desktop\BoostBot>pip list
Package Version
aiohttp 3.8.3
aiosignal 1.3.1
anyio 3.6.2
async-timeout 4.0.2
attrs 22.1.0
certifi 2022.12.7
charset-normalizer 2.1.1
colorama 0.4.6
discord.py 2.1.0
ffmpeg-python 0.2.0
frozenlist 1.3.3
future 0.18.2
h11 0.14.0
httpcore 0.16.2
httpx 0.23.1
idna 3.4
imageio-ffmpeg 0.4.7
multidict 6.0.3
numpy 1.23.5
pip 22.3.1
py-cord 2.1.1
pycord 0.1.1
requests 2.28.1
rfc3986 1.5.0
setuptools 65.5.0
sniffio 1.3.0
urllib3 1.26.13
yarl 1.8.2
Pass the channel into the view init? Hello? Classes?
Use the github version of pycord
tag install
idk it dark?
Uninstall discord.py and pycord and updated py-cord to 2.3.2
how do i move users to a different voice channel?

pip install -U py-cord==2.3.2
You gotta do a flip
do i read the docs and found the solution
but i dont want to await
"coroutine 'Member.move_to' was never awaited"
but i dont want to end my function yet
any other way?
right
Is it possible when I have Autocomplite options to disable the freehand input that you can only select the options?
await interaction.guild.delete(NewChannel) how would i find the channel i've made each time?
I could use fetch but how would i find the channel the bots made
404 Not Found (error code: 10062): Unknown interaction
Anyone know what might be happening ?
is a modal
you can have as many fields as you want
oh you mean the selector?
or embed ?
to paginate embeds you can have as many as you want and use it like this
to paginate embeds
you are using add_field you must put False to cut the line
inline = False
the 1st Inline = True
the 2nd Inline =True
the 3rd Inline = False
you must identify each time it is the third so that I put it in false
I don't know for example
for x in 999
if x == 3:
inline false
else:
inline true
it's up to your wits now
/ 3 == 0 ΒΏ?
%3 == 0 ΒΏ? I don't remember which is the operator to show the rest
if when divided by 3 it has remainder 0 inline false
to avoid having to repeat it in 3,6,9,12,15 etc
Hi! I migrated my bot to replit but I have this error
you forgot to set the prefix
I use only slash command
but it says its a required argument
so you have to set it
doesent matter if you use it or not
Okay
you can just set it to a random thing
if possible adding an invisible field but it is a with a special character
how can I load the cogs?
There is a page but I don't remember what it is
I couldn't tell you I think it was one called zero
For the title and another special for the value
\u200b
yes
Is it possible when I have Autocomplite options to disable the freehand input that you can only select the options?
choices=[]
if its more than 25 you have to use autocomplete
I have used autocomplete but would like to prevent a user from typing anything into the field using the keyboard but only selecting from my predefined selection.
is like:
@bot.event
async def on_interaction
a thing?
yes
.rtfm on_interaction
does anyone have a code example of the select component in ephemeral view
pffft
nvm im just dumb
Uninstall discord.py pycord and py-cord
Then reinstall py-cord
def restart_bot():
os.execv(sys.executable, ['python'] + sys.argv)
class Owner_Only(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def cant(self, ctx): #line 28 (this is not in my main code)
await ctx.message.delete()
embed = discord.Embed(description="`-cant` is **deprecated**. Use `/cant`.",color=p84clr)
await ctx.channel.send(embed=embed,delete_after=5)
@commands.command()
async def music(self, ctx):
await ctx.message.delete()
embed = discord.Embed(description="`-music` is **deprecated**. Use `/music`.",color=p84clr)
await ctx.channel.send(embed=embed,delete_after=5)
@commands.command()
async def suggest(self, ctx):
await ctx.message.delete()
embed = discord.Embed(description="`-suggest` is **deprecated**. Use `/suggest`.",color=p84clr)
await ctx.channel.send(embed=embed,delete_after=5)
@commands.command()
@commands.is_owner()
async def accept(self, ctx, userid):
await ctx.message.delete()
embed = discord.Embed(description=f":tada: Congratulations! Your application was accepted and you were automatically whitelisted on our SMP. If you forgot how to join you can check out #990498479384199168.",color=0x22e63c)
await ctx.channel.send(f"@undone mulch **accepted** <@{userid}>'s application.",embed=embed)
@commands.command()
@commands.is_owner()
async def joinsmp(self, ctx, userid):
await ctx.message.delete()
embed = discord.Embed(title="#MendingArmy SMP",description=f":one: Enter anything into the server name field.\n:two: Enter IP **smp.minermends.com**.\n:three: Leave the port as default.\n:four: Apply in #990499151076790303.\n:five: Join when your application gets accepted.",color=p84clr)
embed.set_image(url="https://media.discordapp.net/attachments/1040478994308550676/1044521716161970254/image.png?width=998&height=593")
await ctx.channel.send(embed=embed)
@commands.command()
@commands.is_owner()
async def vadelia(self, ctx, userid):
await ctx.message.delete()
embed = discord.Embed(title="Vadelia Factions",description=f"This channel is for our official Minecraft server. **Vadelia** is a server that works for both Bedrock & Java. You can use the thread below for any questions you might have regarding the server. Enjoy!",color=p84clr)
embed.add_field(name="Basic Help",value=f"Factions is an intense combat gamemode where you're up against every other player to compete for the top. Each player is capable of creating their own faction and inviting members into it. The ultimate goal is to establish a base and fend off any intruders! Players can resort to any means possible to take out another faction (besides hacking or cheating). Type `/f help` for a list of faction commands. Good luck!",inline=False)
embed.add_field(name="Join Vadelia",value="**IP**: `vadelia.net`\n**PORT**: `Default`\n**Version**: `Latest | Bedrock / Java`",inline=False)
embed.set_image(url="https://media.discordapp.net/attachments/1040478994308550676/1046294996430626957/V-01_1.png?width=839&height=593")
await ctx.channel.send(embed=embed)
@commands.command()
@commands.is_owner()
async def topthread(self, ctx, userid):
await ctx.message.delete()
embed = discord.Embed(title="Welcome to the Thread!",description=f":one: Use this channel for any questions you might have.\n\n:two: Trades, recruitment, and all other faction stuff only.\n\n:warning: This channel is not for general chatting. Please go to #1039556175181647992 for that.",color=p84clr)
await ctx.channel.send(embed=embed)```
Why is it saying that my synax is invalid at line 28
what is line 28
async def cant(self, ctx):```
Is this the code for your entire cog?
Can you provide the traceback @undone mulch
It's saying this
Extension 'cogs.miner_only' raised an error: IndentationError: unindent does not match any outer indentation level (miner_only.py, line 47)```
**Traceback** ^
