Reputation: 1052
I would like to know how to make a button using discord.py.
This would be an example of what I want:
My Code:
import discord
from discord.ext import commands
client=commands.Bot(command_prefix=".")
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
await interaction.response.edit_message(content=f"This is an edited button response!")
@client.command()
async def button(ctx):
await ctx.send("This message has buttons!",view=Buttons())
token=""
client.run(token)
Error
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord' has no attribute 'ui'
Upvotes: 2
Views: 1238
Reputation: 1052
You need to update to version 2.0 instead of 1.7.3 using pip install -U git+https://github.com/Rapptz/discord.py
Upvotes: 2