#General Help

1 messages · Page 20 of 1

carmine portal
#

Yea but how to do it ?

slow dome
#

depends on your implementation. Are you subclassing it or creating a view/dropdown object

carmine portal
#

        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!")




slow dome
carmine portal
#

Nah it's not, only in the cog class

slow dome
slow dome
carmine portal
#

I did not understand

slow dome
#

Do you know object oriented programming?

carmine portal
#

No what it is ?

slow dome
#

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.

carmine portal
#

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️⃣"))


slow dome
#

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

carmine portal
#

okay i'll try it

#

ty

grave wraith
#

how do I get the message of an interaction.response.send_message?

carmine portal
grave wraith
#

The message sent with interaction.response.send_message

#

I want to get the discord.Message object of this message

carmine portal
#

there is an event when the bot waits for the user to make a choice in a drop-down menu?

languid hollow
#

await interaction.response.send_message(.....)

#

oh

#

um

grave wraith
#

yeah

languid hollow
#

can you send over your code

grave wraith
#

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`.
languid hollow
#

(embed=[embed])

slow dome
languid hollow
#

do you want to edit your original message?

grave wraith
slow dome
grave wraith
#

No

languid hollow
#

so you're saying that you want to use?

response = await discord.message.send(...)
grave wraith
slow dome
languid hollow
#

Ah

#

oh sorry I didn't see the embed

slender lintel
#
  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

slow dome
#

I think some games use json files to store dialogue. Maybe you can do something similar with your embeds

slender lintel
slow dome
#

do you know what json files are?

slender lintel
slow dome
slender lintel
#

Thanks

slender lintel
#
   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

slow dome
#

that should work

slender lintel
#

okay

slender lintel
slow dome
#

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

slender lintel
#

Wouldnt json also have long lines?

#

Jsons are confusing me lol

languid hollow
#

is it possible to do an interaction check with link button and get the users interaction with the button?

slow dome
languid hollow
#

A

#

I wanted to get an interaction with the button

#

and give the users a role

slender lintel
#

how do i send a image in a embed?

slow dome
#

b!rtfm discord.Embed.set_

open bearBOT
# slow dome 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

slow dome
#

b!rtfm pyc discord.Embed.set_

slow dome
#

b!rtfm pyc discord.Embed.set_image

open bearBOT
slender lintel
#

k]

#

thx

#

is like add_feild @slow dome

#

?

slow dome
slender lintel
#

Lol

slender lintel
#

What

#

I just said lol

#

Chill mate

static crescent
#

Is anyone else receiving issues with their bots? I am getting an unknown interaction issue out of nowhere.

slender lintel
#

Nope just you, any errors in console?

static crescent
#

Not at all.

slender lintel
#

Code for command or event?

static crescent
#

Nevermind, I found the error, it's something with my database.

slender lintel
#

Oof, good luck fixing it

static crescent
#

Appreciated.

slender lintel
#

for url

#

it has to be on web?

slender lintel
#

such as imgur or imgg

#

What would i use to create a channel once the bot receives a dm?

upbeat hill
#

any ideas for a fix?

slender lintel
#
  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

steep verge
#

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?

slender lintel
past gate
slender lintel
steep verge
steep verge
worthy basin
#

Wait, read the last thing you said

slender lintel
#

I didnt change anything litearly just changed some text in a string

outer valley
#

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)

slender lintel
#

2

outer valley
#

y does just changing the func name from on_message to onmessage makes it stop working?

slender lintel
#

although just use commands lol

slender lintel
outer valley
worthy basin
#

It used the function name to determine what event should trigger it

outer valley
#

ahh i c thanks

past gate
worthy basin
steep verge
past gate
#

hm

#

weird

slender lintel
past gate
slender lintel
#

should i update github?

worthy basin
#

I gtg, you could try looking at the git diff or revert to the last commit you did from your github

slender lintel
#

okay

steep verge
slender lintel
#

how do i put image on tiop?

#

i have this

steep verge
#

I printed the libraries variable and yes it’s a list object

slender lintel
#

but how do i put on top of embed

past gate
#

could you show an example? also make a thread so we dont step on people's convos

steep verge
slender lintel
#

Restarted discord again.. works now

upbeat hill
slender lintel
upbeat hill
#

that is the class that is causing the issue

slender lintel
#

What line is '371'

slender lintel
worthy basin
#

The callback need to take the select argument as well

#

discord.Select is the type

upbeat hill
supple ravineBOT
#

Here's the persistent example.

outer valley
#
@bot.command()
async def inactive(ctx,days: int):
    await ctx.reply(discord.Guild.estimate_pruned_members(days))```
