#Upgrading help command to buttons
1 messages · Page 1 of 1 (latest)
wait I will send you one after i do it again
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
can you send the pip list?
pip list? where can i find it I forgot
cmd and pip list
I am using repl it where do I find it there?
shell
Set up your .replit file so that guessImports is false: https://docs.replit.com/programming-ide/configuring-repl
Every new repl comes with a .replit and a replit.nix file that let you configure your repl to do just about anything in any language!
Your issue is probably that it's installing discord.py as well
But than my whole bot stop working or no?
do it
okay
!replit
Read this to find out how you can install Pycord in replit - https://namantech.me/pycord/installation/#replit
How to install the Py-cord library - Pycord Guide
pycord is a fork from discord.py
uninstall discord.py and discord, create a file with .replit
you can see it here
yes
and now?
now my bot do not even work
what to do now?
No errors
What to do - to - my bot again start working
?tag intents
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)
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
?tag message-content
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
But I have already builded a code
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
Did you turn on the message_content intent?
Yeah
Is the bot turning on?
Are there any errors?
Is the message content intent turned on in the dev portal?
By the way, could you send you main.py file
Yeah
and what to do with it? i cannot turn it on
Oh
Yeah you're gonna need that if you want to use prefixed commands
it wasn t like that?
I don't think Discord gives it just for prefixed commands though
Yeah discord changed some stuff
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?
Yeah
or migrate to slash commands
But for now, do this:
discord.http.API_VERSION = 9
that should allow you to use prefixed commands
Okay, tell me how i do not know what that even is
ohh, never seen that that s cool
But this should be the fix
Add it above where you create your bot object
Okay, where to put it? replace with message intent = true...?
Yeah
You're welcome
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
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
Nice
Yeah I will somehow do it you know what I mean
😎
So now everything should work like in docs? right nothing else needed to funcional buttons commands
Yeah all you need is pycord
okay
@north salmon Can you help me again with this one pelase
I do not know where is problem
You can't set button.disabled=True within the button constructor, you have to use disabled=True instead
oh, tahnk you so much :D
You're welcome
@north salmon sorry for pinging but I need help, I cannot find anywhere. How to make pages through buttons for help command
You could use ext.pages
yeah? i cannot find it
And taht search bar? how to do it to select category
Also a link to the docs which goes into more depth about the select menu part: https://docs.pycord.dev/en/stable/ext/pages/index.html
That's mentioned in the docs
okay thanks i am gonna find it
You're welcome
@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
So the way the paginator works, is that it comes with builtin buttons that you can use
So what to do with that code
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
yeah pretty much
Yeah, that'll create two different sets of pages that can be switched between using a select menu
Have you done:
from discord.ext import pages
no
Yeah make sure you do that
Yeah that works as well
still do not work
Send the error
Oh, you need to do
PageGroup(pages=[...], label="some label")
Yeah, just add pages= before the lists
?
before [discord.Embed(...), ...] and ["some more", ...]
no, put pages= to the left of the [
What error?
Send the part above that exception
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)
Yeah make sure that you indent it correctly
paginator should have the same indentation as your await paginator.send....
So what to do
Backspace 2 indentation 💀
I still do not udnerstand what to do explain more ☠️
☠️
It's basic python 💀
Just press backspace until that line is correctly above your await paginator.send
Both lines should have same amount of tabs\spaces
So what to do bro?
You removed all indentation for both the lines 🥖
Press 1 tab
At the start
Of both of those lines
Still eror
Oh bruh
You didn't make a constructor
I don't really work much with paginators so I can't help you much
Can you show your code in button
you have no self so self.get_pages() isn't going to do anything
Im not sure if its a good idea to call the command "button"
I am testing it man
I do not think so
it is though
?tag idw
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.
again these are basic python errors
you're trying to use a variable page_buttons that you never defined
don't use a variable you haven't defined, or define it
sounds like you're also new to python
?tag lp
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)