#Upgrading help command to buttons

1 messages · Page 1 of 1 (latest)

tired tide
#

any error?

balmy cargo
#
async def hello(ctx):
  button = Button(label="Click me!", style=discord.ButtonStyle.green, emoji=":joy:")
  view = View()
  views.add_item(button)
  await ctx.send("Hi!", view=view)```
#

this is it

#

I am just testing buttons and even testing doesn t work so I cannot create help command with it becuase it doesn t work even emty

#

Can someone please explain or say what i am dong bad?

#

or how to create help commnad with buttons that will work

tired tide
#

can you send the pip list?

balmy cargo
#

pip list? where can i find it I forgot

tired tide
#

cmd and pip list

balmy cargo
#

I am using repl it where do I find it there?

tired tide
#

shell

north salmon
#

Your issue is probably that it's installing discord.py as well

balmy cargo
#

How to fix it

tired tide
#

uninstall it

#

and discord

balmy cargo
#

But than my whole bot stop working or no?

tired tide
#

do it

balmy cargo
#

okay

tired tide
#

!replit

hollow topazBOT
balmy cargo
#

I have to install pycord?

#

is it better

#

?

tired tide
balmy cargo
#

so what to do? uninstall discord.py? and isntall pycord?

#

or?

tired tide
#

uninstall discord.py and discord, create a file with .replit

balmy cargo
#

Like this?

#

tahts it?

shell abyss
#

yes

balmy cargo
#

and now?

#

now my bot do not even work

#

what to do now?

#

No errors

#

What to do - to - my bot again start working

shell abyss
#

?tag intents

indigo horizonBOT
#

https://docs.pycord.dev/en/master/intents.html
https://discord.com/developers/docs/topics/gateway#gateway-intents

import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

shell abyss
#

?tag message-content

indigo horizonBOT
#

As of Pycord Beta 5, Discord API v10 requires message content intent to receive message content. This affects the traditional commands. Not enabling this intent will result in the messages' content, embeds, and components being empty.

You will need to enable the intent on the developer portal, as well as in your code:

intents = discord.Intents.default()
intents.message_content = True
bot = discord.Bot(intents=intents)

Docs: https://docs.pycord.dev/en/master/api.html#discord.Intents.message_content

balmy cargo
#

and it have 2000 lines

#

what to do now

#

My bot commands doesn t work

#

only bot is online

#

Bot is online, but nothing works: commands, changing status etc. what to do?

#

@north salmon what to do now

#

my whole bot commands do not work after doing what you gyus said

north salmon
#

Did you turn on the message_content intent?

balmy cargo
#

this? if so, yes

north salmon
#

Yeah

balmy cargo
#

still do not work

#

No error

north salmon
#

Is the bot turning on?

balmy cargo
#

Yeah he is online

#

oh, now he isnt

north salmon
#

Are there any errors?

balmy cargo
#

He si offline and no errors

north salmon
#

Is the message content intent turned on in the dev portal?

#

By the way, could you send you main.py file

balmy cargo
#

this?

north salmon
#

Yeah

balmy cargo
#

and what to do with it? i cannot turn it on

north salmon
#

Oh

balmy cargo
#

or can I

#

oh I need to apply for that

north salmon
#

Yeah you're gonna need that if you want to use prefixed commands

balmy cargo
#

it wasn t like that?

north salmon
#

I don't think Discord gives it just for prefixed commands though

north salmon
balmy cargo
#

yeah I made that bot 2 years ago

#

I do not remember a lot of things and they changed a things

#

so I need to apply for it?

north salmon
#

Yeah

#

or migrate to slash commands

#

But for now, do this:

discord.http.API_VERSION = 9
#

that should allow you to use prefixed commands

balmy cargo
north salmon
#

It's stuff like this:

#

They're built into Discord

balmy cargo
#

ohh, never seen that that s cool

north salmon
#

Add it above where you create your bot object

balmy cargo
#

Okay, where to put it? replace with message intent = true...?

north salmon
#

Yeah

#

Just replace it with that

balmy cargo
#

like that? right

north salmon
#

Yeah

balmy cargo
#

Okay now it works

north salmon
#

You're welcome

balmy cargo
#

So now after fixing everything I need to finally do what I created this help post for

#

upgraded help with buttons that did not worked

#

Okay now working

north salmon
#

I would recommend migrating to slash commands, which is included in https://guide.pycord.dev, because Discord won't give you the message content intent for prefixed commands

balmy cargo
north salmon
#

Nice

balmy cargo
#

😎

balmy cargo
# north salmon Nice

So now everything should work like in docs? right nothing else needed to funcional buttons commands

north salmon
#

Yeah all you need is pycord

balmy cargo
#

okay

balmy cargo
#

@north salmon Can you help me again with this one pelase

#

I do not know where is problem

north salmon
# balmy cargo

You can't set button.disabled=True within the button constructor, you have to use disabled=True instead

balmy cargo
#

oh, tahnk you so much :D

north salmon
#

You're welcome

balmy cargo
#

@north salmon sorry for pinging but I need help, I cannot find anywhere. How to make pages through buttons for help command

north salmon
#

You could use ext.pages

balmy cargo
#

Something like dank memer have

#

I want to create

north salmon
#

yeah ext.pages would work for that

#

An example is available in the guide

balmy cargo
#

yeah? i cannot find it

balmy cargo
north salmon
north salmon
balmy cargo
#

okay thanks i am gonna find it

north salmon
#

You're welcome

balmy cargo
#

@north salmon I do not really understand that docs. How to create pages from this? because I do not know where to put things. that docs are chaos

#
    @discord.ui.button(label="A button", style=discord.ButtonStyle.primary, disabled=True) 
    async def button_callback(self, button, interaction):
        ...




@client.command()
async def button(ctx):
  
  
  button1 = Button(label="⬅ ⬅", style=discord.ButtonStyle.blurple, disabled = True)
  button2 = Button(label="⬅", style=discord.ButtonStyle.blurple, disabled = True)
  button3 = Button(label="➡", style=discord.ButtonStyle.blurple)
  button4 = Button(label="➡ ➡", style=discord.ButtonStyle.blurple)
  view = View()
  view.add_item(button1)
  view.add_item(button2)
  view.add_item(button3)
  view.add_item(button4)
  await ctx.send("1 2 3 4 5 6 7 8 9 10 11 12", view=view)```