#

what's wrong with this

worthy basin
#

Is there an error?

outer valley
#

no reply

past gate
#

.send

outer valley
#

no output

upbeat hill
# worthy basin discord.Select is the type
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

outer valley
past gate
#

odd

worthy basin
#

.respond()

outer valley
#

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')```
worthy basin
upbeat hill
#

Select cant have a timeout

upbeat hill
#

fixed the pycord issue and now some things are still broken

worthy basin
#

You are on the latest version correct?

upbeat hill
#

dev

worthy basin
#

2.0.0rc1

upbeat hill
#

believe so

worthy basin
#

Ok

outer valley
#

bot is replying to other commands

worthy basin
#

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.

worthy basin
upbeat hill
worthy basin
upbeat hill
outer valley
#
  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'```
slow dome
outer valley
#
@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)```
slow dome
#

do you know what discord.Guild is?

#

it's a class

#

and you are using it like an object

outer valley
#

which in simple terms means lol

slow dome
#

that's the simplest I can put it

#

You should first learn OOP

#

object oriented programming

outer valley
#

i shall do that first then

#

thanks

slow dome
#

you should, Pycord is not meant for beginners

jagged oak
#

how do I make the bot delete the message that contains the "delete button" as soon as it is clicked?

jagged oak
#
        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```
slow dome
#

and is this inside of a command?

jagged oak
#

a slash command

#

do you want the whole command?

jagged oak
#

Any idea?

outer valley
#
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

outer valley
#
@bot.command()
async def inactive(ctx,days: int):

    await ctx.send(no(days))```
crimson coral
#

you need to await no

outer valley
#

but i am awaiting it

#

aren't i

crimson coral
#

no, you're awaiting send

#

await doesn't apply to every function in the line

outer valley
#

i c thanks

slender lintel
#
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
crimson coral
#

uhhhh

#
  1. indent level for command is wrong
  2. you're trying to pass the cog into embeds...?
slender lintel
#

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.```
crimson coral
#

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...?

jagged oak
#

@crimson coral how do I make the bot delete the message that contains the "delete button" as soon as it is clicked?

crimson coral
#

what have you tried so far

slender lintel
#
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?)
crimson coral
#

yes, the command should be outside of the Suggest class

slender lintel
#
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?
crimson coral
#

yes, but now remove the self from the command because it's no longer in a class

slender lintel
#

Oh alr

slender lintel
# crimson coral yes, but now *remove* the `self` from the command because it's no longer in a cl...
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)
jagged oak
crimson coral
#

ok

slender lintel
#

oh lol

#

im dumb

crimson coral
#

wait

slender lintel
#

yeah?

crimson coral
#

please don't call your cog and modal classes the same name

slender lintel
#

Okay ill change it, but why?

jagged oak
#
@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()```
crimson coral
#

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

slender lintel
#

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
jagged oak
#
if button1:
    button1.callback = await arg.delete()
    button1.callback = regado```
@crimson coral in this
crimson coral
#

oh i see

crimson coral
half marsh
#

🥵

slender lintel
crimson coral
#

no need to apologize to me, you're just making it harder for yourself

slender lintel
#

I hate indents in python haha

half marsh
slender lintel
#

Where about is my indentation error? I am new w modals

slender lintel
#

its worse than py

crimson coral
jagged oak
#

@crimson coral can u help me?

crimson coral
#

yeah 1 sec

slender lintel
#

Thanks I will. Fix that tomorrow, going to sleep Joe

jagged oak
#

thanks

slender lintel
#

Now

crimson coral
jagged oak
#

everything is working

crimson coral
#

so everything apart from deleting

jagged oak
#
            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

