Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
Create simple.py
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotrachit committed May 28, 2021
1 parent c615c45 commit c81054e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Examples/simple.py
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')

0 comments on commit c81054e

Please sign in to comment.