#General Help
1 messages · Page 5 of 1
slash command options have to be fully lowercase
pain
matchID
IN The close view?
but i dont want to to a respons
i only want to send a normal message
If I wanted to take a string and replace every space with %20, ive tried using .replace() but it didn't work. I am attempting to format links to search for a username with spaces in it btw
statblock = SlashCommandGroup("statblock", "Generate various statblocks")
#@commands.cooldown(3,180, commands.BucketType.user)
@statblock.command(name="classic", description="Generates a statblocks according to the 4d6^3 (keep highest 3)")
async def classic(self, ctx, characterName = ""):
pass
@statblock.command(name="d4", description="Rolls a d4")
async def d4(self, ctx, amount = 1):
pass
Is there any possible reason on this good planet, why characterName contained within the first command should cause a validationerror while the one below works perfectly fine without a hitch?
no
lol
you dont need a space for it to work
try
await ctx.send(embed=embed)
that works too
lol
oh ok
but it looks bad
Why doesn't it work? :((
Code:
@bot.slash_command()
async def xwarn_remove(ctx, member: Option(discord.Member)):
with open("warns.json") as f:
data = json.load(f)
if str(member.id) in data:
for element in data:
element.pop(f"{member.id}", None)
with open("warns.json", "w") as f:
data = json.load(data, f)
Error:
Ignoring exception in command xwarn_remove:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 829, in _invoke
await self.callback(ctx, **kwargs)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\main.py", line 76, in xwarn_remove
element.pop(f"{member.id}", None)
AttributeError: 'str' object has no attribute 'pop'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
await injected(ctx)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'pop'
so i know element.pop is correct or not?..
but this error say no..
.pop only works for lists
and it takes in the index as the argument
so for example
a = [1, 2, 3, 4]
removed = a.pop(1)
print(a) # [1, 2, 3, 4]
print(removed) # [1, 3, 4]
currently element is a str
One message removed from a suspended account.
One message removed from a suspended account.
Also, variable create and then variable.pop(1) and then is the member id removed from my Json file?
The index is removed from your member file
If you want to remove a specific member id then you have to find it’s index
Maybe something with tasks? There might be better ways though
How i can find a new Index?
You might be able to use list.index() but it depends on the way your data is set out
I have to go sleep so I hope someone else can help you
Okay good night and thanks
how can i catch the page value on a paginator in a button click?
what theme ?
I think it's called bearded
Yep, do you know which one it is in specific ? There are multiple versions.
One message removed from a suspended account.
nvm i have the one ur on
Anyway!!
user_list = "\n".join([f"Name: {name} - Number: {number}" for name, number in users])
Error: TypeError: cannot unpack non-iterable int object
I am so confused :(
One message removed from a suspended account.
Just the normal one
what is the users variable?
users = [(i, data[i]) if user.lower() in i.lower() else 0 for i in data]
This is the users var
try printing out users or using debug to view your users and see what is being stored in there
from what I can tell it looks like your users list is actually a list of integers
oh i see
its (variable) users: list[tuple | int]
yeah, if there is a single int in there then you won't be able to unpack the list
So im trying to figure out how to append each user into a list of strings and then print each one out.
if you really wanna use list comprehensions, you can probably do something like this
user_list = "\n".join([f"Name: {obj[0]} - Number: {obj[1]}" if isinstance(obj, tuple) else f"Number: {obj}" for obj in users])
don't recommend this though as its probably best to make it an actual for loop instead of list comprehension
this is what im trying to do
what does an int represent in your users list versus a tuple?
its not supposed to be that
its supposed to be a list of data like "Name: John - Number: 445 514 6764"
i need help with dm the owner of server on command
@bot.command()
async def customrole(ctx, name):
owner = ctx.guild.owner
member = ctx.message.author
await owner.send(f"{member}, wants to create a custom role called {name}.")
this is my error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 74, in customrole
await owner.send(f"{member}, wants to create a custom role called {name}.")
AttributeError: 'NoneType' object has no attribute 'send'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
@south ermine
@south ermine
#help-rules please stop pinging me
make sure you have the members intent enabled
i do
try guild.fetch_members() maybe?
where do i put the id
its not working
you the need the guild intent to get certain information about guilds
gimme example
?tag intetns
No tag intetns found.
No tag inetnts found.
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)
nailed it
?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)
Only took like 30 tries 1 try
exactly
remove them
name change fixed it... but can't tell what caused this
you cant call subcommands
also that whole file is a nightmare to work with
consider separating and grouping commands into cogs
i found out about cogs when i was done with most of the commands so for now i am just adding / on 3 to 4 remaining commands and will later add cogs
hm okay fair enough
idk if anyone knows anything about sql stuff, but this code block is failing after the line 475 print statement.
sql = f"INSERT INTO lolmatches(guild_id, match_id, blue_one, blue_two, blue_three, blue_four, blue_five, red_one, red_two, red_three, red_four, red_five, winner) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)"
print("made it to line 475")
await db.execute(sql, str(ctx.guild.id), int(matchid), str(blueIDlist[0]), str(blueIDlist[1]), str(blueIDlist[2]), str(blueIDlist[3]), str(blueIDlist[4]), str(redIDlist[0]), str(redIDlist[1]), str(redIDlist[2]), str(redIDlist[3]), str(redIDlist[4]), str("none"))
AttributeError: 'BridgeExtContext' object has no attribute 'user'
For a data storage is it better to use MongoDB or jusy JSON files?
definitely mongodb
mongodb atlas is really good and not too hard to pick up
i dont think so
why does the guild.members list only contain the bot account?
>>> print('member_count: {}'.format(guild.member_count))
member_count: 1338
>>> print('true_member_count: {}'.format(len(guild.members)))
true_member_count: 1
the bot has admin as well so it should be able to see everything
Solved: https://discordpy.readthedocs.io/en/stable/intents.html
you need the members intent to receive the full list
yea just saw that, thanks
is there a way to restrict slash commands to certain channels?
yes, go to interactions and switch off the channels you dont want it to be in
i think there are some decorators to set defaults for those
Is there a way to get real image urls when i use activity.assets?
its currently just this
Hey guys! I am kinda new to pycord and have added this:
class TimeConverter(commands.Converter):
async def convert(self, ctx, argument):
args = argument.lower()
matches = re.findall(time_regex, args)
time = 0
for v, k in matches:
try:
time += time_dict[k]*float(v)
except KeyError:
raise commands.BadArgument("{} is an invalid time-key! h/m/s/d are valid!".format(k))
except ValueError:
raise commands.BadArgument("{} is not a number!".format(v))
return time
class Timeout(commands.Cog):
def __init__(self, bot):
self.bot = bot```
but I get this:
any clue on how to fix?
How can i get a Game Icon from the Application ID?
Traceback (most recent call last):
File "main.py", line 192, in <module>
bot.run(os.getenv('TOKEN'))
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/discord/client.py", line 715, in run
return future.result()
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/discord/client.py", line 694, in runner
await self.start(*args, **kwargs)
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/discord/client.py", line 658, in start
await self.connect(reconnect=reconnect)
File "/home/runner/sir-aramis/venv/lib/python3.8/site-packages/discord/client.py", line 599, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
can anyone help
im on replit btw, pls ping me or dm on reply
@here can some one help @here
Please don't use repl.it 😦
?tag norepl
Why NOT to use Repl as a hosting platform
You should not use Repl.it to host your bot.
It may be a nice option as its "free" but you should use something else considering the major flaws.
- The machines are super underpowered.
-
- This means your bot will lag a lot as it gets bigger.
- You'll need a web server alongside your bot to prevent it from being shut off.
-
- This isn't a trivial task, and eats more of the machines power.
- Repl.it uses an ephemeral file system.
-
- This means any file you saved via your bot will be overwritten when you next launch.
IMPORTATNT
- They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
Please avoid using repl.it to host your bot. It's not worth the trouble.
If you're looking for free options, consider using AWS/Google Cloud Platform/Azure and its respective free tiers or just pay for an actual VPS.
you need to enable intents on developer portal
you are acting like stackoverflow guy
yep, but he didn't even tried to help
he just said "DONT USE IT", like it was causing the error
true
True, should've given more context 😅
what is the alternative to using self inside a decorator (cuz you can't)?
nothing, if you are trying to access variables inside of __init__ iirc
yeah
cause I am trying to make views, but the label of the button is inside a decorator
and I am trying to put a value inside that label, but idk how
check examples in pycord's github
I found an example on stackoverflow
gonna try it out
ok, I'm just gonna try on constructing a button on my own without the decorator
yay it worked
ctx.author?
Do application commands have an option for cooldowns?
they work with the discord.ext.commands.cooldowns decorator
Thanks, Ill take a look at that
Does anyone know where to find an exhaustive list of short codes of languages allowed in discord code blocks?
can you edit an ephemeral msg?
I believe so
I'd say you can't since they're held in the user's client itself
yeah, that's what I wanted to say
I don't think you get access to it after you send it
yeah, well at least buttons work
nope, it's actually possible
it just worked for me
now, how on earth do I remove buttons from a message 
Remove them from view.children and update the message with the view
like do I just do view.remove_item()?
Not really sure if there's such a method but I'd remove it from view.children
hm, there is a view.add_item() which adds the buttons
so maybe view.remove_item() exists, brb gonna check the docs
I think it's in the form of a DM message btw, but not too sure
yeah there is one
Nice
I'd probably just say that discord keeps it in their storage for 15 mins and if it's inactive they remove it
cuz why on earth would they keep it in the storage if it can be closed
they don't store it iirc, the client handles it
You can edit it with interaction.edit_original_message btw
Does anyone know where to find an exhaustive list of short codes of languages allowed in discord code blocks?
Going to the left -> language categories -> all
If you really want all of them
Yeah but it doesn't seem to show the short codes :(
hmm?
what do you want to do?
Me?
yea
You mean with the short codes?
Oh, just trying to recogonize them
Aka if someone is using the right ones I'll know
hmm
You can do a bit of "hacking" and check them in inspector
Imagine not learning python with discord.py 
Yeah but those aren't the short codes though
I mean sorry, some of them aren't
For instance, python, they have language-python
Without the language- part
I know but technically, it should be language-py
Python works too O.o
True taht
def foo():
return "bar"
I need them short codes unfortunately 
Well, shorter than that you ain't getting anywhere 😄 😄
the shorter the better
def short_codes():
return "pain"```
raise ItAintShortEnough```
"it's still pain"```
short codes? I need some help generally
all them shortcodes one could ever desire