jagged oak
crimson coral
#

so when someone clicks button1 specifically

#

or just any button

jagged oak
#

it eliminates before clicking the button, thats the problem

jagged oak
crimson coral
#

well i'll show you why

crimson coral
#

does button1 have any other behavior? or should it just delete the message

jagged oak
#

button1 has to delete the message and callback the 'regado' again

jagged oak
crimson coral
#

so basically remove that await arg.delete() line and we'll try something a bit different

jagged oak
#

ok

crimson coral
#

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.

jagged oak
#

I can't get it to work

inner iris
#

I'm passing two embeds to a message but only one is shown. Am I doing something wrong or is that intended?

inner iris
#
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)
inner iris
#

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

slow dome
#

how are you sending the embed

inner iris
midnight cedar
#

iirc discord has a weird thing that combines images from multiple embeds if the embeds have the same url

midnight cedar
#

url i believe

inner iris
#

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

midnight cedar
#

like the title url

inner iris
#

oh yes now it works

#

why is this though?

midnight cedar
#

idk

inner iris
#

btw. what does iirc stand for?

midnight cedar
#

ask discord

midnight cedar
inner iris
midnight cedar
#

yes

inner iris
inner iris
pale igloo
#

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)

inner iris
pale igloo
#

A warn command, Like ?warn @pale igloo <reason>

inner iris
#

Do you know how to create a basic command?

pale igloo
#

Yes

inner iris
#

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 🙂

pale igloo
#

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!')
slender lintel
#

I'm not very good with databases myself but I recommend mongodb or postgresql.

pale igloo
#

Alright. Thanks!

#

Ill give that a try later. gonna go to bed now

slender lintel
#

gl

upbeat hill
#

anyone know how to get rid of the interaction failed even though it sends a message

upbeat hill
sudden path
#

Interaction.response.send_message

upbeat hill
slender lintel
upbeat hill
sudden path
#

Is how you use it

#

You respond to interactions.

upbeat hill
#

IK

sudden path
#

Otherwise they'll mark as failed

upbeat hill
sudden path
upbeat hill
#

As that sends the message as a standalone message

sudden path
#

It won't work with interactions

slow dome
#

b!rtfm pyc interaction.response

open bearBOT
slow dome
#

b!rtfm pyc interaction.respond

open bearBOT
slow dome
#

b!rtfm pyc interaction.respond

open bearBOT
slow dome
#

b!rtfm pyc respond

slow dome
#

await interaction.response.edit_message()

outer valley
#
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

crimson gale
#

error is self explanatory

outer valley
#

yes it is i just don't know how to make it wait

crimson gale
#

await

#

basic python

outer valley
#

i have added await

#

tried this a = await no(days) await ctx.send(a)

#

where can i learn more on this

crimson gale
#

you can use coroutines in function args

slender lintel
#

?tag lp

hearty rainBOT
#
slender lintel
#

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' Kek

static gull
twilit cobalt
#

is there a way to make a general error handling for when interaction doesnt respond due to an error in a slash comamnd

vivid nacelle
#

it is possible but yeah we don't support it yet

#

mainly because it crashes some clients

slender lintel
#

anyone know how to host a lavalink server on a vps?

#

and even know how to create the fucking server!!!

drifting spindle
#

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

half marsh
#

but their documentation is kinda :meh:

#

anyway there should be not much different since pyc is fork from the original one 🤷‍♂️

gilded widget
#

documentation, guide, and examples are pretty helpful

errant verge
#

can i use
elif something in []: for lists?

neat tide
#

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'

outer valley
slender lintel
#

i keep getting error when using lavalink

finite cliff
#

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

drifting spindle
upbeat hill
#

is there a way to get the interaction of a button to send a message but not as a reply?

drifting spindle
crystal verge
#

Guys all I have to do to change normal commands into slash is to change the decorator? Right?

slender lintel
#

fix?

#

anyone

outer valley
#
@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
crystal verge
#

So I have to change the decorator 5o change the commands type right?

frigid lark
#

how can I send a modal to a specific channel?

worthy basin
#

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?

worthy basin
#

Along with many other small things that you will find when testing your bot

