This repository has been archived by the owner on Dec 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c615c45
commit c81054e
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import discord | ||
from discord.ext import commands | ||
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType | ||
|
||
bot = commands.Bot("!") | ||
|
||
ddb = DiscordComponents(bot) | ||
|
||
@bot.event | ||
async def on_ready(): | ||
print(f'Logged in as {bot.user}!') | ||
|
||
|
||
@bot.command() | ||
async def button(ctx): | ||
m= await ctx.send("Here is an example of a button", | ||
components=[[ | ||
Button(style=ButtonStyle.green, label="GREEN"),Button(style=ButtonStyle.red, label="RED"), | ||
Button(style=ButtonStyle.grey, label="GREY")], | ||
Button(style=ButtonStyle.blue, label="BLUE"), | ||
Button(style=ButtonStyle.URL, label="URL", url="https://www.example.com"), | ||
], | ||
) | ||
|
||
@bot.event | ||
async def on_button_click(m): | ||
await m.respond( | ||
type=InteractionType.ChannelMessageWithSource, | ||
content=f'{m.component.label} pressed' | ||
) | ||
|
||
bot.run('TOKEN') |