#General Help
1 messages ยท Page 15 of 1
you can't use interaction.response multiple times
use interaction.followup for that
ohhhh
so rn i haveawait interaction.response.edit_message(content = None, embed=embed , view=None)
at the end
i have to change to interaction.followup
Because that's not how it works.
i think this is what i want but i have to input message_id, how'd i get that from the message the button is?
What are you trying to do
i have a command that gives you options for approve and deny
it checks if you have a role to be able to use approve and if you do it does a bunch of stuff then it edits the message the button was in to an embed and also removing button
So what you don't know?
how would i get the message id from the message the button is in?
im using view class
set the message to a variable as you await send it
then use .id on that variable
how would i add the button then in this case?
you add it in the view when you send the message
I just didn't write it in there because I'm lazy
message = await interaction.original_message()
Assuming you're in the callback
yeah that might be what you're looking for
interaction.original_message()
refers to the original message the bot sends?
asnyc def button_callback(self, button, interaction):
await interaction.response.defer()
# a bunch of stuff...
msg = await interaction.original_message()
await interaction.followup.edit_message(msg.id, content=None, view=None)
something like this then
oh, it still returns error
discord.errors.InteractionResponded: This interaction has already been responded to before
why are you doing interaction.followup.edit_message
If you're trying to edit the original message
You just have to do
await interaction.response.edit_message(content=None, view=None)```
Show your code
class View(discord.ui.View):
@discord.ui.button(label="Approve", style=discord.ButtonStyle.green)
async def button_callback(self, button, interaction):
guild = bot.get_guild(ID)
role = guild.get_member(interaction.user.id).get_role(ROLEID)
if role is None:
await interaction.response.send_message(f"<@{interaction.user.id}>, you don't have perms to interact", ephemeral=True)
else:
await interaction.response.defer()
# long code
await interaction.response.edit_message(content = None, embed=embed , view=None)
is there any way to make a user select a channel from a server? i was thinking using the wait_for but it doesnt seem to work when using slash commands
in options?
wdym
like
/choosechannel channel:general
i mean i guess that could work
but also is there a way to remove an option when in dms?
im not sure what it does in a dm channel
cause it jsut returns all textchannels
you could make it jsut optional
and check if they are in a guild or not
o yea yea
i was just wondering if there was a more better way already implemented but i dont think so
@slash_command()
async def func_name(
self, ctx,
channel: Option(discord.TextChannel, required=False)
):```
thats what you would do
np ๐
why does on ready in all my cogs never get called but other things like on_message does? only the on_ready event in my main file is working
@commands.Cog.listener()
async def on_ready(self):```
i think its because my cogs are being activated from my main on_ready in main file, is there a way to activate the cogs earlier
Hmm. What happens on the client side? What do you see? Does it edit the message?
no it doesn't seem like it
You have to load the cogs when setting the bot instance.
but the only way to load cogs are to use await bot.load_extension and i cant do that outside on_ready
the only problem that i have with the code is that the long code needs the response defer
Hmm
i think without it, only part of it is completed
Weird tbh
Why not?
it can only be used inside async functions
the basic function that i want to be done is
actually also how would i go about getting the channelid from this option?
someone with role A does command but has to wait for someone with role B to approve their command
and they do this by pressing button
which processes some stuff in google sheets
you have the channel object so you can just do channel.id
ah ok ok thank u
i'd also want to know if i can make a dropdown menu kindof for arguments in a slash command
similar to how if i have the arg to discord.User
or autocomplete the arguments
load_extension is not a couroutine
it's not, that screenshot is from the discord.py docs and not pycord
on extension load and unload
is on_ready() called
and if not
what other method is called
What versions is needed for slash command groups?
rc1 would do
is it possible to register update a command
keep the other commands registered
but force reregister certain commands
bot.register_commands() only registers commands passed
why would you do that
why do only a few slash commands show up in direct messages
cause its a custom command
how to get the vc text channel from the vc object itself?
Not sure if itโs fetch able by the api yet
Ignoring exception in command test:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 126, in wrapped
ret = await coro(arg)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 852, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "/home/container/cogs/mc.py", line 150, in test
await ctx.author.add_roles(role)
File "/home/container/.local/lib/python3.10/site-packages/discord/member.py", line 975, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 353, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 357, in invoke
await injected(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
I can't add roles. The bot has administrator permission
after using interaction.response.defer() i get a leftover response to the command from my bot that says 'The application did not respond' but i know everything has finished after i clicked my button because i have an embed sent out. how would i go about removing this reply message?
Hey guys
I need a bit of a help, I need to create a channel in a particular category. How do i do that?
@bot.slash_command(description = "Change teams for user")
@commands.has_role("Captain")
async def team(ctx, player: discord.User, team: str, tmz: str):
class View(discord.ui.View):
@discord.ui.button(label="Deny", row = 1, style=discord.ButtonStyle.red)
async def button_callback(self, button, interaction):
guild = bot.get_guild(GUILDID)
role = guild.get_member(interaction.user.id).get_role(ROLEID)
if role is None:
await interaction.response.send_message(f"<@{interaction.user.id}>, you don't have perms to interact", ephemeral=True)
else:
# buncha stuff
@discord.ui.button(label="Approve", row = 1, style=discord.ButtonStyle.green)
async def button_callback(self, button, interaction):
guild = bot.get_guild(GUILDID)
role = guild.get_member(interaction.user.id).get_role(ROLEID)
if role is None:
await interaction.response.send_message(f"<@{interaction.user.id}>, you don't have perms to interact", ephemeral=True)
else:
# buncha stuff
embed = discord.Embed(title = "Transaction Request", description = f'<@{ctx.author.id}> requests <@{player.id}> to {team} with timezone {tmz}.')
await ctx.send(embed=embed, view=View(timeout=None))
maybe my format for the command is not good since i have class inside of the function, but idk how to refer to function argument inside of class, but regarding multiple buttons, with this command right now only the 2nd button gets displayed
if i remove the row the same thing happens
For a slash command ctx.respond
Make sure to have the admin role above the role u want to give
ye that fixed it
Nice
Can you send a response to another channel upon modal callback
Hello
Does anyone have a py function that can generate discord timestamps like <t:1654610400:R> ( <t:1654610400:R>) with datetime
ty
which best fetch_guilds or bot.guilds?
And what is the difference between them?
is "content moderation" feature supported on pycord? the banned word thingy
if i have a button which is interactable. How can i do, so that i dont get interaction failed without sending a message response?
You can use interaction.response.defer() which will make Discord think you'll send the response later
Thanks
It will fail after 15 minutes.
Did your bot print we have logged in as ...
Yes
been trying to find out whats wrong for the whole day
i even copied the code exactly
where did you copy it from?
youtube
This is the Ultimate Python Guide on Buttons with Discord.py or Pycord. In this video, I talk about how to create buttons in discord.py or pycord and how to respond to button clicks along with everything about Views. After watching this you'll know everything about Buttons and Views in discord.py or pycord.
This video might also apply to other...
You need message content
The intent for normal commands
I does not appear that you have enabled intents. You need to enable the message content intent to use prefix commands
๐ฎ
how?
please help me
i tried this in discord.py but i just moved to pycord
in discord.py my code works
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="$", intents=intents)
And also go to the developer panel and enable it
In the developer panel go to your bot
"bot" tab -> scroll down -> enable the one that says message content
wrong channel
What is the cause of this error?
2022-06-07 11:56:13,419:ERROR:discord.shard: Attempting a reconnect for shard ID 6 in 2.12s
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/discord/shard.py", line 151, in worker
await self.ws.poll_event()
File "/usr/local/lib/python3.8/dist-packages/discord/gateway.py", line 582, in poll_event
raise ConnectionClosed(self.socket, shard_id=self.shard_id, code=code) from None
discord.errors.ConnectionClosed: Shard ID 6 WebSocket closed with 1000
It appears one of your shards went offline
Can you show your code again?
oh wait didnt do this
A quick search tells me that you might have to update your pycord version.
or not, ok!
We are happy to help, just a warning YouTube tutorials can sometimes become out of date. We have some examples on the github and a guide to pycord if you want to look at them
Ok I will stick to reading the docs.
how do rankcards
How do I know what caused the offline?
Im not entirely sure. I would open a thread for that.
ok
@config.command()
async def channel(self, ctx: discord.ApplicationContext, ch: Option(discord.SlashCommandOptionType.channel)):
await ctx.respond(ch)
err TypeError: issubclass() arg 1 must be a class
Someone knows how to fix it?
hii the button interaction is not working (oddly enough my other buttons work) it always says the interaction failed if im adding it to my view and no errors
discord.Client is a class, and therefore requires ()
when i do that, it say i have to wright something with self and coro
I suggest you first learn how to make a discord bot with https://guide.pycord.dev
The Official Guide for Pycord
b!rtfm pyc discord.enums.ButtonStyle
No results found when searching for discord.enums.ButtonStyle in pyc
ehm, i already made a discord bot before
i never had that error
Yeah, I didn't think discord.enums.ButtonStyle existed
lol
well lol thanks
im dumb xd
well, do you know OOP?
Could you show me this error?
sorry do disturb again but the enum thing wasnt the problem the interaction is the problem
the button was produced fine but if im clicking it it does nothing
odd thing is that my other buttons work xd
super().__init__(
label="button",
style=...,
callback=self.button_callback()
)
oh lol
I think that's how you make a button
persistent Buttons work after the restart, but if i add modal to it , its not working @slow dome
im using this example : https://github.com/Pycord-Development/pycord/blob/master/examples/views/persistent.py
so you respond with a modal?
YES
if you are completely sure there is nothing wrong with your code, open an issue on github
i just learnt about persistent buttons so im not sure
is there any example to refer too ?
well as i expected this threw an error too. callback is the method and not the attribute (dw just respond later if you have time) i will try to fix it. its like in the docs and my other buttons work idk whats wrong xd
well, change the response to something regular like a message and see if it responds or not
if it responds, congrats. you set it up correctly
ok 2 sec
can someone help me pls
my error:
Ignoring exception in command rank:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 181, in wrapped
ret = await coro(args, **kwargs)
File "/home/container/main.py", line 327, in rank
users = json.load(f)
File "/usr/local/lib/python3.9/json/init.py", line 293, in load
return loads(fp.read(),
File "/usr/local/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
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/ext/commands/bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 927, in invoke
await injected(ctx.args, **ctx.kwargs)
File "/home/container/.local/lib/python3.9/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: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
my code
@bot.command()
async def rank(ctx, member: discord.Member = None):
with open('users.json', 'r') as f:
users = json.load(f)
if not member:
member = ctx.author
next_level_xp = (users["level"] + 1) * 100
current_level_xp = users[f'{ctx.author.id}']["level"]
xp_need = next_level_xp - current_level_xp
xp_have = users["experience"] - current_level_xp
percentage = (xp_need / 100) * xp_have
background = Editor("0.png")
profile = await load_image_async(str(member.avatar_url))
profile = Editor(profile).resize((150, 150)).circle_image()
poppins = Font().poppins(size=40)
poppins_small = Font().poppins(size=30)
square = Canvas((500, 500), "#06FFBF")
square = Editor(square)
square.rotate(30, expand=True)
background.paste(square.image, (600, -250))
background.paste(profile.image, (30, 30))
background.rectangle((30, 220), width=650, height=40, fill="white", radius=20)
background.bar(
(30, 220),
max_width=650,
height=40,
percentage=percentage,
fill="#FF56B2",
radius=20,
)
background.text((200, 40), str(member), font=poppins, color="white")
background.rectangle((200, 100), width=350, height=2, fill="#17F3F6")
background.text(
(200, 130),
f"Level : {users['level']}"
+ f" XP : {users['experience']} / {(users['level'] + 1) * 100}",
font=poppins_small,
color="white",
)
file = File(fp=background.image_bytes, filename="card.png")
await ctx.send(file=file)
worked like a charm
thanks ser
first tell us what's wrong
i have an error
Hi, I can do a select menu in modal
Ty tutaj? xd
Oho siema
how to make a slash command error event
!install
Install pycord:
pip uninstall discord.py
pip install py-cord
Install pycord beta:
pip uninstall discord.py
pip install py-cord==2.0.0b7
Install pycord alpha from git:
pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
pip install py-cord==2.0.0b7
i need but thew c
one
i did it elired
to fix everthing
@slash_command(name = '')
async def test(ctx):
<code>
@test.error
async def test_error(ctx, error):
<code>
anyone know witch on it is
?
thx
it was like pip install py-cord==2.0.0c7 or something like that\
np
idk either
i dont know bruh
got
python3 -m pip install -U py-cord --pre
i needed pre
for slash commands
and shit like that
My bot seems to have stopped reading messages.
โข It is working fine on my test server, but not on my live server. I'm guessing I missed a permission when creating the URL, but if I try to select messages.read in the Discord Developer Portal it asks me for a redirect uri, and I am fairly certain I didn't select that option when inviting the bot to my test server.
Slash commands work fine! Everything but message.read is behaving correctly.
im using a vps tho lmao
maybe apart or a older verion of pycord
and it was removed in the pre
Same machine, same installation, everything. Just a different server.
Yes. And I ran it on the test server again. No errors.
hmmm
The slash commands are working perfectly.
Where?
how can i await the user to ping a role instead of sending a message then use the role for further permissions?
[My issue turned out to be PEBCAK - the bot's permissions per channel weren't properly calibrated]
how can i send a embed from json data
{
"content": null,
"embeds": [
{
"title": "kicked.",
"description": "{member.name} was kicked.\nReason ยป {reason}",
"color": 6266528
}
],
"attachments": []
}
after i use a slash command and interact with a button, there is a leftover reply that says the application did not respond but i see that everything i wanted to happen after clicking the button worked. is this because of interaction.defer()? how would i fix this
you guys like it?
ik its pretty much a remkake of this bots but i loved it so
ya
Here's the slash cog groups example.
you need to respond to the interaction
?
bro why would u want to
cuz i can copy it from discohook
and theres no reason to
...
bro what
why use json data when you can just construct the exact embed without json?
exactly
bruh
embed=discord.Embed(title="Moderation", description=""" example
then just call it
bye doing embed=embed
https://docs.pycord.dev/en/master/api.html#embed heres the docs
its easy
ong
I KNOW HOW TO DO A EMBED
Ignoring exception in on_member_join
Traceback (most recent call last):
File "pythonProject/venv/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
TypeError: Member.on_member_join() takes 1 positional argument but 2 were given
hold
theres no reason to
help by that error
bruh
just read the error
TypeError: Member.on_member_join() takes 1 positional argument but 2 were given
yes
then you need to add self as the first arg
@commands.Cog.listener()
async def on_member_join(self):
async def on_member_join(member):
role = get(member.guild.roles, id=896705950688370688)
time.sleep(30)
await member.add_roles(role)
await member.edit(nick=f"ๆงๆๅก | {member.name}") @commands.Cog.listener()
async def on_member_join(self):
async def on_member_join(member):
role = get(member.guild.roles, id=896705950688370688)
time.sleep(30)
await member.add_roles(role)
await member.edit(nick=f"ๆงๆๅก | {member.name}")
@sleek grove
?
add member to the first function def and get rid of the duplicate
main
problem solved
@commands.Cog.listener()
async def on_member_join(self, member):
async def on_member_join(member):
role = get(member.guild.roles, id=896705950688370688)
time.sleep(30)
await member.add_roles(role)
await member.edit(nick=f"ๆงๆๅก | {member.name}") @commands.Cog.listener()
async def on_member_join(self):
async def on_member_join(member):
role = get(member.guild.roles, id=896705950688370688)
time.sleep(30)
await member.add_roles(role)
await member.edit(nick=f"ๆงๆๅก | {member.name}")
I got rate limted on replit, I fixed it but I was wondering what was the reason that the bot got rate limited?
like this?
BRO
its so easy to fix
get rid of the duplicates
sorry im a beginner
so am i but like damn
to python as a whole or just pycord?
ik
i just read errors and code
easy
and READ THE DOCS
lmao
litteraly everying is in the docs
and here
examples
everything
bro chill
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/examples at master ยท Pycord-Development/pycord
use this
is it possible to have mutliple on_message event listeners?
yes
well it doesnr seem to work
not using @bot.event though, theres a different decorator
and what i mean by that is
@bot.listen
async on_message(message):
actually?
bruh wtf
i never knew that lmao
https://docs.pycord.dev/en/master/api.html#discord.Bot.listen because youre not providing it an event name to listen to
?tag lp
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
such as?
"on_message"
where
huh
do i find back ground wallapers like this
besides the logo
just the wallpaper behind it
not here
lol
i see
i had two on_messge functions
so why should i do instead
do i just name it different;y
of course
youre also missing the crucial part of actually telling the decorator which event to listen to
as in?
how can i check if member is = to self cancel author.id i have no clie tbh
i looked through docs
i cant find anythin
what?
so if a user trys to mute them self how do i say u cant do that
just compare the target id to author id
How is the dm function in cogs?
yes
ok'
E, once again got rate limited
what are you asking for here?
so i want to dm a user after kick and i dont know the funktion in a cog
await user.send()
also dm them before kicking
because if they arent in the server, the bot cant dm them
ah
i have already testet it but i have put it after the kick
why?
I believe the bot can DM them unless their privacy is on that friends can only DM (thought I'm not entirely sure)
server presence is also a factor
if the user isnt present in a server that both the bot and user share then the bot is unable to dm them
yes but if you have activated it it is your own fault
How do I edit an interaction?
await interaction.edit_original_message()
@client.slash_command(name="help", description="Opens a select menu based on helping.")
async def menu(self, ctx):
select = Select(options=[
discord.SelectOption(label="Moderation", emoji=None, description="Shows all the available moderation commands."),
discord.SelectOption(label="Fun", emoji=None, description="Shows all the available fun commands.")
])
embed=discord.Embed(title="Moderation", description="""
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!
""", color=discord.Color.dark_gold())
async def menu_callback(interaction):
await interaction.response.send_message(embed=embed, ephemeral=True)
select.callback = menu_callback
view = View()
view.add_item(select)
await ctx.respond("What command do u need help with: ", view=view)
def setup(client):
client.add_cog(help(client))
so i have this but i wanna have it embed another
embed
based on fun
commands
but I'm confused how i can so that with the first embed already there
you can manipulate the attributes
plus an easier method to doing this is to instantiate an embed in the callback and then change the attributes based on the selected option
๐
uhh
how do i do that
@crimson gale
?
lmao
compare select.values[0] to the value of the desired option (label = value if not specified in SelectOption) and then do the desired actions
async def on_message(message):
if bot.user.mentioned_in(message):
await message.channel.send('Hello! I assume you are wondering who i am? \n I was created by @ignfoolish#0396\n I was created for the server Felbcord and i am useful for moderation and fun commands! ')``` How do i make it reply only on single mention eg
@felbcord utils
instead of
@felbcord utils hello
How do I put a local image as the image of an embed?
from code import interact
from select import select
import discord
from discord.ui import Select, View
from discord.ext import commands
from discord.commands import SlashCommand
client = commands.Bot()
class help(commands.Cog):
def __init__(self, client):
self.client = client
@client.slash_command(name="help", description="Opens a select menu based on helping.")
async def menu(self, ctx):
select = Select(options=[
discord.SelectOption(label="Moderation", emoji=None, description="Shows all the available moderation commands."),
discord.SelectOption(label="Fun", emoji=None, description="Shows all the available fun commands.")
])
embed=discord.Embed(title="Moderation", description="""
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!
""", color=discord.Color.dark_gold())
async def menu_callback(interaction):
await interaction.response.send_message(embed=embed, ephemeral=True)
select.callback = menu_callback
view = View()
view.add_item(select)
await ctx.respond("What command do u need help with: ", view=view)
def setup(client):
client.add_cog(help(client))
this all i have
i need help
this is the exact same code?
no
e
i added a little
bit
where?
this orignal code
i need help with the mbed part
so if u choose fun it only shows info about fun commands
vise versa
right here
i literally told you
thats what i need help with
what i told you is the solution
Anyone? Tried on docs lol
select.values is the list of chosen options, [0] grabs the first element of that list, that is then compared to a predetermined value to check the chosen option and then do the desired actions
ok but how do i use select.values to check if it is what ever usaid
compare
ik if
is equal
yes there is
"Moderation" or "Fun"
embed=discord.Embed(title="Moderation", description="""
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!
""", color=discord.Color.dark_gold())
async def menu_callback(interaction):
await interaction.response.send_message(embed=embed, ephemeral=True)
ok but these are connected
ig
u can say
just copy and paste this again
and do the same thing
youve hardcoded the response to send the embed
you cant do that if you want the menu to be able to show a different embed
i was checking my command and it stopped working suddenly saying local variable 'teamc' referenced before assignment so i tried testing it by itself first. my function is:
def test(team):
if team in ["Red", "Green", "Blue"]:
teamc = 1
elif team in ["Apple", "Banana", "Pear"]:
teamc = 2
if team in ["Red", "Apple"]:
start = 1
end = 5
elif team in ["Green", "Banana"]:
start = 7
end = 11
elif team in ["Green", "Banana"]:
start = 13
end = 17
help?
i tried to print teamc, start, and end but they all result in local variable referenced before assignment
either it's my bot or it's something else
u have pre installed
what thing I do not underestand
why did you erase all of your progress?
i still have iut
i did not tell you to do that
reinstall pycord
ok
how do i fix
fix what? the error in the terminal?
dont ping without permission bruh
shush
right so you have the callback ready?
not quirte yet im working on it right now so for my call back args i just leave it blamk?
well you need the interaction
ya ik
async def menu_callback(interaction):
await interaction.response.send_message(embed=embed, ephemeral=True)
select.callback = menu_callback
this
but leave the embed=embed aout
leave args blank
oh
!install
Install pycord:
pip uninstall discord.py
pip install py-cord
Install pycord beta:
pip uninstall discord.py
pip install py-cord==2.0.0b7
Install pycord alpha from git:
pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
regardless of the installed version, that should never appear
no u need pre
except the fact that thats the wrong package
rebuild it
How do I update it?
pip rebuild py-cord
me?
pycord and py-cord are two separate packages
oh
anyway, install the correct package
which?
!install
Install pycord:
pip uninstall discord.py
pip install py-cord
Install pycord beta:
pip uninstall discord.py
pip install py-cord==2.0.0b7
Install pycord alpha from git:
pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
pip install py-cord==2.0.0rc1
yes
that one
that should 100% work
i actually need that thx
its for my host
server
import discord
from discord.ui import Select, View
from discord.ext import commands
from discord.commands import SlashCommand
client = commands.Bot()
class help(commands.Cog):
def __init__(self, client):
self.client = client
@client.slash_command(name="help", description="Opens a select menu based on helping.")
async def menu(self, ctx):
select = Select(
placeholder="Choose your help category:",
options=[
discord.SelectOption(
label="Moderation",
emoji="๐จ",
description="Shows all the available moderation commands.",
),
discord.SelectOption(
label="Fun",
emoji="๐ธ",
description="Shows all the available fun commands."
),
]
)
if select.values[0] == "Moderation":
embed=discord.Embed(title="Moderation", description="""
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!""")
async def menu_callback(interaction):
await interaction.response.send_message(embed=embed, ephemeral=True)
select.callback = menu_callback
view = View()
view.add_item(select)
await ctx.respond("Choose what menu u wanna see: ", view=view)
def setup(client):
client.add_cog(help(client))
so i have this
so far
@crimson gale
is this correct?
the check needs to be ran inside the callback
oh ok
otherwise it is correct
async def menu_callback(interaction):
await interaction.response.send_message(embed=embed, ephemeral=True)
if select.values[0] == "Moderation":
embed=discord.Embed(title="Moderation", description="""
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!""")
select.callback = menu_callback
view = View()
view.add_item(select)
await ctx.respond("Choose what menu u wanna see: ", view=view)
like this?
before the response
then do the same thing for fun
await interaction.response.send_message(embed=embed, ephemeral=True)
before that line
obviously
ok
you should use elif for the other one to cut out unnecessary comparison
ok
guys, this is general help. If your topic is this extensive, make a thread on #969574202413838426
dont need to be a mini-mod thanks
ok moth guy
he i created a thread
no. that breaks a rule
โDonโt post same question in multiple channelsโ
no, it doesnโt matter
also that rule is a bit outdated
something like "dont make duplicate posts" is more appropriate
and โYou can ask for any helpโ
3. To ask for help, create a post in help. Remember that talking unnecessarily or creating useless posts is not allowed.
sry, keyboard bugged out
If you want to debate this, we can take it to DMs
bro we can obviously just go to #help-rules like the other dude said stop being a MINI MOD
ok bro, if you want constant help im just saying, easier to make a thread than flood #969580926885580801
you never even helped me
bro stfu your digging a missive hole for your self and you sound stupid
. . .
leave it at that
youre gonna get yourself in trouble with the mods if you keep that up which is why im saying that as a courtesy
mate im being polite, that cupcake dude is shouting at me lmao
it goes for the both of you
bruh can we calm down, it rly isnt that big of a deal
def pow(team):
if team in ["Tokyo Fart Sniffers", "Neko Cavaliers", "Miami Jits", "Milan Mafias", "Sao Paulo Macacos", "Sendai Sharks", "Cairo Mambas", "New York Rats"]:
teamc = 6
print(teamc)
pow("Tokyo Fart Sniffers")
```i was testing my command but i received an error saying `UnboundLocalError: local variable 'teamc' referenced before assignment` so i took out the function and tested it by itself
i'm still getting the same error
the condition is not true and thus teamc never gets assigned
nice team names btw
LOL
ah ok
i had to manually write the names from google sheets so i think i just mistyped
now nothing comes out
could be, but if team isnt in that list, teamc will never be assigned and you will run into that error
make sure that you error handle this
congrats, it works now probably
i got the value printed out
yea i have an else
but idk if i have to have it because i plan on making the team options with drop down OptionChoice
then you wont need to
couldn't you indent the print statement below the if statement?
unless with the error hander as walmart said ignore what I said
that comes out
then it works just fine
anyone know a reoad command i can use?
i need one
really badly
and well tbh i have no clue on how to code one
Hey ya'll, I'm trying to debug something here and figure out why my bot is crasing
I've got some really simple code setup that should just log every message being sent but it crashes with AttributeError: 'TextChannel' object has no attribute 'news'
I looked online and someone said to use the github version instead of the pip version but that didn't work
Here's the full code:
@bot.event
async def on_message(message):
if message.author.bot:
return
print(message)```
For some reason that print statement is just crashing the bot. I've enabled the messages intent but it still crashes
i believe its cuz your if statement isn't checking anything
oh wait
nvm
sorry
my bad
perhaps it doesn't have access to it or doesn't have the perms?
It has administrator perms in the server
its code
It should be able to see the whole server
its has admin?
Ye
i've installed the pycord library like it says to do in the github, yet when i run my code it says no module named discord
import discord
ModuleNotFoundError: No module named 'discord'
import discord
from custommodules import infoclass
version = infoclass().FOW_VERSION
bot = discord.Bot(...
what's the difference between the two?
one has a hyphen and one doesn't
i think pycord is a dfiferent libraries name
oh so whole different one
ye
bruh opera
?
whats wrong with opera
its so bad
in what way
its litteraly found in virus
slow, slows down pc, adds and more
its just ass
much faster than chrome for me
nah
\
chrome so fast for me
well i had better experiences with opera
so im sticking with this
oh
everyone has opinions, deal with it
can we focus on the task at hand
?tag install
-
Uninstall
discord.pyor any other forks of discord.py you might have with the namespacediscord.
python -m pip uninstall discord.py discord -y -
Install
py-cord
python -m pip install py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
Updating to release candidate:
pip install py-cord==2.0.0rc1
hm
still no luck
unistall pycord
what's the error message?
is there a stop the bot funktion?
if rnames in ['Tokyo Fart Sniffers', 'Balitmore Bughas']:
await player.remove_roles(['Tokyo Fart Sniffers', 'Balitmore Bughas'])
await player.add_roles(team)
elif rnames not in ['Tokyo Fart Sniffers', 'Balitmore Bughas']:
await player.add_roles(team)
is this a valid way to remove a members role in a list and add the new one?
to stop the bot
did that
Is there a way to enable slash command only to server admin ?
**@command.has_permissions(administrator=True)**
async def prepare(ctx: commands.Context):
await ctx.respond ("What's your favourite colour?", view=PersistentView())```
This not working
you need ctx.respond for a slash command
ya ya that ill update
for the permission itself its not working
its just a snippet
@command.has_permissions(administrator=True)
@frigid lark is this correct ?
yes
ok then let me cross check again
this is painful
but you also can use ```py
@discord.default_permissions(administrator=True)
so people cannot see the slash command
without the permission
(you still can see it on mobile)
this worked , can i also add a specific role to have permissions
like role_name = "xyz " or role_id = 19793824536
Im not sure if you can, that is the list what you can use
nothing like has_role
how to make a slash command alias
you cant
its a slash command for a reason it would be a prefix command if it had alias
and in a cog?
No tag images found.
p.help
b!rtfm pyc discord.Embed.image
@discord.slash_command()
async def nick(self, ctx, member: Option(discord.Member, description="gdzhuja"), name: Option(str, description="Why?")):
await member.edit(nick=(f"ๆงๆๅก | {name}"))
why that code doesnt works
two parentheses at the end instead of one
hm the command it removing it self after sending it
but it works
Is there any way to disable the button after n number of uses
this example is close to exactly what you want: https://github.com/Pycord-Development/pycord/blob/master/examples/views/counter.py
will it work if the bot is in different servers ?
?tag lp
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
Hey, why is this not working?
if BotMissingPermissions is True:
await ctx.send(f"I can not kick this player..")
else:
await ctx.send(f"Good.")
await member.kick(reason="Test")
Ignoring exception in command perms:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 181, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\main.py", line 28, in perms
await member.kick(reason="Test")
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\member.py", line 679, in kick
await self.guild.kick(self, reason=reason)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\guild.py", line 2733, in kick
await self._state.http.kick(user.id, self.id, reason=reason)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\http.py", line 353, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\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: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
I have read the docs: https://docs.pycord.dev/en/master/ext/commands/api.html?highlight=bot permissions#discord.ext.commands.BotMissingPermissions
but not working..
Use a try except
^ BotMissingPermissions is a exception (error) that you can create and catch.
As stickfab said you should use a try/except or built in error handling.
try:
# Kick member
except commands.BotMissingPermissions:
# Send message
You might want to look into the error handling as well to keep your code cleaner in the future.
@bot.command()
@commands.has_permissions(ban_members=True)
async def perms(ctx, member: discord.Member):
try:
if BotMissingPermissions is True:
await ctx.send(f"I can not kick this player..")
except:
await ctx.send(f"Good.")
await member.kick(reason="Test")
so?
you mean perms.error ?
do it like how ice wolfy did
BotMissingPermissions is not an Boolean value it is an exception, view my code in my message
@supple ravine
try tries to execute a block of code, and if an exception is raised, it executes the block inside except
I have now done this as you have it in your code
@bot.command()
@commands.has_permissions(ban_members=True)
async def perms(ctx, member: discord.Member):
try:
await member.kick(reason="Test")
except commands.BotMissingPermissions:
await ctx.send(f"i can not kick this player.")
is this correct?
it should be
yes
i have a error..
Ignoring exception in command perms:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 181, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\main.py", line 25, in perms
await member.kick(reason="Test")
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\member.py", line 679, in kick
await self.guild.kick(self, reason=reason)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\guild.py", line 2733, in kick
await self._state.http.kick(user.id, self.id, reason=reason)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\http.py", line 353, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\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: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
When i kick a admin, mod ..
Also don't use f-strings if you're not gonna use a variable in the statement
yes but that is not an error reason?
Just a tip
Ok thanks 
wait, BotMissingPermissions is for the bot trying to run a command, you need something else give me a seocond to find it
Oops I thought that is when the bot has no rights 
is there a way to unregister a command
Try doing except discord.Forbidden:
yeah its work thanks 
Im not sure how discord handles unregistering commands. It might take a bit.
you could also set force=True in sync commands
Hey, how can I do that but without try? I need try for except or not?
Because with try he tries something or?
You need both the try and except in it, is that what you mean?
Yes I want to do it in perms.error as you recommended but how can I try something when there is nothing to try or is there?
try:
# Your code that might give an error
except ERROR: # The Error the the code under the try might give AND should 'ignore'
# What to do after 'ignoring' the error
try:
await member.ban()
except discord.Forbidden:
raise whatever_error_you_want_that_you_want_in_your_perms.error
but member is not possible in perms.error?
wdym
wait im confused
perms.error with member?
ok when you mean, thanks

command_found = self.bot.get_application_command(
name, guild_ids=[ctx.guild.id]
)
if command_found is not None:
self.bot._application_commands.pop(command_found.id)
removed = self.bot.remove_application_command(command_found)
await self.bot.sync_commands(force=True, check_guilds=[ctx.guild.id])
command_found = self.bot.get_application_command(
name, guild_ids=[ctx.guild.id]
)```
im doing this
im removing > syncing > checking if removed after
anyway
removed = self.bot.remove_application_command(command_found) is returning None

sucks
to send modals to a certain channel would it be like this?
form = MyForm(title="Apps")
Channel = bot.get_channel(12345)
await Channel.send_modal(form)
Since I'm not rlly sure on how to send Modals to a certain channel
You can only send modals on interactions responses
so would it be
await Channel.interaction.response.send_message(embed=[embed])
bc I did that and for some reason it didn't send
and the interaction comes as failed
How can I remove this error?
No?
You can only send modals when replying to interactions, slash commands, buttons, dropdowns...
You have to respond.
yes but how would I send it to a different channel
I'm not sure if I made it clear, sorry if I didn't
and how I do it
Whst
What
How would you send a modal to another channel
Modals pop-up for the user
wait I meant for the embedded
ctx.respond
not the modal mb
thanks
b!rtfm pyc change_presence
Code?
User = interaction.user
embed = discord.Embed(title=User, color=discord.Color.random())
embed.add_field(name="First Input", value=self.children[0].value, inline=False)
embed.add_field(name="Second Input", value=self.children[1].value, inline=False)
await interaction.response.send_message(embeds=[embed])
channel = bot.get_channel(973303609699758132)
await channel.send(embed)
You're not sending it with the embed kwarg
Hey I have a question about the docs, how do I find exactly what I want? For example, I was looking for when a bot has no rights to issue an error but then I was told (thanks by the way) that it was something else.
awesome thank you!
?custom
By reading the traceback you get you should be able to look for it
since you got Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions you should look for "Forbidden" in the exceptions section on the docs
and then do try except error handling with that
Ohhh thanks this is amazing
bruh help
ajuda_comandos = [
OptionChoice(name="/embed", value="Este comando รฉ um comando interativo onde vocรช constrรณi sua prรณpria embed de forma prรกtica."), # Value must be a string.
OptionChoice(name="/ajuda", value="Ajuda 2.0?? :eyebrow_raising:"), # Value must be a string.
OptionChoice(name="/info", value="`/info` รฉ um comando simples, apenas mostra algumas informaรงรตes bรกsicas sobre o bot")
]
@bot.slash_command(guild_ids=testbot, description="Veja todos meus comandos")
async def ajuda(ctx, comando : discord.Option(str, description="Escolha um comando", choices=ajuda_comandos, required=False)):
if comando == None:
embed=discord.Embed(title="Ajuda geral", description="Mรณdulo de ajuda sobre comandos. Digite `/help <comando>` para obter ajuda sobre um comando especรญfico", color=discord.Color.blurple())
embed.add_field(name="/info", value="Mostra algumas informaรงรตes sobre o bot", inline=False)
embed.add_field(name="/ajuda", value="Mostra essa lista", inline=False)
embed.add_field(name="/embed", value="Criador de embed's dinรขmico", inline=True)
button = Button(label="Vote em top.gg", url="https://meuurl.com.br")
view = View(timeout=None)
view.add_item(button)
await ctx.respond(embed=embed, view=view)
else:
embedhelp=discord.Embed(title="Ajuda detalhada", description=choices, color=discord.Color.blurple())
await ctx.respond(embed=embedhelp)
im trying to add choices to a command
what is going wrong
i have this code
@bot.event async def on_message(message): printer = f'Message from {message.author}: {message.content}' print(printer)
but message.content doesnt print anything
You need message intents
and how would i go about doing that
?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)
so
intents = discord.Intents.all() bot = discord.Bot(intents=intents)
?
ok yup, thanks!
just a tip: it's bad practice to use all intents, only use the intents you need
intents = discord.Intents(messages=True)
bot = discord.Bot(intents=intents)
use discord.Intents.all() when you get all the events ready
For now, just use the intents you're working with
what can happen if you use all, ill update it, but what makes it bad practice
quick question, ctx.defer() makes my bot keep saying "bot is thinking..."
how can i disable that?
ctx.defer() makes it so you donโt have to respond within the time limit for an interaction. You have to respond still.
help?
async def displayedmbed():
embed = discord.Embed(
title = 'Title',
description = 'This is a description.',
colour = discord.Colour.blue()
)
embed.set_footer(test='This is a footer.')
embed.set_image(url='')
embed.set_thumbnail(url='')
embed.set_author(name='',
icon_url='')
embed.add_field(name='field name', value='Field Value', inline=False)
embed.add_field(name='field name', value='Field Value', inline=True)
embed.add_field(name='field name', value='Field Value', inline=True)
await ctx.respond(embed=embed)```
code
Any error?...
There you go
What?
Read the error
You're providing incorrect (unexpected) kwargs. And you're setting blank stuff?
This code showed blank parameters.
but i don't see it
embed.set_footer?
change test= to text= in embed.set_footer
avatar_url -> avatar.url
thank you
also provide errors next time pls
ok
I have this code:
user=bot.get_user(member.id) imageurl=user.avatar.url
And i get this error:
exception in on_member_join Traceback (most recent call last): File "E:\Development\python\cc-discord-bot\venv\lib\site-packages\discord\client.py", line 382, in _run_event await coro(*args, **kwargs) File "E:\Development\python\cc-discord-bot\main.py", line 27, in on_member_join imageurl=user.avatar.url AttributeError: 'NoneType' object has no attribute 'url'
read docs, that possibility and the solution is outlined here: https://docs.pycord.dev/en/master/api.html#discord.User.avatar
thank you
also just so you know that url doesnt work, like the #discord.User.avatar doesnt actually exist
What change to my code?
without the r at the end?
@bot.slash_command(guild_ids=[884611858512887848])
async def displayedmbed(ctx):
embed = discord.Embed(
title = 'Title',
description = 'This is a description.',
colour = discord.Colour.blue()
)
embed.set_foote(text="This is a footer")
embed.set_image(url='https://cdn.discordapp.com/avatars/479441843864731663/4c1c7d257267fa13c543c8e9d082a2af.png?size=2048')
embed.set_thumbnail(url='https://cdn.discordapp.com/avatars/479441843864731663/4c1c7d257267fa13c543c8e9d082a2af.png?size=2048')
embed.set_author(name='Mepicaloscoco',
icon_url='https://cdn.discordapp.com/avatars/479441843864731663/4c1c7d257267fa13c543c8e9d082a2af.png?size=2048')
embed.add_field(name='field name', value='Field Value', inline=False)
embed.add_field(name='field name', value='Field Value', inline=True)
embed.add_field(name='field name', value='Field Value', inline=True)
await ctx.respond(embed=embed)```
embed.set_foote(text="This is a footer")
Change that line to
embed.set_footer(text="This is a footer")
something odd is going on, since when the pycord has been upgraded from b7 to latest one, the verified bot goes down automatically after running about a day or two, thats really weird, script is on and bot is down, tried logging, but n abnormal behaviour | error found
host provider says host was up 100% of the timez
this happened 4 -5 times. pls guide what to do
any console output?
nop
hmmm
have you tried running the bot locally?
like, on ur computer
does the same issue occur?
also another wierd thing, ram hikes up the to highest limit when bot is down, there is a issue(unconfirmed bug tagged) opened in git page, that ram hikes up whenever reconnects, this time ram hikes and it dont reconnect
i said, bot does after a day or two, i cant keep my pc running for 2 days
most likely api bug
hmmm
if you could, that would confirm whether its pycord or the host that is the issue
Summary RAM spike go brr, then silence, then brrr again Reproduction Steps I have my entire reproduction here: https://github.com/AlexFlipnote/PyCord_RAMDebug Minimal Reproducible Code No response ...
i havent faced any issues like this one
thats why i changed the host to heroku
creavite
for investigation
whats ur pycord version?
latest git one
2.0.0c smthing
!install
Install pycord:
pip uninstall discord.py
pip install py-cord
Install pycord beta:
pip uninstall discord.py
pip install py-cord==2.0.0b7
Install pycord alpha from git:
pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
the git version is unstable with many bugs
yes this issue came from a few days only
try using beta or just normal pycord
not really
?
not relly
if anything b5 is more unstable lmao
yes
wait rly
rc1 is latest release
using that only
@red tendon sorry for ping, but that requires assistance, i am stumpted and dont know what to do fr
i think its a bug
error?
^^
r34 = discord.SlashCommandGroup(
name = 'r34',
description = 'Rule34 related commands',
)
blacklist = r34.create_subgroup(
name = 'blacklist',
description = 'Blacklist related commands'
)
How would i go about setting up a commands.isNSFW() check on the r34 slashcommandgroup?
btw the command tree looks a bit like this
r34
|____latest
|____random
|____search
|
L____ blacklist
|____add
|____remove
|____enable
|____disable
i need all of these slash commands to trigger only if the channel is nsfw, for legal reasons
ive searched through the documentation for 20 mins, is there any way to delete the message a user sent in on_message
had you opened an issue in github?
and also try to install the master branch
i will
so this one is buggy?
Ig this also somewhat related
@client.event
async def on_application_command_error(context:discord.ApplicationContext, error):
if isinstance(error, commands.NSFWChannelRequired):
await context.respond('> **Error : Command can only be run on NSFW channels**')
Why does the slash command not respond when used on a non-NSFW channel?
command is in a cog in a different file
raises NSFWChannelRequired error
this seems to catch the error, but doesnt respond
it is a slash command btw
i have this code:
await member.timeout_for(duration=60, reason="Swearing")
and get this error:
Traceback (most recent call last): File "E:\Development\python\cc-discord-bot\venv\lib\site-packages\discord\client.py", line 382, in _run_event await coro(*args, **kwargs) File "E:\Development\python\cc-discord-bot\main.py", line 30, in on_message await member.timeout_for(duration=60, reason="Swearing") File "E:\Development\python\cc-discord-bot\venv\lib\site-packages\discord\member.py", line 857, in timeout_for await self.timeout(datetime.datetime.now(datetime.timezone.utc) + duration, reason=reason) TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'int'
docs, can't use an int
rnames = []
for role in player.roles:
rnames.append(role.name)
trole = discord.utils.get(ctx.guild.roles, name=team)
if rnames in ['Tokyo Fart Sniffers', 'Baltimore Bughas']:
await player.remove_roles(['Tokyo Fart Sniffers', 'Baltimore Bughas'])
await player.add_roles(trole)
elif rnames not in ['Tokyo Fart Sniffers', 'Baltimore Bughas']:
await player.add_roles(trole)```
currently this part of my command doesn't remove the roles for a player
can i not remove roles in the list?
self.bot.close()
you'll be passing the bot object through setup() method to the class.
rnames is a list of objects. Not an individual str object
Or rnames is never going to be in the list of team names
So*
is there a way to add more slash arguments if the previous option choice argument have been filled (selected)?
is it possible to have a listener which is only listening if a command is fired ?
import asyncio
import random as r
from discord.ext import commands
client = commands.Bot(command_prefix=">")
@client.event
async def on_message(msg):
if msg.author.bot:
pass
else:
await client.process_commands(msg)
#the bot executes this when it is running
@client.event
async def on_ready():
moderator = client.get_channel(984031180162752525)
print("running")
asyncio.sleep(2)
await moderator.send("I am now online.")
@client.command()
async def math_equations(ctx):
moderator = client.get_channel(984031180162752525)
for i in range(1,10):
moderator.send(str(r.randint(1,10))+"+"+str(r.randint(1,10))+"=")
token = open("number.env", "r")
client.run('token_replaced)```
is the one i have (code)
no
i would recommend you to use python-dotenv
?