crystal verge
upbeat hill
#

can you make a button unuseable for someone?

slender lintel
#

If it’s a modal or button

#

But yea button

#

Interaction.response.edit_message does the same thing for every interaction

drifting spindle
celest moth
#

is it possible to copy to clipboard using pycord?

sudden path
sudden path
fair drift
#

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?

past gate
#

believe its choices not options

worthy basin
#

^ they are right

fair drift
#

'-'

#

aaaaa

#

i'm damn

worthy basin
#

Honestly it is a bit confusing

fair drift
#

Yeah

#

How do I do then?

worthy basin
fair drift
#

Ah

#

But... how do I do that?

#

'-'

tepid anvil
#

Is there to way convert in python

ᗅ𝓃nဝun𝕔ҽmen𝓽 𝚩οt to announcement bot

past gate
#

linguagem: Option(str, "Escolha a linguagem da sua aplicação.", choices=language_list),

fair drift
#

.-.

#

ah

#

ah

#

'-'

#

omg

past gate
#

specifically the normalize function

tepid anvil
past gate
#

wdym?

languid hollow
#
commands.BucketType.role

will that make a cooldown for the Role Captain?

earnest rampart
#

anyone know how to create a command that can only be used w certain roles

#

would it be something like

languid hollow
#

second line of my code

earnest rampart
languid hollow
#

put the Role name in the strings

earnest rampart
#

ty

#

can u make it have multiple roles by using commas?

#

@languid hollow

languid hollow
earnest rampart
#

oops

#

didnt mean to ping

earnest rampart
languid hollow
#

you can give it a go

earnest rampart
upbeat hill
#

is there a way to make a command that clears the dms with the bot?

slender lintel
slow dome
upbeat hill
slow dome
#

this may be helpful

upbeat hill
slow dome
#

so discord.Member inherits from discord.User

#
async for message in user.history(limit=200):
  if message.author == bot.user:
    await message.delete()
upbeat hill
slow dome
#

which ones

upbeat hill
#

normal prefix ones

odd zealot
#

is it possible to edit the description of a select option, after its selected by a user?

slow dome
upbeat hill
# slow dome yeah
@bot.command()
async for message in bot.user.history(limit=200):
  if message.author == bot.user:
    await message.delete()
```??
slow dome
upbeat hill
slow dome
#

in ctx.author.history

odd zealot
# slow dome sure

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?

slow dome
#

and edit self

odd zealot
#

uhmmm

#

how to?

slow dome
#

self is a discord.ui.view

odd zealot
#

yes

#

and now how do i edit the options?

slow dome
#

well, you can just edit them

odd zealot
#

yes

#

but HOW

crimson gale
#

you can access options of the select object

slow dome
#
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

odd zealot
#

its undefined?

#

how do i define it

crimson gale
#

label is a string, value i believe can be anything that is a basic type

odd zealot
#

i dont mean this

#

i mean the select.options

crimson gale
#

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?

odd zealot
#
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

crimson gale
#

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

odd zealot
#

i dont understand

crimson gale
#

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

odd zealot
#

so

#

when i understand it right

#

i can put the class Enable in the class EnableView

crimson gale
#

the callback specifically yes

slender lintel
sleek grove
#

guys how can i make a prefix command in a cog

past gate
#

look at the examples on the github

sleek grove
#

when i use them i have a error

#

it sounds like not setuped the command

odd zealot
#
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'
sleek grove
sleek grove
#

#986655928440999987 message but only with a @commands.command

slow dome
#

@commands.command()

odd zealot
#

okay

sleek grove
odd zealot
#

is it possible to edit the placeholder from my select menu

odd zealot
#

i mean in the timeout

slow dome
#

select.placeholder

#

well self.children

odd zealot
#

i cant do just self.placeholder

slow dome
#

returns all of them

#

and just have to find it

odd zealot
#

self.children[0]

#

i only have one

slow dome
#

ok then self.children[0].placeholder = "hi"

#

and then edit the message

sleek grove
odd zealot
#

yes

odd zealot
sleek grove
#

need help bros

slow dome
sleek grove
#

can i do work updoad?

slow dome
sleek grove
#

or mediafire

slow dome
#

doesn't matter

#

just do it somehow

neat tide
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id' showing this error

past gate
#

code? @neat tide

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)

past gate
#

please format you code

slow dome
# odd zealot well how to?
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

hearty rainBOT
#

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?

past gate
#

what?

odd zealot
#

delete it please

neat tide
#

format

neat tide
past gate
#

format your message with the code you sent

#

not your code in your IDE

sleek grove
neat tide
#

ok

odd zealot
slow dome
odd zealot
sleek grove
neat tide
#

same error

neat tide
#

ok

#

sorry my mistake

past gate
open pollen
slow dome
sleek grove
steady lotus
#

i keep getting this

#

checking logs

#

one command is posted twice

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)
#

here

past gate
#

read what I said

neat tide
#

my net

#

sorry

#

i am sending wrong one

muted drift
#

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?

jagged oak
#

Hi guys, can someone write me code to send a specific message every 35 minutes of every hour?

muted drift
#

heres some example code

jagged oak
slender lintel
# crimson coral basically, your `modal_slash` command is part of your `Suggestions` Cog class. Y...
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
jagged oak
#

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?

slender lintel
errant verge
#
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?
slender lintel
# slender lintel ```py import discord from discord.commands import slash_command from discord.ext...
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))```
slender lintel
#
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

past gate
#

Not sure you've realised but this has nothing to do with indentation

tawny shore
#

does bridge doesnt work in Cogs properly?

past gate
slender lintel
past gate
#

self goes first

slender lintel
#

Oh mb

slender lintel
# past gate self goes first
  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

past gate
#

you're missing self in modal_slash

slender lintel
#

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'```
past gate
#