#

How to create pages from this, and buttons that will switch the pages

north salmon
balmy cargo
#

So what to do with that code

north salmon
#

So you should make a list of pages, which will be displayed by the bot:

page_list = [discord.Embed(...), "some string", "another string"]
#

And then you don't need any of the buttons

#

Since the paginator has its own buttons

#

And then you can do this:

paginator = pages.Paginator(pages=page_list)
await paginator.send(ctx)
#

And that will allow the user to loop through all the pages in the help command

#

If you want to have the select menu, then you can instead do this:

page_group_1 = pages.PageGroup([discord.Embed(...), "something"], label="Help command set 1")
page_group_2 = pages.PageGroup(["some more", discord.Embed(...)], label="Command set 2")
paginator = pages.Paginator([page_group_1, page_group_2])
await paginator.send(ctx)
#

And that should create the select menu as well by default

#

So that's how you could create a select menu help command with buttons

balmy cargo
#

thank you

#

so

#

delete this:

#

and replace with paginator

north salmon
#

yeah pretty much

balmy cargo
#

It is giving me error

north salmon
#

Yeah, that'll create two different sets of pages that can be switched between using a select menu

north salmon
balmy cargo
#

no

north salmon
#

Yeah make sure you do that

balmy cargo
#

this?

north salmon
#

Yeah that works as well

balmy cargo
#

still do not work

north salmon
#

Send the error

balmy cargo
north salmon
# balmy cargo

Oh, you need to do

PageGroup(pages=[...], label="some label")
balmy cargo
#

where?

#

istead of this:?

north salmon
#

Yeah, just add pages= before the lists

balmy cargo
#

?

north salmon
#

before [discord.Embed(...), ...] and ["some more", ...]

balmy cargo
#

like that?

#

Error

north salmon
#

no, put pages= to the left of the [

balmy cargo
#

okay

#

Error again

#

So what to do?

#

@north salmon do you know?

north salmon
#

What error?

balmy cargo
north salmon
balmy cargo
north salmon
#

Try to replace your code iwth this:

          page_groups = [
            pages.PageGroup(
                pages=self.get_pages(),
                label="Main Page Group",
                description="Main Pages for Main Things",
            ),
            pages.PageGroup(
                pages=[
                    "Second Set of Pages, Page 1",
                    "Second Set of Pages, Page 2",
                    "Look, it's group 2, page 3!",
                ],
                label="Second Page Group",
                description="Secondary Pages for Secondary Things",
                custom_buttons=page_buttons,
                use_default_buttons=False,
                custom_view=view,
            ),
        ]
        paginator = pages.Paginator(pages=page_groups, show_menu=True)
        await paginator.send(ctx)
balmy cargo
#

error

north salmon
#

Yeah make sure that you indent it correctly

balmy cargo
#

@north salmon What is wrong on this

#

@tired tide Do you knwo how to fix this?

short stirrup
#

paginator should have the same indentation as your await paginator.send....

balmy cargo
#

So what to do

short stirrup
#

Backspace 2 indentation 💀

balmy cargo
#

☠️

short stirrup
#

It's basic python 💀

balmy cargo
#

I know

#

But still explain

short stirrup
#

Just press backspace until that line is correctly above your await paginator.send

balmy cargo
#

like taht?

#

or?

#

💀

short stirrup
#

Both lines should have same amount of tabs\spaces

balmy cargo
#

So what to do bro?

short stirrup
#

Delete button

balmy cargo
#

oh I get it like I get girls, I do not

#

Okay know I really get it

#

like this?

short stirrup
#

You removed all indentation for both the lines 🥖

#

Press 1 tab

#

At the start

#

Of both of those lines

balmy cargo
#

like taht?

short stirrup
#

YES

#

Well done

balmy cargo
#

Still eror

short stirrup
#

What

#

Error

balmy cargo
short stirrup
#

Oh bruh

#

You didn't make a constructor

#

I don't really work much with paginators so I can't help you much

pure cove
#

Can you show your code in button

balmy cargo
pure cove
#

you have no self so self.get_pages() isn't going to do anything

tired tide
#

Im not sure if its a good idea to call the command "button"

pure cove
#

just delete that first page group

#

also this is basic python...

balmy cargo
balmy cargo
pure cove
#

it is though

balmy cargo
#

still do not work

pure cove
#

?tag idw

indigo horizonBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

balmy cargo
#

this is error

pure cove
#

bruh

#

read the error

#

read the line of code it's pointing at

balmy cargo
#

of I see

#

Again error

pure cove
#

again these are basic python errors

#

you're trying to use a variable page_buttons that you never defined

balmy cargo
#

So what to do?

#

I am new to pycord and I made last update on my bot 2 years ago

pure cove
#

don't use a variable you haven't defined, or define it

#

sounds like you're also new to python

#

?tag lp

indigo horizonBOT
#