#General Help
1 messages · Page 20 of 1
depends on your implementation. Are you subclassing it or creating a view/dropdown object
class MyView(discord.ui.View):
classOptions = []
for i in canBeBuy2:
price = globals()[i][5]
i = i.capitalize()
if i == "Darkknight":
i = "Dark Knight"
classOptions.append(discord.SelectOption(label=f"{i}", description=f"Price : {price}", emoji="🟥"))
@discord.ui.select( # the decorator that lets you specify the properties of the select menu
placeholder = "Choose a class here...", # the placeholder text that will be displayed if nothing is selected
min_values = 1, # the minimum number of values that must be selected by the users
max_values = 1, # the maxmimum number of values that can be selected by the users
options=classOptions
)
async def select_callback(self, select, interaction): # the function called when the user is done selecting options
select.disabled = True
await interaction.response.edit_message(view=self)
await interaction.followup.send(f"Awesome! I like {select.values[0]} too!")
Idk the diffrence 
Subclassing is creating a class that inherits from another class. Also known as creating a child.
Nah it's not, only in the cog class
So what you want to do, is create a constructor.
How is it not? You are creating MyView that inherits from discord.ui.View
Ho i see
I did not understand
Do you know object oriented programming?
No what it is ?
https://www.digitalocean.com/community/tutorials/understanding-class-and-instance-variables-in-python-3 https://docs.python.org/3/tutorial/classes.html
these should help
You can continue without learning them and be confused for half of the time, or learn them and know what you are doing without just copying code blindly.
I thought it would be the same system as for verified with reactions
With a check
def checkEmoji(reaction, user):
return ctx.message.author == user and myembed.id == reaction.message.id and (
str(reaction.emoji) == "1️⃣" or str(
reaction.emoji) == "2️⃣" or str(reaction.emoji) == "❌"
or str(reaction.emoji == "3️⃣"))
It is fairly similar
But it can only be seen that way from the user side.
Learning object oriented programming is very useful from a programming aspect, and that is why Pycord uss them
how do I get the message of an interaction.response.send_message?
I check it but i don't understand at all how it Can help me
wdym??
The message sent with interaction.response.send_message
I want to get the discord.Message object of this message
there is an event when the bot waits for the user to make a choice in a drop-down menu?
yeah
can you send over your code
well I've tried
response = await interaction.response.send_message(embed=embed)
```, but that gives me back a `discord.Interaction` object instead of a `discord.Message`.
(embed=[embed])
message = await interaction.original_message()
do you want to edit your original message?
That's not the issue
that's just double wrong
No
that's what I do, if i don't do it then I get an error
so you're saying that you want to use?
response = await discord.message.send(...)
thank you
The parameter embed takes a discord.Embed while embeds takes List[discord.Embed]
async def rules(self,ctx):
rules=discord.Embed(title="Server Rules", description="Here is the rules for the felbcord, Please follow them as if you dont it can result in a warn/mute/kick/ban \n 1) Do not impersonate another user or staff member, This can be annoying to people trying to talk to specfic users, This includes \n➥ Putting your nicknameas the same of another member\n➥ Telling others you are someones alt account ",color=discord.Color.blue())
rules.set_author(name="FelBot", url="https://github.com/VividBlue1/Felbcord-Py/tree/discord", icon_url="https://i.ibb.co/tz7VQJw/felb.jpg")
await ctx.respond(embed=rules)``` Is there anyway to make the description of this code smaller without litearly making it less words, like its just going on and on along the line and its only 1 rule lol
Im making a server rules embed
I think some games use json files to store dialogue. Maybe you can do something similar with your embeds
Wym? May you expand on this?
do you know what json files are?
Yeah i know what a json file is, but im not very good and havent worked with json files
Thanks
Any specfic parts i should look at here?
for filename in os.listdir(directory):
if filename.endswith(".py"):
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")``` Would i just add
if filename.endswith(".json"):
to connect a folder for jsons
that should work
okay
I am looking through this but im still confused how its going to solve my issue?
well, you can load jsons
and instead of having long texts in your python file, it's going to be organized in your json file
is it possible to do an interaction check with link button and get the users interaction with the button?
link buttons don't receive interactions
H
how do i send a image in a embed?
b!rtfm discord.Embed.set_
I couldn't find a documentation with the name discord.embed.set_! 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 discord.Embed.set_
b!rtfm pyc discord.Embed.set_image
read docs please
Lol
Is anyone else receiving issues with their bots? I am getting an unknown interaction issue out of nowhere.
Nope just you, any errors in console?
Not at all.
Code for command or event?
Nevermind, I found the error, it's something with my database.
Oof, good luck fixing it
Appreciated.
Yes, Use an online image hoster
such as imgur or imgg
What would i use to create a channel once the bot receives a dm?
any ideas for a fix?
async def rules(self,ctx):
rules=discord.Embed(title="Server Rules", description="Here is the rules for the felbcord, Please follow them as if you dont it can result in a warn/mute/kick/ban \n 1) Do not impersonate another user or staff member \n 2) Dont leak peoples personal infomation including phone numbers, locations, or anything that puts someone in danger \n 3) ",color=discord.Color.blue())
rules.set_author(name="FelBot", url="https://github.com/VividBlue1/Felbcord-Py/tree/discord", icon_url="https://i.ibb.co/tz7VQJw/felb.jpg")
await ctx.respond(embed=rules)``` Bruh i was just editing my rules and i restarted my bot to see it, and it dosent show the slash commands (no error at start but error at stop)
```Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
RuntimeError: Event loop is closed```
Is my discord just bugging or what
I havent changed anything, just typed the rules
I am trying to sort a list by using a key and reversing it, but it doesn't continue after the .sort function, 0 errors and yes I have an error handler that raises the errors so its not my error handler.
leaderboard = self.bot.db.find({})
LEADERBOARDS = list(await leaderboard.to_list(length=1000))
for i in LEADERBOARDS:
try:
_ = i['balance']
except:
LEADERBOARDS.remove(i)
def mysortkey(e):
return e['balance']
LEADERBOARDS.sort(reverse=True, key=mysortkey) # it errors here, doesn't do the print statement after
print('Sorted')
Can anyone help me?
@worthy basin Could this be related to my old issue? although i doubt it as its a new name and not same error @slow dome
have you tried to set the result of .sort() to a variable?
It sometimes happens , but reloading dc or restarting bot fixes it but not this time
No I’ll try that
It doesnt return anything when I print it from a variable
Discord can take up to 1 hour to register global command remember. So changing the name will take up to 1 hour for that command to work again
Wait, read the last thing you said
I didnt change anything litearly just changed some text in a string
1py @bot.event async def onmessage(message): if message.content.startswith("!hello"): await message.reply("Hello!", mention_author=True)
2py @bot.event async def on_message(message): if message.content.startswith("!hello"): await message.reply("Hello!", mention_author=True)
2
y does just changing the func name from on_message to onmessage makes it stop working?
although just use commands lol
Its supposed to be on_message, not onmessage
but isen't that just a func name and we should be able to use custom names!
It used the function name to determine what event should trigger it
@worthy basin
ahh i c thanks
like an empty list or just None?
Does it happen when you restart your bot again?
It doesn’t return anything when I print it, not even None. So idk
Yeah, I restarted discord and my bot twice each
is the leaderboards variable even set to anything before the .sort?
I've even removed some of the string i was typing, and hasnt fixed it
should i update github?
I gtg, you could try looking at the git diff or revert to the last commit you did from your github
okay
Yes it’s a list of dictionaries from mongodb
how do i put image on tiop?
embed.set_image(url='https://cdn.discordapp.com/attachments/964892403209212024/986505573375811594/PANKAKERS.jpg')
i have this
I printed the libraries variable and yes it’s a list object
but how do i put on top of embed
hmm
could you show an example? also make a thread so we dont step on people's convos
Yeah that’s what I was going to say
Removed this entire command, If i update my github could someone check the code?
Restarted discord again.. works now
any ideas?
If you can lmk what line is causing the issue, lll try help, i cant tell tho lmao
im guessing at the top one
that is the class that is causing the issue
What line is '371'
Uh, Mabye try re-naming your class
how do you make it persistent ?
Here's the persistent example.
@bot.command()
async def inactive(ctx,days: int):
await ctx.reply(discord.Guild.estimate_pruned_members(days))```
what's wrong with this
Is there an error?
no reply
.send
no output
class MyView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None) # timeout of the view must be set to None
@discord.ui.select(custom_id="select-1", options = [...]) # a custom_id must be set
async def select_callback(self, select, interaction):
...
@bot.command()
async def button(ctx):
await ctx.send(f"View persistence status: {MyView.is_persistent(MyView())}", view=MyView())
that is the example for persistent select menu and i followed the layout for this aswell
tried still nothing
odd
.respond()
nope nothing
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix='!',intents=intents)
@bot.event
async def on_ready():
print(f'{bot.user} has logged in')
@bot.command()
async def inactive(ctx,days: int):
await ctx.send(discord.Guild.estimate_pruned_members(days))
@bot.event
async def on_message(message):
if message.content == "hi":
channel = message.channel
await channel.send('hoo')```
Did my solution fix it might be a mistake in the example
nope
Select cant have a timeout
i have had it working till i had an issue with pycord
fixed the pycord issue and now some things are still broken
You are on the latest version correct?
dev
2.0.0rc1
believe so
Ok
You never do bot.run(token)
i did just didn't send it here
bot is replying to other commands
Oh I know what it is, when you have on_message it does not send the message to check for commands you either need an else with bot.proccess_commands() iirc. Or get rid of on message.
And no errors?
I can't test things rn you might have better luck making a thread
yep, thank you tho :)
File "discord\ext\commands\bot.py", line 344, in invoke
await ctx.command.invoke(ctx)
File "discord\ext\commands\core.py", line 927, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "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_descriptor' object has no attribute '_state'```
this is not helpful. Tell us what your code is
@bot.command()
async def inactive(ctx,days: int):
guild= discord.Guild.id
prune_members_list = await discord.Guild.estimate_pruned_members(self=guild ,days=days)
await ctx.respond(prune_members_list)```
which in simple terms means 
that's the simplest I can put it
You should first learn OOP
object oriented programming
you should, Pycord is not meant for beginners
how do I make the bot delete the message that contains the "delete button" as soon as it is clicked?
what is your current code?
async def regado(interaction):
view = View()
await interaction.response.edit_message(view=view)
await s(10) #mudar para 3600 = 1hora
embed = discord.Embed(color=0xE3C21A)
embed.add_field(name='Notificação', value= 'É hora de regares as tuas sementes!',inline=False)
button1 = Button(label="Regado", style=discord.ButtonStyle.secondary, emoji=':seedling:')
button2 = Button(label="Apanhado", style=discord.ButtonStyle.secondary, emoji=':white_check_mark:')
view = View()
view.add_item(button1)
view.add_item(button2)
arg = await ctx.send(user.mention, embed=embed, view=view)
async def apanhado(interaction):
view = View()
await interaction.response.edit_message(view=view)
await ctx.send('>>> O jogador ' + user.mention + ' acabou de colher os frutos.')
new3_embed = discord.Embed(title=f'Sementes', color=discord.Color.from_rgb(124, 252, 0))
new3_embed.add_field(name='Descrição',
value='O jogador ' + user.mention + ' plantou e colheu as sementes com sucesso!', inline=False)
await message.edit(embed=new3_embed)
### Problems here ! ###
if button1:
button1.callback = await arg.delete()
button1.callback = regado
if button2:
button2.callback = apanhado```
and is this inside of a command?
Any idea?
async def no(days):
await discord.Guild.estimate_pruned_members(self=discord.Guild.id,days=days)```
```RuntimeWarning: coroutine 'no' was never awaited
content = str(content) if content is not None else None
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
y does it still say func wasen't awaited
where did you use no
@bot.command()
async def inactive(ctx,days: int):
await ctx.send(no(days))```
you need to await no
i c thanks
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggest(Cog):
def __init__(self, bot):
self.bot = bot
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
@slash_command(name="suggest",description="Suggest Something")
async def suggest(self,ctx):
await ctx.respond(embeds=Suggest)``` Why dosent my command show? I am struggling making the slash command send the modal
uhhhh
- indent level for command is wrong
- you're trying to pass the cog into
embeds...?
I changed to this
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
@slash_command()
async def modal_slash(ctx: discord.ApplicationContext):
modal = Suggest(title="Modal via Slash Command")
await ctx.send_modal(modal)```
Traceback (most recent call last):
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 15, in <module>
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 787, in load_extension self._load_from_module_spec(spec, name)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 718, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'Modals.Suggestions' raised an error: ClientException: Callback for modal_slash command is missing "context" parameter.```
you've put modal_slash into the modal class itself, so now it needs self
but im pretty sure you want it outside the modal class...?
@crimson coral how do I make the bot delete the message that contains the "delete button" as soon as it is clicked?
what have you tried so far
I just changed it to add self, then ctx
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggest(title="Modal via Slash Command")
await ctx.send_modal(modal)``` Dosent show still (is this an indent error?)
yes, the command should be outside of the Suggest class
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggest(title="Modal via Slash Command")
await ctx.send_modal(modal)``` this?
yes, but now remove the self from the command because it's no longer in a class
Oh alr
class Suggest(Cog):
def __init__(self, bot):
self.bot = bot
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback( interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
@slash_command(name="suggest", description="suggestions")
async def modal_slash(ctx: discord.ApplicationContext):
modal = Suggest(title="Modal via Slash Command")
await ctx.send_modal(modal)``` self is not defined (On the value=self part)
ill show you the whole command:
the callback still needs self
ok
wait
yeah?
please don't call your cog and modal classes the same name
Okay ill change it, but why?
@commands.slash_command(name='grandrp')
async def grandrp(self, ctx):
if ctx.channel.id == (986685592840585298):
user = ctx.author
guild = ctx.guild
embed = discord.Embed(title=f'Sementes', color=discord.Color.from_rgb(218, 165, 32))
embed.add_field(name='Descrição', value='O jogador '+ ctx.user.mention + ' acabou de plantar sementes.', inline=False)
button1 = Button(label="Começar", style=discord.ButtonStyle.secondary, emoji=':alarm_clock:')
button2 = Button(label="Cancelar", style=discord.ButtonStyle.secondary, emoji=':x:')
view = View()
view.add_item(button1)
view.add_item(button2)
message = await ctx.send(embed=embed, view=view)
async def cancelado(interaction):
view = View()
new_embed = discord.Embed(title=f'Sementes', color=discord.Color.from_rgb(255, 40, 0))
new_embed.add_field(name='Cancelado', value='Afinal o jogador ' + user.mention + ' não plantou sementes.',inline=False)
await message.edit(embed=new_embed)
await interaction.response.edit_message(view=view)
async def regado(interaction):
view = View()
await interaction.response.edit_message(view=view)
await s(10) #mudar para 3600 = 1hora
embed = discord.Embed(color=0xE3C21A)
embed.add_field(name='Notificação', value= 'É hora de regares as tuas sementes!',inline=False)
button1 = Button(label="Regado", style=discord.ButtonStyle.secondary, emoji='🌱')
button2 = Button(label="Apanhado", style=discord.ButtonStyle.secondary, emoji='✅')
view = View()
view.add_item(button1)
view.add_item(button2)
arg = await ctx.send(user.mention, embed=embed, view=view)
async def apanhado(interaction):
view = View()
await interaction.response.edit_message(view=view)
await ctx.send('>>> O jogador ' + user.mention + ' acabou de colher os frutos.')
new3_embed = discord.Embed(title=f'Sementes', color=discord.Color.from_rgb(124, 252, 0))
new3_embed.add_field(name='Descrição', value='O jogador ' + user.mention + ' plantou e colheu as sementes com sucesso!', inline=False)
await message.edit(embed=new3_embed)
if button1:
button1.callback = await arg.delete()
button1.callback = regado
if button2:
button2.callback = apanhado
if button1:
new_embed = discord.Embed(title=f'Sementes', color=0xE3C21A)
new_embed.add_field(name='Descrição', value='O jogador ' + user.mention + ' acabou de plantar sementes.',inline=False)
new_embed.set_footer(text=str('Serás notificado daqui a 1 hora para regares as tuas sementes.'))
await message.edit(embed=new_embed)
button1.callback = regado
if button2:
button2.callback = cancelado
view = View()```
well mainly bad practice, strictly speaking there's nothing wrong with it in this context but if you form a habit of it you'll mess up later
oh my
alright
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(Cog):
def __init__(self, bot):
self.bot = bot
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
@slash_command(name="suggest", description="suggestions")
async def modal_slash(ctx: discord.ApplicationContext):
modal = Suggestions(title="Modal via Slash Command")
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggestions(bot))``` Command still wont show up
if button1:
button1.callback = await arg.delete()
button1.callback = regado```
@crimson coral in this
oh i see
Too much indent error
ok PLEASE figure out indents man, most of your questions here are because you keep misunderstanding indentation levels
🥵
Alr will check them
sorry
no need to apologize to me, you're just making it harder for yourself
I hate indents in python haha
use js with bracket
Where about is my indentation error? I am new w modals
basically, your modal_slash command is part of your Suggestions Cog class. Your Suggest Modal is also a class inside of the Suggestions class. As such, both Suggest and modal_slash should have the same indentation level.
@crimson coral can u help me?
yeah 1 sec
Thanks I will. Fix that tomorrow, going to sleep Joe
thanks
Now
just checking, does any of this command actually work already?
everything is working
so everything apart from deleting
view = View()
await interaction.response.edit_message(view=view)
await s(10) #mudar para 3600 = 1hora
embed = discord.Embed(color=0xE3C21A)
embed.add_field(name='Notificação', value= 'É hora de regares as tuas sementes!',inline=False)
button1 = Button(label="Regado", style=discord.ButtonStyle.secondary, emoji=':seedling:')
button2 = Button(label="Apanhado", style=discord.ButtonStyle.secondary, emoji=':white_check_mark:')
view = View()
view.add_item(button1)
view.add_item(button2)
arg = await ctx.send(user.mention, embed=embed, view=view)```
in this part it sends the notification
i want to delete it when someone clicks the button, after that: button1.callback = regado
yes
it eliminates before clicking the button, thats the problem
only button 1
well i'll show you why
this code here, let's break it down
if button1: - checks if button1 is True or not None, meaning this always occurs
-> button1.callback = await arg.delete() - delete's the message arg. delete() returns nothing, so button1.callback now equals None
does button1 have any other behavior? or should it just delete the message
button1 has to delete the message and callback the 'regado' again
big mistake of mine, makes sense what you're saying of course, but i'm not sure how to get out of there
so basically remove that await arg.delete() line and we'll try something a bit different
ok
instead of using arg, inside your class __init__ you should define self.arg = None
now inside the top of your regado function, check if self.arg:, and if self.arg is True then await self.arg.delete()
finally, instead of arg = await ctx.send, we can do self.arg = await ctx.send
this way, the message is now remembered globally and can be updated whenever button1 is pressed, and should delete properly.
I can't get it to work
I'm passing two embeds to a message but only one is shown. Am I doing something wrong or is that intended?
What is your code?
if re.match(r"^{(\s|.)+}$", raw_value):
json_string = rf"[{raw_value}]".encode()
dicts = orjson.loads(json_string)
print(dicts)
embed_dicts = self._get_embed_dicts(dicts)
for embed_dict in embed_dicts:
embed = discord.Embed.from_dict(embed_dict)
embeds.append(embed)
print(embeds)
return embeds
```This is what converts a string input to the embed objects.
and it seems like it does actually work in some cases
This works for example```json
{
"embed": {
"color": 3092790,
"fields": [
{
"name": "What do you want?",
"value": "Please react with the corresponding emoji.",
"inline": false
}
]
}
}
And this doesn't: https://glitchii.github.io/embedbuilder/ (the json from there)
there are acutally both embeds stored in the message object but as I wrote only one is shown...
When I use the json from the link just once it looks like this:
but when I use it twice for two embeds it looks like this:
@slow dome
how are you sending the embed
message = await channel.send(**values)
where values is a dict with embeds, content and files as keys and their values.
could I see the embed part?
that's this one
iirc discord has a weird thing that combines images from multiple embeds if the embeds have the same url
same url or domain?
url i believe
because I changed it just a bit and still the same except with two different pictures
the image url right?
changed even the whole url and problem continues
idk
btw. what does iirc stand for?
ask discord
if i recall correctly
So it's on discord not on pycord?
yes
thx
ok good to know.
How can i create a warn command?
(The thing is i dont know what i can and cant use as im on windows 7, not on latest version of python and i dont think im on the latest version of pycord too)
What do you mean with a "warn command". This can literally be anything. No one here can read your mind, so explain it.
What about updating? Like... everything.
A warn command, Like ?warn @pale igloo <reason>
Do you know how to create a basic command?
Yes
Then you know how to create such a command...
Or do you mean what to execute when the command is invoked?
Just explain what exactly you want to achieve. What have you tried so far, and what errors did you get?
And feel free to create a post if necessary 🙂
Ive not tried anything so far as i have the older versions of stuff and im not sure where i can find docs that work for them.
I want to make a warn command that saves the warning every time you do it for a player but i want to make it a requirement that you need a reason,
So far what ive got is this, But this wont do the main part command, It just replys that its added a warning.
@bot.command()
async def warn(ctx):
await ctx.reply('Warning logged for that user!')
Use a database to store the reasons and warning. I suggest making the key a warning id. then the values be the user id and the reason. You need a paramater that recieves the reason and the member.
I'm not very good with databases myself but I recommend mongodb or postgresql.
gl
anyone know how to get rid of the interaction failed even though it sends a message
Code
Interaction.response.send_message
dont want it as a response but as a standalone message
Well it is failing cause no respone pretty sure
Have had this working before
...
Is how you use it
You respond to interactions.
IK
Otherwise they'll mark as failed
I did have a way round it before
Why are you doing interaction.channel.send then lol
As that sends the message as a standalone message
It won't work with interactions
b!rtfm pyc interaction.response
b!rtfm pyc interaction.respond
No results found when searching for interaction.responsd in pyc
b!rtfm pyc interaction.respond
No results found when searching for interaction.respond in pyc
b!rtfm pyc respond
discord.InteractionResponded
discord.InteractionResponded.interaction
discord.InteractionResponse.defer
discord.ext.tasks.Loop.seconds
discord.InteractionResponse.edit_message
discord.InteractionResponse.is_done
discord.InteractionResponse.send_autocomplete_result
discord.InteractionResponse.send_message
discord.InteractionResponse.send_modal
discord.ext.commands.HelpCommand
await interaction.response.edit_message()
async def no(days):
await discord.Guild.estimate_pruned_members(self=discord.Guild.id,days=days)
@bot.command()
async def inactive(ctx,days: int):
print(no(days))
await ctx.send(no(days))```
this code send this in channel
`<coroutine object Guild.estimate_pruned_members at 0x000001F60B1BEFF0>`
with warning in terminal RuntimeWarning: coroutine 'no' was never awaited content = str(content) if content is not None else None RuntimeWarning: Enable tracemalloc to get the object allocation traceback
kinda week in python async func but how do i make func(no) wait
error is self explanatory
yes it is i just don't know how to make it wait
i have added await
tried this a = await no(days) await ctx.send(a)
where can i learn more on this
you can use coroutines in function args
?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)
await interaction.response.edit_message(embed=embed, view=DisfinalView(), file=discord.File(f'cache/{str(interaction.user.id)}.txt'))TypeError: edit_message() got an unexpected keyword argument 'file' 
where the interaction come from? modal? button?
is there a way to make a general error handling for when interaction doesnt respond due to an error in a slash comamnd
it is possible but yeah we don't support it yet
mainly because it crashes some clients
anyone know how to host a lavalink server on a vps?
and even know how to create the fucking server!!!
Basically if you are using pycord that you can use dpy2.0 and dpy is better than pycord and dpy is easy also
And the best feature of dpy is it fully asynchronous
but their documentation is kinda :meh:
anyway there should be not much different since pyc is fork from the original one 🤷♂️
🤨
documentation, guide, and examples are pretty helpful
shm
can i use
elif something in []: for lists?
i create a command when i pin a user @bot.command()
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member):
mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
await member.add_roles(mutedRole)
await member.send(f" you have muted from: - {ctx.guild.name}")
embed = discord.Embed(title="mute", description=f" muted-{member.mention}",colour=discord.Colour.light_gray())
await ctx.send(embed=embed) showingt error raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'
Yep.
I am stuck at pycord asynchronous func for 2 days it keeps pooping i am not waiting whatever that means.
I am waiting though