modal = Suggestions(title="Modal via Slash Command")

#

you called your modal class Suggest not Suggestions

desert dagger
#
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?

slender lintel
#

@past gate

past gate
#

yes hi

slender lintel
#

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

past gate
#

whats your code currently?

open pollen
jagged oak
#
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

slender lintel
#

I dont think that matters, I get it when stopping my bot and no issues

jagged oak
#

but the problem is, I cant run the bot....

slender lintel
jagged oak
#

does anyone know why?

slender lintel
#

Use

bot.run(os.getenv("TOKEN"))```
#

from dotenv import load_dotenv
load_dotenv()
at top too

slender lintel
#

can someone help me? lmfao

slender lintel
jagged oak
slender lintel
jagged oak
slender lintel
#

ngl this new help system is so messy

#

cuz the posts are so hard to go through

#

and general help is like dead

slender lintel
frigid lark
slender lintel
#

if u have 'token'

slender lintel
frigid lark
#

I use a json file

slender lintel
#

cool

jagged oak
#

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')
slender lintel
frigid lark
slender lintel
#

im not great

slender lintel
jagged oak
slender lintel
foggy flax
#

let me look

#

ohno I have to go

#

oh god

frigid lark
slender lintel
#

(did this ping you?)

foggy flax
#

yep

slender lintel
# foggy flax yep

Okay, May you help sorry? I am really confused (Yes, I have asked google and docs)

fair drift
#

AttributeError: module 'discord' has no attribute 'default_permissions'

frigid lark
fair drift
slender lintel
fair drift
#

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:

frigid lark
#

You need rc1

fair drift
#

hmmmm

steady lotus
#

are command cooldowns fixed to the callback?

fair drift
#

thanks

frigid lark
#

Uninstall this version and use
pip install py-cord==2.0.0rc1

fair drift
#

v2.0.0-rc.1?

#

ah

#

ok

frigid lark
slender lintel
slender lintel
#
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))```
frigid lark
#

Oh you use the wrong class

past gate
slender lintel
#

I just sent it now

frigid lark
#

U use the cog and not the modal

slender lintel
#

wym?

#

themofal?

#

oh

#

where

past gate
#

You did suggestions instead of suggest

frigid lark
#

modal =Suggestions()

past gate
#

Clearly didn't read a thing I said

slender lintel
frigid lark
#

Yes

slender lintel
#

I didnt notice that, thanks to u both (Sorry fish didnt see ur msg)

past gate
slender lintel
#