@client.slash_command(name='sell', description='Sell one of your roles to another')
async def sell(
ctx,
role=Option(discord.Role, "Choose your role")
):
await ctx.respond(f"You chose {role}!")
``` is it possible to choose the guild's roles in the Option? I thought I would see a list of all the guild's roles, but it doesnt do that. Am I mistaken?
Doesn't it show the roles that are pingable?
it's like this
has it not registered? I added debug_guilds
It is registered for sure, what if you type the beginning of a role name?
Make Role to role i think
I have it in my code
Let me check

Replce = with :
Also the type of role is str not discord.role
this worked, thanks
Keep that Role but replce = with :
Cool
U can do same for text channel too by discord.TextChannel if u ever need that
Thank you
Now someone help me with this
How to make command accessible only in guilds?
but i dont want to to a respons
i only want to send a normal message
You have to have a response somewhere
What I suggested was leave your regular .send, but then at the very end of your callback you include a response.send_message that's ephemeral just to say what happened
what do you mean?
Like at the very end of the callback you do something like await interaction.response.send_message("Success", ephemeral=True)
Outside of the if so it'll run regardless, but you might wanna customise the message a bit
Like, not allow them in DMs? You can do something like:
if ctx.author.dm_channel == ctx.channel:
return None
@discord.ui.button(label='Ja', style=discord.ButtonStyle.green, emoji="✅", custom_id='closeja')
async def closeja(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.defer()
guild = interaction.user.guild
team = guild.get_role(serverteam)
#if team in interaction.user.roles:
mycursor.execute("SELECT * FROM Tickets WHERE TicketChannelID=%s", (interaction.channel.id,))
data = mycursor.fetchone()
user = await guild.fetch_member(data[3])
if user:
await interaction.channel.set_permissions(user, view_channel=False)
em = discord.Embed(description=f'Das Ticket wurde von {interaction.user.mention} geschlossen!', timestamp=datetime.now(), colour=colour().main)
em.set_author(name=interaction.user.name, icon_url=interaction.user.display_avatar.url)
em2 = discord.Embed(description=f'Dein Ticket wurde von {interaction.user.mention} geschlossen!', timestamp=datetime.now(), colour=colour().main)
em2.set_author(name=interaction.user.name, icon_url=interaction.user.display_avatar.url)
message = await interaction.response.send_message(embed=em, view=Closed())
#message = await interaction.channel.send(embed=em, view=Closed())
log = bot.get_channel(log_id)
em=discord.Embed(title="Log - Close", description=f"{interaction.user.mention} hat Ticket {interaction.channel.mention}({interaction.channel.name}) von {user.mention}({user.id}) geclosed!", timestamp=datetime.now(), color=colour().main)
em.set_author(name=f"{interaction.user.name}#{interaction.user.discriminator}", url="", icon_url=interaction.user.display_avatar.url)
em.set_footer(text=f"{interaction.user.id}")
await log.send(embed=em)
# manchmal error nach hier
mycursor.execute("INSERT INTO ReopenMSG (reopen, TicketChannelID) VALUES (%s,%s)", (message.id, interaction.channel.id,))
db.commit()
# interaction.response.send_message # muss response
try:
await user.send(embed=em2)
except:
pass
mycursor.execute("SELECT closenein FROM CloseMSG Where TicketChannelID=%s", (interaction.channel.id,))
data = mycursor.fetchone()
message2 = await interaction.channel.fetch_message(data[0])
mycursor.execute("DELETE FROM CloseMSG WHERE TicketChannelID=%s", (interaction.channel.id,))
db.commit()
await message2.delete()
#else:
#await interaction.response.send_message(f"{emoji().error} Nur das Severteam, kann Tickets schließen!", ephemeral=True)
what about / commands i don't want them to show un in dm
I don't think you can at the moment until perms v2 are sorted out
what about guild_only
how does that works?
I'll check this later since I'm on mobile but you only need one response, not multiple
I mean, you can do it as in the example here https://docs.pycord.dev/en/master/api.html?highlight=guild_only#discord.commands.guild_only
But am not sure if it relies on the perms or not
guild_only is available on master branch, otherwise you'd have to set guild_ids (which you may not want if they're meant to be global)
But you can use an internal check if you want to stay on the current beta
i think i have master version i installed using pip install git+http....
When did you install it? Might need to update it a bit
yesterday
But if you are on the latest master it's @discord.guild_only()
That should work then
thanks a lotttt will try
thanksssssssssss
i don't need to pass any value in it?
AtrributeError: 'PartialMessagable' object has no attribute 'permission_for'
getting this rn any way to ignore it?
i need help, I'm new to coding
How do i create an guild owner only command
I been struggling for hours
Anyone know why discord.ext.commands.cooldown doesn't work on slashcommands in 2.0.0b7?
Do you know the basics of Python?
@bot.event
async def on_member_update(before, after):
# check if user has tebex role
roleids = [973887804486598696, 973887673821433916, 973882126527250542, 973608966145835118, 973608857039417394, 973607879653330984, 973607779015213096, 973606870130515999, 973606684389961808]
# check if roleid in in list roleids
how should i do it?
i thought about fetching every role and check if its in the after.roles
you don't need to get every role object, you can just compare the role IDs
you can get all of the IDs in after.roles by list comprehension, e.g. roles = [role.id for role in after.roles]
So the problem is not an error but it doesn't add a cooldown to the command (bot shown in command._buckets.cache)
i did it now like this?`
if before.roles != after.roles:
for role in after.roles:
if role.id in roleids:
this good?
or this:
roleids = [973887804486598696, 973887673821433916, 973882126527250542, 973608966145835118, 973608857039417394, 973607879653330984, 973607779015213096, 973606870130515999, 973606684389961808]
if before.roles != after.roles and [role.id for role in after.roles if role.id in roleids]:
...
how to add multiple buttons to a single message?
does anyone know?
await ctx.respond(embed=embed, views=[view, view2])
i tryed this and failed
a view can fit 25 buttons
each view has 5 rows
each row can fit 5 buttons
nice but how
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/examples/views at master · Pycord-Development/pycord
ty
cant find an example witch has 2 views in one response
Is it possible to make slash commands only visible in specific channels?
what?
you don't need 2 views
is it possible to disable a button from an other callback?
How use have 2 checks for a command?
what type of checks
@client.command()
@commands.has_permissions(administrator=True)
@commands.has_any_role('test')
async def test(ctx):
await ctx.reply('success')
like this but it doesnt work
wdym doesn't work
like i want a user with the role test or any admin to use a command
how to do that
and what does the current one do?
Admins can use it
I tried from my alt with the role test and it showed missing permissions
Nvm
Apparently the command only works if you have both admin perms and test role
can i delete this message when pressing the first button?
I want it to work with either of them
Anyone knows how?
Thanks
it doesn't work..
@bot.command()
async def auto(ctx):
user = ctx.message.author
role = discord.utils.get(user.server.roles, name="staff")
await user.add_roles(role)
await ctx.send("you got the role!!!")
the problem :
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'server'
@bot.command()
async def dungeon(self, ctx: commands.Context, *targets: list[discord.User]) -> None:
...
how to convert rest of arguments to discord.User?
i know i can just find user by id, but i wanna know are there any easier ways?
async for msg in channel.history(limit=None, after=date):``` I'm using this function wrong? I pass this date `2022-05-11 22:28:27.593047` which i get from `datetime.utcnow()` but I loop over messages which have ```
text
2022-05-11 22:06:33.161000+00:00
``` older timestamp, which I don't want to do, idk what's the problem I think I understood the docs about this function correctly
has anyone experienced an issue with attachments not populating in discord.InteractionMessage.attachments? my bot is awaiting on user message and checking the list but it is empty when i send an image or video
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\cwals\Documents\GitHub\novabot-dev\.venv\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\cwals\Documents\GitHub\novabot-dev\.venv\lib\site-packages\discord\bot.py", line 1025, in on_connect
await self.sync_commands()
File "C:\Users\cwals\Documents\GitHub\novabot-dev\.venv\lib\site-packages\discord\bot.py", line 685, in sync_commands
await self.http.bulk_upsert_command_permissions(self.user.id, guild_id, guild_cmd_perms)
File "C:\Users\cwals\Documents\GitHub\novabot-dev\.venv\lib\site-packages\discord\http.py", line 357, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed
Anyone having a similar issue?
i had that an after reinstalling pycord it went away
Thanks!
Hey
I'm having some trouble with the slash commands. My import statement for discord.commands is no longer working.
It is as follows:
from discord.commands import slash_command
It claims that discord.commands does not exist. Is it in a new location now?
what is the error?
so permissions decorator rip
then im using commands.ext
can i manage only guild permissions with it or i can do a command just for me?
b!rtfm attachment
I couldn't find a documentation with the name attachment! 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 attachment
Cannot find reference 'commands' in '__init__.py'
The runtime error is:
Traceback (most recent call last):
File "C:\Users\...\...\...\venv\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\...\...\...\extensions\....py", line 11, in <module>
from discord.commands import slash_command
ModuleNotFoundError: No module named 'discord.commands'
This is using Pycord 1.7.3 from pip/PyPi.
- 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 beta:
pip install py-cord==2.0.0b7
No matching package version found: 'py-cord== 2.0.0b7' (required: <nothing>, installed: 1.7.3, latest: 1.7.3)
no space
👍
anyone suddenly having issues with slash commands?
anyone know what event is emitted when a guild member's account is purged? not the initial "deletion", which is only a deletion market, but the purge that happens after the waiting period that fully deactivates it as a messageable target and transitions it to the Deleted User <hash> name
is it just a MEMBER_REMOVE?
How would I check if someone dms the bot ?
In on_message see if message.guild is None
oh that is interesting I will try that
I don't really know, it might be a member update
ddevs server could probably answer that
how to send the entire traceback as a form of msg ?
You can make an error handler for that and format the exception into a string with something like:
import traceback
''.join(traceback.format_exception(
type(error), error, error.__traceback__))```
then send it as a msg if you want
yhh tysm
np
for some reason the slash commands don't register when i use debug_guilds in bot constructor, only works if i have guild_ids in slash command decorator, anyone know why?
hello?
Traceback (most recent call last):
File "D:\Program Files (x86)\Python 3.10\lib\site-packages\aiohttp\connector.py", line 969, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\base_events.py", line 1064, in create_connection
raise exceptions[0]
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\base_events.py", line 1049, in create_connection
sock = await self._connect_sock(
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\base_events.py", line 960, in _connect_sock
await self.sock_connect(sock, address)
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\proactor_events.py", line 705, in sock_connect
return await self._proactor.connect(sock, address)
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\windows_events.py", line 817, in _poll
value = callback(transferred, key, ov)
File "D:\Program Files (x86)\Python 3.10\lib\asyncio\windows_events.py", line 604, in finish_connect
ov.getresult()
OSError: [WinError 121] The semaphore timeout period has expired
like why
the intentions are okay
class verify(discord.ui.View):
@discord.ui.button(label="Click me!", style=discord.ButtonStyle.primary)
async def button_callback(self, button, interaction):
await interaction.response.send_message("....")
@bot.command()
async def auto(ctx):
user = ctx.message.author
role = discord.utils.get(ctx.guild.roles, name="staff")
await user.add_roles(role)
await ctx.send("you got the role!!!", view=verify)
ptoblem:
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: to_components() missing 1 required positional argument: 'self'
commands are not appearing
as well as "Command not found error"
as it may be relating to the 405: Method Not Allowed Error.
I tested group commands on the main py file instead of its own cog
it works
so how do i fix this error
idk, try installing Python 3.9 instead of 3.10, might help
ok
thx
i have python 3.7 installed so is that also okay
How can I resolve this problem The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\thegi\AppData\Local\Programs\Python\Python39-32\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: to_components() missing 1 required positional argument: 'self'
put self in to_components() (the brackets)
no
it's discord API sending false errors because of slash permissions v2
can i get modal input with returning the value in the modal callback?
Is there an established docker image anyone would suggest for a pycord bot? Just getting into docker and researching
Just came back here to say I was slightly wrong; as per https://github.com/discord/discord-api-docs/pull/4896, guilds and clients that are on Commands V2 (not to be confused with permissions V2) will have global commands synced immediately
it hasn't rolled out fully to all clients/guilds, so you may see inconsistency in syncing behavior
keep getting this, is it happen because the code are slow before the loop starting again?
How do we join the if statement to a button like if button == "button1"
you generally do this within a callback and refer to the interaction's custom_id
Hi, I am struggeling with setting up a object, can someone help me with that? I never really done OOP before :D
How do I make the button or select never dies like after a time it says interaction failed
Bot examples: https://github.com/Pycord-Development/pycord/tree/master/examples
Slash command/context menu examples: https://github.com/Pycord-Development/pycord/tree/master/examples/app_commands
Buttons, dropdowns example: https://github.com/Pycord-Development/pycord/tree/master/examples/views
How to know which one used the button like in message ctx.message.author
can you send me an invite by DM?
b!rtfm on_interaction
b!rtfm pyc on_interaction
@slate stirrup here, use the on_interaction function
(note it's much better to use callbacks instead of the generic on_interaction event)
- 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 beta:
pip install py-cord==2.0.0b7
Hey how i can open two modals and the info wait for two modal and then send this message?
I'm reading the docs on PermissionsV2 for setting default permissions, can I not set permissions at a role level anymore like with the @permissions decorator?
there’s no docs for permissions v2
That's not what I mean, I'm reading the Pycord docs that have been updated for permissions v2
This is all I'm seeing, so I can only assume that I can't set command permissions at a role level from the bot and will have to manually do it from the server.
yeah
Fabulous, is this just until there's more dev work done by the maintainers or is this a limitation of the Discord API now?
Because it seems like a step backwards to not have this option anymore
api limitation, user/role permissions can only be set with a bearer token now
aka bot tokens don't cut it, it's all via the UI now
all good
all in all it's a better option for bots on a scale but inconvenient for devs used to being able to adjust permissions on their end
discord: use slash commands
also discord: slash commands also don’t work
well at least they got global command syncing down to instant before enforcing them... with the delay anyway
@commands.Cog.listener()
async def on_message(self, message):
if message.guild is None:
if "red or blue" in message.content.lower():
await message.respond("shut up bunk")
this doesnt work
?tag message_content
No tag message_content found.
?tags message
message-content
?tag message-content
As of PyCord beta 5 (which uses API v10), specifying the message content intent will be required for receiving message content.
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
Docs: https://docs.pycord.dev/en/master/api.html#discord.Intents.message_content
this is for in dms correct?
it
is
the opposite
message content will only appear in DMs and messages where it is mentioned
It logs deleted msgs in dms. but idk why it wont check for stuff in dms
message.respond isn't a real method
you either want message.reply or message.channel.send
What would ListPageSource in pycord?
not sure what you mean by this
it works in my other files wym
you sure that's message.respond?
wait wdym
your code here wouldn't work because it isn't a real method, you might be confusing it with ctx.respond
oh
.reply doesnt work :(
check pinned messages please
umm i am trying to let my bot to join the voice channel
@bot.command()
async def play(ctx, url : str):
voiceChannel = discord.utils.get(ctx.guild.voice_channels, name=f"shadowvoice1")
voice = discord.utils.get(bot.voice_clients, guild=ctx.guild)
await voiceChannel.connect()```
pydiscord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice
error
That error is very self-explanatory
lmao
what was the way to format a traceback for sending it via a discord message
#969580926885580801 message
nvm
Is there a way to gray out buttons for other users besides the user that executed the command?
Or at least not allow others to press a button?
async def interaction_check(interaction) function in a View
return True to allow callback to be processed, return False to prevent (and respond to the interaction manually)
I see
thank you
is that possible?
modals have a wait() method
but the issue is with sending the other modal
because you can only send a modal as a response
Hey is a modal form out in pycord?
Here's the modal dialogs example.
Thanks
Hello,
what could be reason for the bot not working after a few hours?
Like I start my bots on vps works fine but after a few hours slash commands says "The application did not respond " or something
and normal message commands also stopped working
Issue on vps?
After restarting they work fine again
I thought that might be connection issues from the vps hosting but that seems not the case
Services like the database are working just fine
sounds like something might be blocking, but that's just a guess
umm so i just started coding a bot today after a long time of 2 years and was looking through the guide, i used the same code, did all the procedures but im getting an error every time.
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 1147, in on_connect
await self.sync_commands()
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 643, in sync_commands
registered_guild_commands[guild_id] = await self.register_commands(
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 473, in register_commands
prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id)
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\discord\http.py", line 353, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
my code is :
import discord
import os
from dotenv import load_dotenv
load_dotenv() # load all the variables from the env file
bot = discord.Bot(debug_guilds=[my guild id here])
@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")
@bot.command(name="hello", description="Say hello to the bot")
async def hello(ctx):
await ctx.send("Hey!")
bot.run(os.getenv("TOKEN")) # run the bot with the token
someone please help
did you invite the bot with the applications.commands scope?
Hey I need some help in #974652298523463701
yo
anyone know what this error means?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Extra data: line 1 column 72 (char 71)
you worked poorly with your json
think you have multiple records inside a single json file which isn't allowed
Hey how i can edit a message with id?
I solved it
srry for the late reply
I fell asleep
now I got a new error after making a few changes
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for +: 'int' and 'str'
you're trying to concat without casting
hold on a second I think I know the problem
ah okay
thanks anyway
I think I'm just too sleepy
should go to sleep soon
oh ill try that
Get the message and then edit it.
b!rtfm pyc get_message
discord.Bot.get_message
discord.Client.get_message
discord.ext.commands.Bot.get_message
discord.Bot.get_partial_messageable
discord.Client.get_partial_messageable
discord.Thread.get_partial_message
discord.DMChannel.get_partial_message
discord.TextChannel.get_partial_message
discord.VoiceChannel.get_partial_message
discord.ext.commands.Bot.get_partial_messageable
Hi, is there a way to get 2 modals in a row?
I'm looking for something like when the first Modal is finished it will need to popup a new Modal
still the same issue
Just looking for inspiration.
Slash commands has sorta made implementation of developer-only commands a little less elegant. I was wondering if anyone had some interesting methods on administrating their bot without using Discord commands? I suppose directly interacting with it via SSH would also work but figured I'd ask.
Hmm never think about SSH
dashboard
I believe you need to JUST install py-cord[voice]==2.0.0b5
Otherwise you're installing two different versions of pycord. Also, if you're running on linux, you need to install the listed system requirements.
Possible, but I'd want to avoid a public facing dashboard website. Would really need to ensure best practices on that.
hmm it doesn't work
I use ubuntu server in aws
Did you install the linux package listed on PyCord?
That looks like Alpine linux to me but I could be wrong.
I assume your hypervisor is Docker on Ubuntu, though. But the program itself is running in an Alpine Linux container.
yes
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - GitHub - Pycord-Development/pycord: Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API
Just my guess, though. I've never tried voice stuff with PyCord.
Xd which I am not attentive
No worries, hahaha
😁 Reading docs all day sorta melts the brain after a while. I've been there
I just didn't think to finish reading this sentence😂
I read this and nothing more. Hah
Is it possible to change bot's avatar? Was looking at the Bot & Client classes but doesn't look like there's some change_avatar() or something
Found it, the edit() one accepts avatar parameter
I think that not possible. But maybe I'm wrong
its possible
It is posted above ^ it's the edit()
hmm
bot.user.edit(avatar=link/iamge)
The package name is libffi-dev
I currently have this slash command, the options are not showing up for the integration but the command works fine otherwise. Any ideas on whats going wrong with this?
Someone knows you know how to fix it?(docker)
not sure why i'm getting this, any help?
install py-cord==2.0.0b4 or older
i just git cloned, ty tho
Ok
Hey guys.
How to use custom emoji in label of button?
use emoji= instead of label
for emojis, that is
if you want normal text too, you can put your emoji in emoji= and text in label
I want to add spaces on the sides of the emoji to make the button stretch, how can I do that?
idk, maybe try using the invisible char in the label, might stretch the buttons a bit, not sure though
the invisible char is \u200b btw
@crimson coral having another slash command issue, for this one it runs fine the options do not show up though. Everything is lower case so im not sure what I am doing wrong on it.
hi i saw this.
@bot.event
async def on_message_delete(message:discord.Message):
guild = message.guild
if message.guild:
print(message.author)
# get message deleter from auditlog
try:
audit_logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.message_delete).flatten()
deleter = audit_logs[0].user
#channel = audit_logs[0].channel
print(deleter)
#print(channel)
except IndexError:
return
how do i use this channel thing from the docs
I think I know the answer, but just as a sanity check, are you able to have any arguments for Message application commands?
For an easy to understand example, if I wanted to have a "RemindMe" type command, you'd right-click and select Remind, and then get a prompt for the duration
Can it be checked what invite link a user used to join the server? I'd like to have users receive different roles based on the URL they join
Have seen the "hack" where you can check by the invite count, but that's so hard if there are 2+ users joining at the same time 😦
TypeError: object TextChannel can't be used in 'await' expression
ok im either being dumb or the latest update to support forum channels broke somit
you have to do it in a on_member_join
you could check your "invites_before"invites you stored in db and "invites_after"guild.invites()
and then check the invite.uses and find the invite code
Was afraid that was the only way :/ as I said, it's a bit hard since I have a lot of multiple users a second influxes which if I'm not careful enough might missfire a lot of times. I guess I'll drop the idea and figure another solution
is there a way to check if someone is boosting a certain amount of times. ?
Theres no key called whitelistedmembers
Same error here 🤨
I know but how?
heya
how can i create a slashcommand and add a default role permission to it?
with older versions of py-cord something like this worked for me
@bot.slash_command(
guild_ids=[GUILD_ID],
default_permission=False,
permissions=discord.CommandPermission(314100296819277824, 1)
)
but ye... permissions v2 ruined it i guess
can i create default role permissions with this one?
https://docs.pycord.dev/en/master/api.html#discord.commands.default_permissions
and if so, how?
they're only showing discord permissions not roles
did something break bcz of new update?
is there a way to check if someone is boosting a certain amount of times. ?
Hey how i can edit a message with id?
You cant edit other peoples messages
iirc
i know, i mean a bot messages
yeah but how i can edit with id?
so Prefixedit MessageID
yk?
i want a another bot messages editing yk? so with command
Example ?
your bot can only edit messages it sends
I know this want i do xD
ok
you would either have to get the message first using the id, or if it’s in the same command you can do:
msg = await ctx.send(“hi”)
await msg.edit(edited message)
OH ik what he wants
yeee 
he wants to do something like
bot:hello bruh (edited)
/edit msgid: 676798967867 message: bruh
and argument is msgid and message ?
Those are just names of the arguments
yeah also ctx, msgid, message so?
You can using this method:
msg = bot.get_message(the_message_id)
await msg.edit("hi")
Guess you can then
thanks guys 
no problem!
i helped :D
Can await self._bot.http.bulk_upsert_command_permissions(self._bot.user.id, guild_id, guild_cmd_perms) be bypassed in sync_commands when starting the bot? To avoid the v2 perms issue and it returning error 405 Method Not Allowed.
u can upgrade to master where v2 is supported already
So i have this
@slash_command(description="🧸› Add Feature to the Embed (Admin / Management) 🔐")
async def zembed_create2(self, ctx, msgid):
msg = bot.get_message(msgid)
await msg.edit(content="test")
but error is there..
Ignoring exception in command zembed_create2:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 825, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Modal.py", line 63, in zembed_create2
await msg.edit(content="test")
AttributeError: 'NoneType' object has no attribute 'edit'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
await injected(ctx)
File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'edit'
I'm probably doing it wrong. Ran pip install -U py-cord --pre after having uninstalled py-cord first, but running into the same issue (Error 405). I'll have to check on how to properly upgrade to master.
Never mind, I figured it out rather quickly. Cheers.
client.get_message can return None because it only looks in the cache. If you want to always get a message, you should use await ctx.channel.fetch_message(id) instead
Have this issue too
so?
@slash_command(description="🧸› Add Feature to the Embed (Admin / Management) 🔐")
async def zembed_create2(self, ctx, msgid):
bot.get_message(msgid)
await ctx.channel.fetch_message(msgid)
but this is not working.. no error and no edit my message
no you're replacing the part that edits the message. replace msg = bot.get_message(msgid) with msg = await ctx.channel.fetch_message(msgid)
yeah thanks its working! 
np
is there a way to check if someone is boosting a certain amount of times. ?
pls help, Ive asked this question 3 times already :(
Getting a Import "discord.commands" could not be resolved error on the master branch 🤔
self.add_item(discord.InputText(label="Short Input", placeholder="Placeholder Test"))
TypeError: __init__() got an unexpected keyword argument 'label'
Any clue why this could be happening ? The code is 1:1 from https://github.com/Pycord-Development/pycord/blob/master/examples/modal_dialogs.py
it's discord.ui.InputText
import discord
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="-", intents=intents)
@bot.event
async def on_ready():
print("BOT Ready!")
print("Name: {}".format(bot.user.name))
print("ID: {}".format(bot.user.id))
bot.run("TOKEN")
WHERE I PUT THE TOKEN?
I edit
you install py-cord?
I'm getting object TextChannel can't be used in 'await' expression when using await channel.send(embed), but when I remove await it says channel.send was never awaited 🤔
yes
hmm
i install py-cord.
use venv
what is venv?
what?
Hey, could i get some help with 2 things ??
- How can i check how many boosts someone has?
- How could I compare two keys in one dictionary??
like {"bruh": 123 , "hurb": 556}
I want to compare the keys of those two
well, dict.keys() lists all the keys of a dict
dict.keys() isnt iterable pretty sure
I think it is
im trying to sort keys alphabetically
also why is everyone ignoring question 1 like cmonnnn
you can’t
ok well ive been trying to get an answer like that for agese
So how would I get the next key ?
for loop?
this is what I have so far
nameDict = {"Darryl": "2341", "Cecil": "9102", "Beth": "3258"}
def sortDict(nameDict : dict):
newDict = {}
for key, value in nameDict.items():
tmp = str(key).lower()
if tmp[0] > tmp[1]:
newDict[key] = value
it doesnt work obv but im stuck here
.
thats the thing im trying to sort using my own sorting algorithm
hi I would like to ask how do you make a ctx.respond but it's private
so that only the ctx.author can see it
do await ctx.respond(msg, ephemeral=True)
alright thanks
How would I check for the version i currently have of pycord ??
hello, currently running bot on replit. found a solution for the ratelimit on the platform. i'm wondering if there are any downsides to doing this:
try:
bot.run(os.getenv('TOKEN'))
except:
os.system("kill 1")```
curious, is this not valid under the new option rewrite system?
@commands.slash_command()
async def spotify_info(self,
ctx: discord.ApplicationContext,
member: discord.Member = discord.Option(
description="Enter the mention or ID of a member.",
required=True
),
) -> None:
I'm currently on the latest master branch commit
the option itself is visible but the description does not appear and it is not a required argument
same thing happens here:
@commands.slash_command()
async def reload(self,
ctx: discord.ApplicationContext,
cog: str = discord.Option(
description="Select the cog to reload.",
choices=["config", "development", "general", "moderation"],
required=True
),
) -> None:
no choices appear either
@slash_command ig
not an issue with the slash command decorator afaik, worked fine with the same decorator before modifying how the options are written
how to add a specific role to a user
await self.lmbot.add_roles(role=)
in tthe role option do we give the name of tthe role?
You pass a role object
if i am doing something like this
user = interaction.user.id role = discord.utils.get(user.guild.roles, name="Student") await self.lmbot.add_roles(user, role=role)
i get an error
role = discord.utils.get(user.server.roles, name="Student") AttributeError: 'int' object has no attribute 'guild'
when i type import dis discord is not suggested ( only dis and disutils )
user is an int
No idea why you're doing user.server.roles
When you can simply do interaction.guild.roles
And add_roles is for the member object.
So interaction.user.add_roles()
ok
Read the docs. And read your own code when an error shows up.
How do I work with cogs and Views?
is there any special methods/classes which makes Views easier to work with Cogs?
seems like all methods fetching text channels have gotten bugged
all my bots died so hard
im getting a 405 method not found error in the terminal
but my commands seem to work
How do you get the invite link someone used when they join the server?
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 352, in _run_event
await coro(*args, **kwargs)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 793, in on_connect
await self.register_commands()
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 338, in register_commands
to_update = update_guild_commands[guild_id]
KeyError: 910860626837004308```
whats this error?
i want to list only the members who have the specific role teacher in the teacher parameter in slash command how do i do that?
https://cdn.discordapp.com/attachments/974905007642132531/974933871437164594/unknown.png
Hey, how i can check if the bot has the channel permissions? If not, an error should come
did slash permission v2 release?
please can anyone help me?
apparently i cant send the message to this channel why?
i have specified the channel too?
i get this error
object TextChannel can't be used in 'await' expression
https://cdn.discordapp.com/attachments/974956691340808233/974956691793780756/unknown.png
what channel that you specify can I see?
You can specify the channel by using client.get_channel() method.
Here is some example.
channel = self.bot.get_channel(channel id here)
await channel.send(embed = embed)
Ah, thank you!
try to use the master branch. I had this issue before too
Use ctx.message.channel.reply instead
Already fix that issue
what about self.client.channel.fetch_channel(id)
is it possible to align only two fields in a row in embeds?
may i know what version are you using?
you'll need to experiment with inline=False in some fields
do note that inline=False forces fields with that attribute to their own row no matter what
2.0
pip install -U git+https://github.com/Pycord-Development/pycord
installed using this
did you follow the guide in ?tag replit ( do it in #app-commands )
to install it
cuz it seems like you are using replit
how to send a modal in a interaction without response
ok
do you mean to say that sending a modal after invoking the slash command?
Why is the embed limited to that size? I want it to span wider
is there any way of doing that??
is just limited to that size
oof F
if you are using a computer
if phone it will be smaller
and cut off half
yes discord mobile moment
i want to send a modal after selecting in a select menu
https://github.com/Pycord-Development/pycord/blob/master/examples/views/dropdown.py replace send_message to send_modal
just that
no i dont mean that
then wdym
i have responed to the interaction before
Im getting RuntimeWarning: coroutine 'Client._run_event' was never awaited when trying to use discord.Bot.dispatch apparently it cant find the event loop for some reason, does anyone know how to solve this?
ok and?
an interaction can only be responded ones
you could send a Button in the select menus respond and make the button send a modal
is there a way to do a thing like followup.send_modal
no, and i dont think discord will implement this
nvm I just added the dispatch into a create_task and it works now
self.client.get_channel(channel id)
How do I make a command both a user command and a slash command?
Hey, how i can several datetime formate usen?
time_give = {"d": 86400, "h": 3600, "m": 60, "s": 1}
time_giveaway = int(time[:-1]) * time_give[time[-1]]
timestamp = (datetime.datetime.now() + datetime.timedelta(seconds=time_giveaway)).timestamp()
timestamps = int(round(timestamp))
So when i use 1h 30m is not working.. I know have to re use something but how?
so only 1d or 1h or 1m or 1s is working but not more..
also 1m 1s is not working..
Error:
Traceback (most recent call last):
File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
await injected(ctx)
File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ValueError: invalid literal for int() with base 10: '1m 1'
Ignoring exception in command giveaway:
Traceback (most recent call last):
File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 825, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\zReaxr\PycharmProjects\Discord\extensions\Commands.py", line 45, in giveaway
time_giveaway = int(time[:-1]) * time_give[time[-1]]
ValueError: invalid literal for int() with base 10: '1m 1'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\bot.py", line 1098, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 331, in invoke
await injected(ctx)
File "C:\Users\zReaxr\PycharmProjects\Discord\venv\lib\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ValueError: invalid literal for int() with base 10: '1m 1'
How do I create a button for a slash cog command?
Hey, sorry for a noob question. Just started off with python and I wanted to make a bot which is interactive, shows buttons with some images. Sort of like you've to choose an image from a list of images.
And... I just got to know(or maybe i'm wrong) about the weird stuff of official discord not providing much support. I'm having trouble with running some alternatives and discord-components library is working for me.
Problem is, Button class object is not iterable and I want to make buttons according to the input provided by the user.. and that can vary.
Any help is much appreciated.
await interaction.followup.send(view=BadFeedback(title="Willkommen im lol!"))
why isnt this working?
error:
Ignoring exception in view <FeedbackView timeout=None children=1> for item <Feedback placeholder='Gib uns Feedback...' min_values=1 max_values=1 options=[<SelectOption label='Sehr Schlecht' value='Sehr Schlecht' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>, <SelectOption label='Schlecht' value='Schlecht' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>, <SelectOption label='Ausreichend' value='Ausreichend' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>, <SelectOption label='Gut' value='Gut' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>, <SelectOption label='Sehr Gut' value='Sehr Gut' description='Bewerte bitte unseren Support!' emoji=<PartialEmoji animated=False name='⭐' id=None> default=False>] disabled=True>:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/discord/ui/view.py", line 371, in _scheduled_task
await item.callback(interaction)
File "/root/NarcoCityTicketBot/main.py", line 980, in callback
File "/usr/local/lib/python3.9/site-packages/discord/webhook/async_.py", line 1546, in send
data = await adapter.execute_webhook(
File "/usr/local/lib/python3.9/site-packages/discord/webhook/async_.py", line 213, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0: The specified component type is invalid in this context
Hello im trying to do a select role menu, it works but sometimes i have an error that i dont understand. here is my code and the error
what is BadFeedback
a modal
the problem is...
i responed already
can i edit the view without response?
yes
how?
just do a message edit with the view
my current code:
**self.disabled = True
await interaction.response.edit_message(view=self.view)
if data <= 3:
print(data)
await interaction.followup.send(view=BadFeedback(title="Willkommen im lol!"))
followup.edit_message?
how do you mention @everyone in a message?
just do @everyone
.
sorry i framed the question wrong
i want a command to recognise when i do >>hug @everyone
how do i detect when @everyone has been mentinoed?
Can someone help me pls? :((
im having smoothbrain moment
If you want to check if the mention actually worked you can use mention_everyone
Thank you!
sorry got a typo xD
Traceback (most recent call last):
File "main.py", line 2, in <module>
import discord
File "/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/__init__.py", line 25, in <module>
from .client import Client
File "/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/client.py", line 53, in <module>
from .webhook import Webhook
File "/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/webhook/__init__.py", line 12, in <module>
from .async_ import *
File "/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/webhook/async_.py", line 52, in <module>
from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/home/runner/bot-TBW/venv/lib/python3.8/site-packages/discord/channel.py)
bro wtf even is this error
i coded literally the simpliest concept of bot possible
import discord
import os
bot = discord.Bot()
@bot.event
async def on_ready():
print("on-line")
TOKEN = os.everion['TOKEN']
bot.run(TOKEN)
the bot dont have even a single command wtf is the error
i installed pycord v7
can you help me too pls
i want to make "n" buttons instead of specific no. of buttons
@jolly charm dont dm me or others/dont ping / be patient ; #help-rules
Make a constructive post, show your code/errors.
And describe what you exactly want. I'm sorry, but you both in dms and here you dont make much sense (considering you didnt show any code)
I don't know how to code that.. that is the exact problem. I haven't used pycord.. coz it's not working for me, discord_components is though.
Here's a code which doesn't work on my end (also doesn't give errors), i've installed pycord.
import discord
from discord.ui import Button,View
from discord.ext import commands
bot = commands.Bot(command_prefix=">>>")
@bot.command()
async def hello(ctx):
button = Button(label="Click me!",style=discord.ButtonStyle.green, emoji="👋")
view = View()
view.add_item(button)
await ctx.send("Hi",view=view)
from config import TOKEN
bot.run(TOKEN)
What I exactly want is:
- How to implement N buttons instead of specific buttons. which i'll make for a data fetched from an api
How are you planning on getting N buttons tho?
You could just use a for loop and at the end use view.add_item
Looping thru the users input
While implementing buttons through discord_components, i tried to do a for loop, then append button to a list.. as components is usually a list of list of buttons..
That didn't work since buttons are objects and objects aren't iterable
Hey! thanks for the input.
Can you please link to me a small piece of code to implement a button.. I'll try to implement the for loop and append buttons items to the view.
The code i sent above doesn't show any errors and doesn't work for me.. (even if i send a prefix on the server for the bot)
also embed that you showed in dm screenshot is done with ext.pages https://docs.pycord.dev/en/master/ext/pages/index.html
I'll try
also check guide buttons section https://guide.pycord.dev/interactions/ui-components/buttons
yeah.. I showed that, as I want to implement something like that. That would be a great alternative. Sorry I don't have much idea of these things.. just started off with bots in python.
I'll try that code for the reference you sent. Thanks @stable tiger
timestamp=datetime.datetime.utcnow()
anyone wanna help me??
usually it means you have not properly done "uninstall all other discord libraries -> install fresh py-cord" operation
How to pass a tuple to @commands.has_any_role()?
Like I have roles as a list of roles
I want to use it like @commands.has_any_role(roles)
embed.timestamp(unixtime)
^ use this to get unix timestamp
Hi, I'm wondering if there's any way I can set permissions for Slash Commands inside a Slash Command Group. Eg:
Managers can use /mod ban
Moderators can use /mod mute
Trial Mods can use /mod warn
As far as I'm aware, Discord's Integration menu only allows you to set permissions for the surface level commands/groups
nope
you can use checks to accomplish this though, they'd be on the bot side not on the client thoufh
Hope discord will consider doing permissions per command or at least per subgroup 😦
im getting depressed
my bot have literally 13 lines of code
import os
import discord
bot = discord.Bot()
tbw = [974818131728015360]
@bot.event
async def on_ready():
print("on-line")
TOKEN = os.everion['TOKEN']
bot.run(TOKEN)
this is the entire bot
STILL CANT START IT
Traceback (most recent call last):
File "main.py", line 2, in <module>
import discord
File "/home/runner/TBW/venv/lib/python3.8/site-packages/discord/__init__.py", line 25, in <module>
from .client import Client
File "/home/runner/TBW/venv/lib/python3.8/site-packages/discord/client.py", line 53, in <module>
from .webhook import Webhook
File "/home/runner/TBW/venv/lib/python3.8/site-packages/discord/webhook/__init__.py", line 12, in <module>
from .async_ import *
File "/home/runner/TBW/venv/lib/python3.8/site-packages/discord/webhook/async_.py", line 52, in <module>
from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/home/runner/TBW/venv/lib/python3.8/site-packages/discord/channel.py)
help please
i cant do this anymore
Literally got an answer here
@clever lava
ok but what should i do
or where should i go
check for any libraries relating to discord, uninstall them, reinstall pycord
k
ty
NICE
Traceback (most recent call last):
File "main.py", line 4, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'
what version of pycord are you on
pip list or python -m pip list
python -m discord -v also works
how to add description to a slash option?
async def test(ctx, option1: Option(str, description="description here")):
Option(str, description="description here")
here
the first arg should be the type of the option
in this case its an string
for example when you need a member mention
Option(discord.Member, description="choose a member")
nice, thank you
will tell you the syntax hold on
another quick question, how to add slash commands to server commands? (because global slash takes ~1 hour to update, right? and I need to test something quickly)
hm
I tried searching on docs but no quick answer, hmm
so you right click the server you want to make the command
click on copy id
then you create a variable
named everything you want
like this
test_server = [id goes here]
@bot.slash_command(guild_ids=test_server)
...
oh huh, alright! 👌
about this one
from discord.commands import Option
@bot.slash_command(guild_ids=[...])
async def test(ctx, option1 : Option(str, description="description goes here")):
await ctx.respond(option1)
you need to import options first
wat
make sure you've uninstalled all other discord libraries and install the latest pycord version 2.0.0b7
i deleted the entire sht then created another screw it
Oh right
and still giving me errors
import os
import discord
bot = discord.Bot()
tbw = [974818131728015360]
@bot.event
async def on_ready():
print("on-line")
@bot.slash_command(guild_ids=tbw)
async def test(ctx):
await ctx.respond("Hello world")
TOKEN = os.everion['TOKEN']
bot.run(TOKEN)
can anyone please help im getting mad with this bot
this is the simpliest concept possible of a bot
hmmmmm 
and just dont work
wut is that os.everion
its an thing to hide my token
ah
idk im not english native
ye
daamn and I wanted to submit the bot in about 8 minutes for some itch.io jam
guess I can't xD
im almost giving up
oh huh, it worked for me, your code
the bot didn't show up in the sidebar when typing / but when I typed /test it worked
hm
i think your problem is having other bots in same server
thats why when you type the command shows up
no way
NOWAY
THANK GOD
after all day long
why its so hard to create a bot aaaaaaaaaa
lolol, gz
For some reason, slash commands are not being registered despite the fact I have one implemented AND I have the server ID in the list of debug_guilds for the bot.
I enabled DEBUG level logging and looking in the log there are lines that say this:
2022-05-14 00:08:48,202:DEBUG:discord.bot: Skipping bulk command update: Commands are up to date
There are no errors.
I have kicked the bot from my server and had it rejoin several times. I have also removed and readded the integration.
I have made sure it has the correct permissions (both Administrator and application.commands).
I'm using the latest version of the library from the github repository .
autorole works as same as discord.py nowdays?
Are you asking me? Because I don't understand your question.
I've had this problem for over a week now.
If I can't resolve it I'll switch to another library and let other developers know about the issue.
sad
Hey how i can say time in Modal? i have tried so: time=self.children[0].value (in async def callback(self, interaction: discord.Interaction, time=self.children[0].value):).
I switched to another fork of discord.py and got commands working there.
Goodbye.
okay lmao
I have a quick question regarding part of the documentation. What is the atomic attribute for member.add_roles
Whoever ends up answering, please ping me so I can ensure I see the answer
Anyone who could please provide a sample code for page extension module. I'm too noob to implement lol
https://docs.pycord.dev/en/master/ext/pages/index.html#
I'm trying code from this repo but it's not working as it's not complete, just contains classes. Also there is no documentation
https://github.com/Rapptz/discord-ext-menus
ok i got it.. a little bit of this, thanks guys
hey guys, i really need help
i want to use discord buttons on my slash commands but i use cogs
how do i add buttons in my cogs?
https://www.github.com/Pycord-Development/pycord/tree/master/examples%2Fviews%2Fbutton_roles.py is a really good example for buttons in cogs
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/button_roles.py at master · Pycord-Development/pycord
ok this was looking really bad.
pycord has such a beautiful implementation and when I tried that my commands aren't working
!hello gives no output.
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)
ok i'm using this code now, and it still doesn't work
import discord
from discord.ext import commands
intents = discord.Intents.default()
#intents = discord.Intents()
#intents.messages = True
bot = commands.Bot(command_prefix='!',intents=intents)
@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")
@bot.command()
async def hello(ctx):
await ctx.reply("Hey!")
from config import TOKEN
bot.run(TOKEN)
i've this commented out portion.. and both gives not error
also this on_ready func() is always getting executed well
if you're on a version >= 2.0.0b5 you also need intents.message_content and the message content intent enabled in the dev portal
yes I'm using 2.0.0b7
ig dev portal is @ https://discord.com/developers/applications/ but which option do i really want to look into?
yes, go to your app, bot tab, then enable the message content intent