i want to disable a button in a view after a button is clicked but the button that is clicked is not the button which to be disabled
That mean there are no Lavalink nodes are connected
is there a way to get the interaction of a button to send a message but not as a reply?
Why are you here then
I just joined because I like this server

Guys all I have to do to change normal commands into slash is to change the decorator? Right?
@bot.command()
async def i(ctx):
mem = ctx.guild.members
print(mem)```
y does this work and following doesn't
```py
@bot.command()
async def i(ctx):
guild = await bot.fetch_guild(9747190257068298)
print(guild.members)```
y does this gives empty list
So I have to change the decorator 5o change the commands type right?
how can I send a modal to a specific channel?
I font think that is possible. Models can only be sent in response to an interaction and you cannot change the interaction data. Do you mean you want the callback of the modal to execute in a diff channel?
The decorater and change send to respond
Along with many other small things that you will find when testing your bot
ok
ty
can you make a button unuseable for someone?
It doesn’t matter
If it’s a modal or button
But yea button
Interaction.response.edit_message does the same thing for every interaction
Bro this will return a obj if you want to print all mem then just use for loop
is it possible to copy to clipboard using pycord?
I will return a list. Not an obj.
That's impossible in any kind of library.
Heeey
language_list = [OptionChoice(name='Python', value='Python'),
OptionChoice(name='Java', value='Java'),
OptionChoice(name='JavaScript', value='Python'),
OptionChoice(name='Kotlin', value='Kotlin'),
OptionChoice(name='Lua', value='Lua'),
OptionChoice(name='Elixir', value='Elixir'),
OptionChoice(name='PHP', value='PHP')]
@slash_command(description="Adicionar bot à lista de análise.")
async def adicionar(self, ctx,
aplicação: Option(int, "Digite o ID da sua aplicação."),
linguagem: Option(str, "Escolha a linguagem da sua aplicação.", options=language_list),
descrição: Option(str, "Descreva como é a sua aplicação."),
prefixo: Option(str, "Digite o prefixo da sua aplicação.")):
What do I have to do to show up as choices?
believe its choices not options
^ they are right
Honestly it is a bit confusing
Just change the options to choices in your linguagem option argument
Is there to way convert in python
ᗅ𝓃nဝun𝕔ҽmen𝓽 𝚩οt to announcement bot
linguagem: Option(str, "Escolha a linguagem da sua aplicação.", choices=language_list),
look at the unicodedata module
specifically the normalize function
its not working tho
wdym?
commands.BucketType.role
will that make a cooldown for the Role Captain?
anyone know how to create a command that can only be used w certain roles
would it be something like
second line of my code
ok
put the Role name in the strings
I think so, not sure though
ok
you can give it a go
can u join my server for a sec and try the command when i change the code
is there a way to make a command that clears the dms with the bot?
@commands.has_any_role(role_id, role_id, etc)
You cannot remove messages sent by the user in DMs
just the bots messages
dont quite follow
so discord.Member inherits from discord.User
async for message in user.history(limit=200):
if message.author == bot.user:
await message.delete()
can you run commands in dms?
which ones
normal prefix ones
is it possible to edit the description of a select option, after its selected by a user?
sure
yeah
@bot.command()
async for message in bot.user.history(limit=200):
if message.author == bot.user:
await message.delete()
```??
do you know how commands work?
@bot.command()
async def hide(ctx):
async for message in bot.user.history(limit=200):
if message.author == bot.user:
await message.delete()```
in ctx.author.history
my current code is await interaction.response.edit_message(view=self.view)
this edits the view to the default view
how can i give a new view?
well you can do view=self
and edit self
self is a discord.ui.view
you can access options of the select object
select.options = [discord.SelectOption(label, value, description=None, emoji=None, default=False), discord.SelectOption(label, value, description=None, emoji=None, default=False), discord.SelectOption(label, value, description=None, emoji=None, default=False)]
ofc replace the values
label is a string, value i believe can be anything that is a basic type
well how are you defining the select object?
is it in a view class or a select class?
hell, even its own object without subclassing
which of the three is it?
class Enable(discord.ui.Select):
def __init__(self):
options = [
discord.SelectOption(
label="Fraktions Anträge", description=f"Status: {get_enabled()['fraktionsanträge']}", emoji="📋"
),
discord.SelectOption(
label="Team Bewerbung", description=f"Status: {get_enabled()['teambewerbungen']}", emoji="👥"
),
]
super().__init__(
placeholder="Wähle aus...",
min_values=1,
max_values=1,
options=options,
custom_id="enable",
disabled=False
)
async def callback(self, interaction: discord.Interaction):
if interaction.user.guild_permissions.administrator:
if self.values[0] == "Fraktions Anträge":
await interaction.response.edit_message(view=self.view)
await interaction.followup.send(f"test {self.values[0]}")
elif self.values[0] == "Team Bewerbung":
select.options = [discord.SelectOption("test", 0, description=None, emoji=None, default=False)]
await interaction.response.edit_message(view=self.view)
await interaction.followup.send(f"test {self.values[0]}")
else:
await interaction.response.send_message(f"{emoji().error} {interaction.user.mention} Du hast keine Berechtigungen dazu!")
class EnableView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.add_item(Enable())
this is my code
you dont necessarily need to define a separate select class to use it in a subclass view
infact, you should stick to one of the two styles
and not use both simultaneously for one view
i dont understand
what im saying is that either remove the view subclass and keep the select subclass or move the callback into the view subclass and remove the select subclass
you dont need both at the same time
the callback specifically yes
Someone help me the docs is like
guys how can i make a prefix command in a cog
look at the examples on the github
class EnableView(discord.ui.View):
async def on_timeout(self):
for child in self.children:
child.disabled = True
await self.message.edit(content="Du hast zu lange gebraucht!", view=self)
@discord.ui.select(...stuff here)
async def select_callback(self, select, interaction):
...stuff here
hey, i get this error
File "/root/Bot/main.py", line 1924, in on_timeout
await self.message.edit(content="Du hast zu lange gebraucht!", view=self)
AttributeError: 'EnableView' object has no attribute 'message'
ExtensionFailed: Extension 'cogs.fun.coinflip-fun' raised an error: AttributeError: 'Bot' object has no attribute 'add_command'
What is your code?
#986655928440999987 message but only with a @commands.command
yeah, you need the message attribute from elsewhere. e.g. from ctx
@commands.command()
okay
it is @commands.command()
is it possible to edit the placeholder from my select menu
i mean in the timeout
i cant do just self.placeholder
?
yes
you wrote the same like he lmao
need help bros
well how to?
send the entire thing including how you actually load the cog
can i do work updoad?
?
or mediafire
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id' showing this error
code? @neat tide
@bot.command(description="mutes a specified user.")
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member):
mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
await member.add_roles(mutedRole)
await member.send(f" you have mutedd from: - {ctx.guild.name}")
embed = discord.Embed(title="mute", description=f" muted-{member.mention}",colour=discord.Colour.light_gray())
await ctx.send(embed=embed)
please format you code
View(ctx) #initing it
class View(discord.ui.View):
def __init__(self, ctx):
self.ctx = ctx
async def on_timeout():
for child in self.children:
child.disabled = True
await self.ctx.edit(content="Du hast zu lange gebraucht!", view=self)
?tag codeblock
Please put your code in a code block:
```py
Here is your Code
```
That makes reading code in Discord a lot easier:
print("This is an example.")
@neat tide
i do now it work?
what?
delete it please
format
format
why?
ok
look dms
ok, so why do you need a cog for every command?
TypeError: __init__() got an unexpected keyword argument 'timeout'
i don't wan't it but my co owner...
format this
🤦
you'll have to post the whole stacktrace because this isn't enough to figure out whats wrong
could someone run my code and try to reproduce the problem in the stackoverflow post.. wondering if it happens only on my machine
https://stackoverflow.com/questions/72647225/socket-randomly-stops-receiving-data
I don't understand what your code is trying to accomplish
What do you mean?
bot.command(description="mutes a specified user.")
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member):
mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
await member.add_roles(mutedRole)
await member.send(f" you have mutedd from: - {ctx.guild.name}")
embed = discord.Embed(title="mute",
description=f" muted-{member.mention}",
colour=discord.Colour.light_gray())
await ctx.send(embed=embed)
here
check this
read what I said
i tried getting the channels of a guild but it returns an empty array, the bot has administrator perms so any idea why it could be empty?
Hi guys, can someone write me code to send a specific message every 35 minutes of every hour?
do it with tasks
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/background_task.py at master · Pycord-Development/pycord
heres some example code
can anyone help?
but i want to send a specific notification every 35 minutes of every hour during the day
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(Cog):
def __init__(self, bot):
self.bot = bot
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
@slash_command(name="suggest", description="suggestions")
async def modal_slash(ctx: discord.ApplicationContext):
modal = Suggestions(title="Modal via Slash Command")
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggestions(bot))``` I've tried to do what you said, I am really bad with indentations
the example here is for a specific time, I want it to always send a notification at 35 minutes. does anyone know how i can do it?
Uh, code??
if discordID in [301480016657776642, 464721355116380160]:
a = 0
b = 10
elif discordID in [92786442891169792, 746850928417701990]:
a = 85
b = 99
else:
a = 49
b = 99
Spiking = np.random.randint(a, b)```
can i not have elif in list like this?
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(Cog):
def __init__(self, bot):
self.bot = bot
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggest])
@slash_command(name="suggest", description="suggestions")
async def modal_slash(ctx: discord.ApplicationContext):
modal = Suggestions(title="Modal via Slash Command")
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggestions(bot))```
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggest])
class Suggestions(Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(ctx: discord.ApplicationContext):
modal = Suggestions(title="Modal via Slash Command")
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggestions(bot))```
Traceback (most recent call last):
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 15, in <module>
bot.load_extension(f"{directory[2:]}.{filename[:-3]}")
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 787, in load_extension self._load_from_module_spec(spec, name)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 718, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'Modals.Suggestions' raised an error: ClientException: Callback for suggest command is missing "context" parameter.
Why do i keep getting this error?
I have checked 5 times for indenation errors
Not sure you've realised but this has nothing to do with indentation
does bridge doesnt work in Cogs properly?
async def callback(self, interaction: discord.Interaction): is missing a context parameter
async def callback(ctx,self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggest])``` same error
self goes first
Oh mb
async def callback(self,ctx, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggest])``` same error
@past gate
my bad I was looking at the wrong function
you're missing self in modal_slash
starts now, but application did not respond
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 26, in on_application_command_error
raise error
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Suggestions.__init__() got
an unexpected keyword argument 'title'```
modal = Suggestions(title="Modal via Slash Command")
you called your modal class Suggest not Suggestions
example= {
"test": discord.Embed(title='Test',description='test description'),
"test2": "example"
}
ctx.send(embed=example['test2'])
if i do this then i'd get <discord.embeds.Embed object at 0x000001A829047D00>
Is this something i cant do?
@past gate
yes hi
i have this error
Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 26, in on_application_command_error
raise error
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Suggestions.init() missing 1 required positional argument: 'bot'
what line am i missing it on
@past gate
whats your code currently?
could someone pls try running that code to reproduce my problem https://stackoverflow.com/questions/72647225/socket-randomly-stops-receiving-data
?
import os
import discord
from discord.ext import commands, tasks
from itertools import cycle
intents = discord.Intents().all()
bot = discord.ext.commands.Bot(command_prefix='!', help_command=None, intents=intents)
status = cycle(['/help', 'GrandRP']) # (lines 17-19)
@bot.event
async def on_message(message):
print('I got something...')
await bot.process_commands(message)
@bot.event
async def on_ready():
change_status.start()
print('Bot is ready.')
@tasks.loop(seconds=10)
async def change_status():
await bot.change_presence(activity=discord.Game(next(status)))
for files in os.listdir('./cogs'):
for filename in os.listdir(f'./cogs/{files}'):
if filename.endswith('cog.py'):
bot.load_extension(f'cogs.{files}.{filename[:-3]}')
bot.run('TOKEN')
I keep getting this error message:
RuntimeError: Event loop is closed
I dont think that matters, I get it when stopping my bot and no issues
but the problem is, I cant run the bot....
What are you doing in on ready for the change status
@past gate
i think somehow it is giving me that error because the: bot.run('TOKEN')
does anyone know why?
Oh yeah, i know you have an env right?
Use
bot.run(os.getenv("TOKEN"))```
from dotenv import load_dotenv
load_dotenv()
at top too
no
Bruh...? Why are you using 'TOKEN' then?
can someone help me? lmfao
with?
i dont want to put the token here xD
.
I know but why 'token' if u have no env
it has the token in that place
idk sorry
ngl this new help system is so messy
cuz the posts are so hard to go through
and general help is like dead
Could you send me the entire code with token (but reset the token ofc)
You dont need a .env file
rly isnt
I use a json file
cool
in the main.py file, i only have this amount of code
import os
import discord
from discord.ext import commands, tasks
from itertools import cycle
intents = discord.Intents().all()
bot = discord.ext.commands.Bot(command_prefix='!', help_command=None, intents=intents)
status = cycle(['/help', 'GrandRP']) # (lines 17-19)
@bot.event
async def on_message(message):
print('I got something...')
await bot.process_commands(message)
@bot.event
async def on_ready():
change_status.start()
print('Bot is ready.')
@tasks.loop(seconds=10)
async def change_status():
await bot.change_presence(activity=discord.Game(next(status)))
for files in os.listdir('./cogs'):
for filename in os.listdir(f'./cogs/{files}'):
if filename.endswith('cog.py'):
bot.load_extension(f'cogs.{files}.{filename[:-3]}')
bot.run('TOKEN')
Try changing bot = to
bot = commands.Bot(code here)
That is also fine
I am just giving what has worked for me, why dont you help him if you are correcting me??
im not great
May you help here? @foggy flax (Code is just above the msg)
not working
🤷 sorry idk then
plssss
good pinging
let me look
ohno I have to go
oh god
sorry, but may you help ive been trying myself for 2h
(did this ping you?)
yep
Okay, May you help sorry? I am really confused (Yes, I have asked google and docs)
AttributeError: module 'discord' has no attribute 'default_permissions'
Which pycord version is installed?
?
One second please
Run 'pip list' in console to check your version
Name: py-cord
Version: 2.0.0b5
Summary: A Python wrapper for the Discord API
Home-page: https://pycord.dev/github
Author: Pycord Development
Author-email: None
License: MIT
Location: /home/runner/Lion-BOT-list-c/venv/lib/python3.8/site-packages
Requires: aiohttp
Required-by:
You need rc1
hmmmm
are command cooldowns fixed to the callback?
thanks
Uninstall this version and use
pip install py-cord==2.0.0rc1
Would appreciate it alot
Is it still this code or did you change something?
also just reliased, pinged wrong person (meant to ping u)
one sec
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggest(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggest])
class Suggestions(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions()
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggestions(bot))```
Oh you use the wrong class
@slender lintel
I just sent it now
U use the cog and not the modal
You did suggestions instead of suggest
modal =Suggestions()
Clearly didn't read a thing I said
suggest right?
Yes
fixed it now
I didnt notice that, thanks to u both (Sorry fish didnt see ur msg)
@slender lintel
ty
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggestions])
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions()
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggestions(bot))```
error:
```Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Suggestions.__init__() missing 1 required positional argument: 'bot'```
(did remove a bit of error cos discord wouldnt let me send)
So you've switched the class names around but forgot to do it for the setup function
Suggestions is a modal now not a cog
o lol
👍
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 852, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 23, in modal_slash
modal = Suggestions()
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 8, in __init__
super().__init__(*args, **kwargs)
TypeError: Modal.__init__() missing 1 required keyword-only argument: 'title'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 26, in on_application_command_error
raise error
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Modal.__init__() missing 1
required keyword-only argument: 'title'``` Got this after changing the bottom part in the setup function to suggest
Add a title to the modal
suggest.add_field(title="Short Input", value=self.children[0].value) would smth like this work?
No
It should be name not title iirc
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggestions])```
i have that
modal = Suggestions(title="text")
Wouldnt it be suggest? (check latest code)
why does my bot sometimes do this?
Its a discord thing
nothing on my end then ?
Nope
^
Just cache n stuff doing it's thing
theres no workaround to this?
you can display their name
Im not sure if is that
I added your code you gave but changed modal = to suggest =
and it same eror
https://github.com/Pycord-Development/pycord/blob/master/examples/modal_dialogs.py
You can see in the examples what I mean where you have to add the title
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/modal_dialogs.py at master · Pycord-Development/pycord
ty
I am confused, My code looks pretty much the same
I know, you have copy it ;3
The bot doesn't send the message, why?
Entfern das "self" bei der Interaction
wym?
msg = await interaction.response.edit_message(content="")
why cant i do msg.edit after that
its an interaction that is being stored into msg
??
Falsche Person xd
why u saying thx to me? wrong reply?
xD
how can i edit it afterwards?
What do you mean?
huch xD
do something like
message = await msg.original_message()
message.edit()
and basically that gets the message part of the interaction response message
and then message.edit eddits it
yep
thanks
np
Sus ;3
? Could you help lol i cant see where i put title its the same
In the example is the title in "modal =MyModal(title="text")"
i dont think original_message exists
Thanks got it poping up but subit does nothing
code:
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest = Suggestions(title="text")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggestions])
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions(title="text")
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggest(bot))```
error
```Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch
await value.callback(interaction)
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 16, in callback
suggest.add_field(name="Short Input", value=self.children[0].value)
AttributeError: 'Suggestions' object has no attribute 'add_field'```
@frigid lark der wählt nur das letzte aus weißt du vlt warum?
ändere ```py
if "Regelwerk" in ... zu
if select.values[0] == "Regelwerk"
remove in this one "suggest = Suggestions(title="text")"
Alr
and dont have the same name like the slash command for the embed
Könntet ihr euch bitte auf englisch unterhalten!
alles klar
it doesn't work
it doesn't show anything
only the last one the "serverteam bewerbung"
@fickle spruce try this out
if "Regelwerk" in str(interaction.data.values()):
nope doesnt work
Sure? For me it works 
I do it like this
shoud i edit "send" to "edit" ?
I mean the stuff with the values
you can do it, it would overwrite the message
no now its doesnt send anythink
I will try something
k
What does check mean?
like what messages
and does bulk = True delete pinned messages as well?
use only one ```py
async def my_callback(interaction: discord.Interaction):
you have 4
with only 1 it works
with 2 or more not
ohh
it works😆 thx
\o
Try it
(Im not sure if bulk do that)
Is there any way to pause a task for a certain amount of seconds? Using this to stop the bot from being ratelimited by a third party api
asyncio.sleep(seconds)?
the problem with that is it'll delay rest of the task, and in the delay time, more tasks are created iirc
stonks
👍
@bot.command()
@commands.is_owner()
async def fsrp(ctx):
# for every message in ctx.channel get the mentions out of the message
for message in ctx.channel.history(limit=None).flatten():
for mention in message.mentions:
print(mention.name, mention.id)
error:
1|Quikz Helper | 2022-06-17T00:19:53: /root/QUIKZHELFERCHEN/main.py:618: RuntimeWarning: coroutine '_AsyncIterator.flatten' was never awaited
1|Quikz Helper | 2022-06-17T00:19:53: for message in ctx.channel.history(limit=None).flatten():
1|Quikz Helper | 2022-06-17T00:19:53: RuntimeWarning: Enable tracemalloc to get the object allocation traceback
how do i fix this?
@stats.error
async def stats_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
if ctx.author.id == 92786442891169792:
args = (player)
kwargs = {}
await ctx.invoke(ctx.command, *args, **kwargs)
else:
msg = f'Try again in {round(error.retry_after)}s'
await ctx.respond(msg, ephemeral = True)
am i using invoke incorrectly? my command takes player: discord.User argument and i want it so i have no cd
that is an async iterator. you need to use the async keyword with the loop
async def regado(interaction):
embed2 = discord.Embed(color=0x7DF9FF)
embed2.add_field(name='Notificação',value=f'As tuas sementes foram regadas por: {interaction.user.mention}',inline=False)
embed2.set_footer(text=str(f'Localização: {localizacao}'))
view = View()
await ctx.author.send(embed=embed2)
new_embed = discord.Embed(title=f'Sementes', color=0xE3C21A)
new_embed.add_field(name='Processando ...', value=f'O jogador {user.mention} plantou sementes em: `{localizacao}`.',
inline=False)
new_embed.set_footer(text=str('Serás notificado daqui a 1 hora para regares as tuas sementes.'))
await message.edit(embed=new_embed)
view = View()
await interaction.response.edit_message(view=view)
embed = discord.Embed(color=0xE3C21A)
embed.add_field(name='Notificação', value= f'É hora de regares as tuas sementes!',inline=False)
embed.set_footer(text=str(f'Localização: {localizacao}'))
button1 = Button(label="Regado", style=discord.ButtonStyle.secondary, emoji='🌱')
button2 = Button(label="Apanhado", style=discord.ButtonStyle.secondary, emoji='✅')
view = View()
view.add_item(button1)
view.add_item(button2)
arg = await ctx.author.send(user.mention, embed=embed, delete_after=30)
await ctx.send(user.mention, embed=embed, view=view, delete_after=30
I want this 'regado' to be sent at 10:35, 11:35, 12:35, 13:35... (all day from 0:35 to 23:35) how do I do that? I dont know how to schedule this
You're looking for tasks.
Here's the background task example.
I am once again asking for your intellectual support
is there a way to update a cooldown's retry after?
Have you made an attempt?...
Where on the guide do i find how to implement a help command using slash commands?
The page on help only seems to cover prefixed commands
dynamic cooldowns
slash commands usually don’t need a help command
Is there a way to ignore spaces in prefixes?
Like if my prefix was "?"
I also want my command to trigger with "? " and so on
because all of them are shown
Thank you
Also, is there a direct setting that makes @ mentioning the bot always work as a prefix
client = commands.Bot(prefix = commands.when_mentioned_or('!'))
it should be something along those lines
:o thank you
np
just checked
instead of prefix its command_prefix
wym
why not
Having a concise list of commands is definitely necessary
also people are used to using help to see all the commadns\
How do you add description to the arguments in a bridge command?
Also, can bots upload large files? (Above 8mb) since they technically don't have nitro
Yes
i dont think so
since bots cant send messages over 2000 characters in length
i dont suppose that they would be able to send files larger than 8mb
im not sure though
Hello
Does any of you guys know how to invoke something like update_database in cogs? without cogs I'm using @bot.before_invoke but with cogs @commands.before_invoke it ain't working
Dynamic cooldown?
how would you get users @ in a message added to a list which gets the bot to send them a message?
Like user.mention?
ye
Can’t you just add that to a list?
hmmm that could work, sorry for the ping btw
Haha it’s fine - happens literally all the time. Curse my name!
ahaha yeah
I’m not sure what you’re trying to do?
it send a message to @ people and the response is(e.g. you voted against wumpus#0000 being reinstated)
where wumpus#0000 to be reinstated is the question
is there an @bot.event that triggers when the bot joins a voicechannel?
Is there any way to edit an ephemeral message?
await interaction.response.send_message(embeds=[Suggestions]) Says i am missing self, but where?
code?
I gave it.. at least the line i think the error is on
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Short Input"))
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title="Modal Results")
suggest.add_field(name="Short Input", value=self.children[0].value)
suggest.add_field(name="Long Input", value=self.children[1].value)
await interaction.response.send_message(embeds=[Suggestions])
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions(title="text")
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggest(bot))```
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch
await value.callback(interaction)
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 17, in callback
await interaction.response.send_message(embeds=[Suggestions])
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 648, in send_message
payload["embeds"] = [e.to_dict() for e in embeds]
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 648, in <listcomp>
payload["embeds"] = [e.to_dict() for e in embeds]
TypeError: Modal.to_dict() missing 1 required positional argument: 'self'```
you are passing a modal as an embed...
why am i getting ignored so badly
I am following the docs (then going to customize to what im needing)
try await interaction.response.send_message(embeds=[suggest])
take a look at the event list in the docs
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch
await value.callback(interaction)
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 17, in callback
await interaction.response.send_message(embeds=[Suggest])
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 648, in send_message
payload["embeds"] = [e.to_dict() for e in embeds]
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 648, in <listcomp>
payload["embeds"] = [e.to_dict() for e in embeds]
AttributeError: type object 'Suggest' has no attribute 'to_dict'
b
lowercase... the Suggest needs to be suggest
oh my bad
then there is no such event...
@slender lintel did you read the messages?
I changed what u said last night
but its fixed now
thanks
Ok?
and do you know what your mistake was?
Yeah, My embed/modal is named suggest but i sent it as 'Suggest'
suggest = discord.Embed(title="Suggestion by {user}") What would i use to get the member who sent the modal/embed
Your embed is suggest and your modal is Suggestions. You tried to pass the modal as an embed which clearly does not work.
Oh okay
An Embed and a Modal are two completely different things...
Do you know what i can do here? As i dont have anything like discord.Member or discord.User
I know but it has
suggest = discord.Embed
so i was confused
@inner iris
well the bot sent the embed right? Or do you mean the user that made the suggestion?
That would be simply user like you used it in the embed title...
Alright, just checking if i did it right
oh you don't even know if it works...
it probably doesnt...
like you did it.
I thought you already tested it.
yeah well just learn python at this point...
Usage of f-strings and basic python. And then learn to use the docs and examples...
I know mate but i aint got anything for the code to find the user from
discord.Embed(title=f"{user} Suggested ") user is not defined
Thanks this worked! Going to customize it now, sorry if i've been annoying
you need rc1
what is rc1?
uinstall the old version and use
pip install py-cord==2.0.0rc1
oh okey
restart the editor after the installation
Using
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
suggest.add_field(name="Your Suggestion", value=self.children[1].value)
channel = self.bot.get_channel(964130201514692628)
await interaction.channel.send(embeds=[Suggestions])```
But cant seem to get it to send to that channel
Why are you adding interaction
Its an Interaction
That doesnt work with an Interaction
What would work? I just want to send the modal result to a channel (I already knew channel.send but i also knew it wouldnt work in modals)
Just send the result with channel.send (the channel you got)
You cant....
And then just respond to the interaction so it doesn't "fail"
🤦
Ill try it
What
You're in the modal callback
You just said you want to send the result to a different channel the modal was invoked from.
Correct
Then what I'm saying is correct.
Try it...
await channel.send(embed=embed)
await interaction.response.send_message("Successfully sent your suggestion!")
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch
await value.callback(interaction)
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 15, in callback
suggest.add_field(name="Your Suggestion", value=self.children[1].value)
IndexError: list index out of range```
We have just discussed the fact, Channel.send will not work
Why it won't work?..
Channel.send dosent work in modals
Try to send the embed with channel.send
Yes, I'm asking why
.
oo
Send modal result to another channel from where /suggest was done
yes what dark said
then get a channel with .get_channel(id)
@frigid lark same error
channel = self.bot.get_channel(964130201514692628)
I have that
import discord
from discord.commands import slash_command
from discord.ext.commands import Cog
class Suggestions(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))
async def callback(self, interaction: discord.Interaction):
suggest = discord.Embed(title=f"{interaction.user} Suggested ")
suggest.add_field(name="Your Suggestion", value=self.children[1].value)
suggest.add_field(name="Message id:{message.id}", value=self.children[1].value)
channel = self.bot.get_channel(964130201514692628)
await channel.send(embeds=[Suggestions])
class Suggest(Cog):
def __init__(self,bot):
self.bot = bot
@slash_command(name="suggest", description="suggestions")
async def modal_slash(self,ctx: discord.ApplicationContext):
modal = Suggestions(title="text")
await ctx.send_modal(modal)
def setup(bot):
bot.add_cog(Suggest(bot))```
my full code
And 1
99% of python is 0 indexed
He only got one input
0 is the first one
That's why 1 is out of range
Yeah, I thought it might be that lol so should i change 1 to 0?
Yes
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch
await value.callback(interaction)
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 17, in callback
channel = self.bot.get_channel(964130201514692628)
AttributeError: 'Suggestions' object has no attribute 'bot'```
Shall i remove self.bot to self.
you gotta pass your bot to your suggest modal
def __init__(self,bot):
self.bot = bot```
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)```
You pass the bot object when creating the view
this is cog
oh yeah why did i send that one lmao
wym
# in some slash command
await ctx.send_modal(Suggestions(self.bot)) # assuming youre in a cog```
Thanks, got confused
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 852, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\Modals\Suggestions.py", line 27, in modal_slash
await ctx.send_modal(modal,(self.bot))
TypeError: InteractionResponse.send_modal() takes 2 positional arguments but 3 were given
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 26, in on_application_command_error
raise error
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: InteractionResponse.send_modal() takes 2 positional arguments but 3 were given
ok you clearly dont understand python oop
you forget to add a parameter to pass your bot to your view
then make a bot attribute on view yourself
def __init__(self,bot):
self.bot = bot``` I am defining bot here (Sorry if i have read your message wrong)
that is a cog ...
yes, for my command as it wont send any modal now