ty

slender lintel
# past gate <@456226577798135808>
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)

past gate
#

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

slender lintel
#

o lol

past gate
#

👍

slender lintel
# past gate 👍
  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
slender lintel
frigid lark
#

No

past gate
#

It should be name not title iirc

slender lintel
#
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

frigid lark
#

modal = Suggestions(title="text")

slender lintel
errant verge
#

why does my bot sometimes do this?

frigid lark
errant verge
#

nothing on my end then ?

past gate
#

Nope

frigid lark
#

^

past gate
#

Just cache n stuff doing it's thing

errant verge
#

theres no workaround to this?

slow dome
frigid lark
slender lintel
#

and it same eror

frigid lark
slender lintel
frigid lark
#

I know, you have copy it ;3

fickle spruce
#

The bot doesn't send the message, why?

frigid lark
slender lintel
#

msg = await interaction.response.edit_message(content="")
why cant i do msg.edit after that

slender lintel
#

??

frigid lark
#

Falsche Person xd

slender lintel
#

why u saying thx to me? wrong reply?

slender lintel
slender lintel
slender lintel
fickle spruce
slender lintel
#

and basically that gets the message part of the interaction response message

#

and then message.edit eddits it

#

yep

#

thanks

#

np

frigid lark
slender lintel
frigid lark
slender lintel
slender lintel
slender lintel
# frigid lark In the example is the title in "modal =MyModal(title="text")"

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'```
fickle spruce
#

@frigid lark der wählt nur das letzte aus weißt du vlt warum?

frigid lark
frigid lark
slender lintel
#

Alr

frigid lark
#

and dont have the same name like the slash command for the embed

crimson hinge
frigid lark
fickle spruce
#

it doesn't show anything

#

only the last one the "serverteam bewerbung"

crimson hinge
#

@fickle spruce try this out

if "Regelwerk" in str(interaction.data.values()):
crimson hinge
frigid lark
frigid lark
fickle spruce
frigid lark
#

I mean the stuff with the values

frigid lark
fickle spruce
#

no now its doesnt send anythink

frigid lark
fickle spruce
#

k

languid hollow
#

What does check mean?

#

like what messages

#

and does bulk = True delete pinned messages as well?

frigid lark
#

you have 4

#

with only 1 it works

#

with 2 or more not

fickle spruce
#

ohh

frigid lark
fickle spruce
#

it works😆 thx

frigid lark
#

\o

frigid lark
#

(Im not sure if bulk do that)

cyan olive
#

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

cyan olive
past gate
#

stonks

cyan olive
#

also i fixed the problem i think

past gate
#

👍

wide cloak
#
@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?

errant verge
#
@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

crimson gale
jagged oak
#
    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

sudden path
#

You're looking for tasks.

supple ravineBOT
#

Here's the background task example.

jagged oak
#

i still dont know how to do it

#

can u help me?

open pollen
steady lotus
#

is there a way to update a cooldown's retry after?

sudden path
analog elk
#

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

slow dome
slow dome
solar berry
#

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

slow dome
#

because all of them are shown

solar berry
#

Thank you

#

Also, is there a direct setting that makes @ mentioning the bot always work as a prefix

terse plinth
#

client = commands.Bot(prefix = commands.when_mentioned_or('!'))

#

it should be something along those lines

solar berry
#

:o thank you

terse plinth
#

np

terse plinth
analog elk
#

why not

#

Having a concise list of commands is definitely necessary

#

also people are used to using help to see all the commadns\

solar berry
#

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

jagged oak
terse plinth
#

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

harsh turtle
#

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

steady lotus
upbeat hill
#

how would you get users @ in a message added to a list which gets the bot to send them a message?

upbeat hill
#

ye

winged tiger
#

Can’t you just add that to a list?

upbeat hill
#

hmmm that could work, sorry for the ping btw

winged tiger
#

Haha it’s fine - happens literally all the time. Curse my name!

upbeat hill
#

ahaha yeah

upbeat hill
#

bit stuck

winged tiger
upbeat hill
#

where wumpus#0000 to be reinstated is the question

open pollen
#

is there an @bot.event that triggers when the bot joins a voicechannel?

inner iris
#

Is there any way to edit an ephemeral message?

slender lintel
#

await interaction.response.send_message(embeds=[Suggestions]) Says i am missing self, but where?

inner iris
#

code?

slender lintel
#
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'```
inner iris
#

you are passing a modal as an embed...

open pollen
slender lintel
inner iris
#

try await interaction.response.send_message(embeds=[suggest])

inner iris
slender lintel
# inner iris try `await interaction.response.send_message(embeds=[suggest])`
  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'
inner iris
open pollen
#

I did

#

but didn't find anything

inner iris
slender lintel
#

oh my bad

inner iris
frigid lark
#

@slender lintel did you read the messages?

slender lintel
#

but its fixed now

#

thanks

frigid lark
#

Ok?

inner iris
slender lintel
#

suggest = discord.Embed(title="Suggestion by {user}") What would i use to get the member who sent the modal/embed

inner iris
slender lintel
#

Oh okay

inner iris
#

An Embed and a Modal are two completely different things...

slender lintel
slender lintel
#

so i was confused

inner iris
slender lintel
inner iris
#

oh you don't even know if it works...
it probably doesnt...

#

like you did it.

#

I thought you already tested it.

slender lintel
#

Oh, No i hadnt

#

I want it to be
suggestion by ignfoolish

#

for example

inner iris
#

yeah well just learn python at this point...
Usage of f-strings and basic python. And then learn to use the docs and examples...

slender lintel
#

discord.Embed(title=f"{user} Suggested ") user is not defined

inner iris
#

try interaction.user

#

if that doesn't work create a post.

slender lintel
slender lintel
#

wtf ?

frigid lark
slender lintel
#

what is rc1?

frigid lark
#

uinstall the old version and use
pip install py-cord==2.0.0rc1

slender lintel
#

oh okey

frigid lark
#

restart the editor after the installation

slender lintel
#

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
sudden path
#

Why are you adding interaction

frigid lark
sudden path
#

He's sending it to another channel tho?

#

Just channel.send

frigid lark
slender lintel
sudden path
#

Just send the result with channel.send (the channel you got)

slender lintel
#

... modals dont work with channel.send

#

we just said that

sudden path
#

And then just respond to the interaction so it doesn't "fail"

slender lintel
#

🤦

frigid lark
#

Maybe that work

slender lintel
#

Ill try it

sudden path
#

You're in the modal callback

#

You just said you want to send the result to a different channel the modal was invoked from.

slender lintel
#

Correct

sudden path
#

Then what I'm saying is correct.

frigid lark
sudden path
#

await channel.send(embed=embed)
await interaction.response.send_message("Successfully sent your suggestion!")

slender lintel
# frigid lark Try it...
  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```
slender lintel
sudden path
#

Why it won't work?..

slender lintel
frigid lark
sudden path
half marsh
#

what are you tryna do again?

half marsh
#

oo

slender lintel
#

yes what dark said

half marsh
#

then get a channel with .get_channel(id)

slender lintel
#

channel = self.bot.get_channel(964130201514692628)

#

I have that

half marsh
sudden path
#

I assume you passed bot to the modal class

#

So it shouldn't be an issue.

slender lintel
#
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

sudden path
#

self.children[0].value

#

It is a list

frigid lark
sudden path
#

99% of python is 0 indexed

#

He only got one input

#

0 is the first one

#

That's why 1 is out of range

slender lintel
sudden path
#

Yes

slender lintel
#
  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.

half marsh
slender lintel
#
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)```
sudden path
#

You pass the bot object when creating the view

slender lintel
#

oh yeah why did i send that one lmao

slender lintel
sudden path
#
# in some slash command
await ctx.send_modal(Suggestions(self.bot)) # assuming youre in a cog```
slender lintel
#

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
half marsh
slender lintel
#

hopw

#

how*

half marsh
#

you forget to add a parameter to pass your bot to your view

#

then make a bot attribute on view yourself

slender lintel
#
    def __init__(self,bot):
        self.bot = bot``` I am defining bot here (Sorry if i have read your message wrong)
slender lintel
#

yes, for my command as it wont send any modal now