-
Notifications
You must be signed in to change notification settings - Fork 43
Conversation
Hey, I went ahead and added some small touches to your file! @rachit1601 import discord
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
bot = commands.Bot("!")
@bot.event
async def on_ready():
#DiscordComponents(bot)
#^ uncomment this to init discord-components when the bot is 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.red, label="EMOJI", emoji="😂", disabled=True),
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):
DiscordComponents(bot)
#^ Inits discordcomponents when the event is fired..
"""Possible interaction types:
Pong
ChannelMessageWithSource
DeferredChannelMessageWithSource
DeferredUpdateMessage
UpdateMessage
"""
await m.respond(
type=InteractionType.ChannelMessageWithSource,
content=f'{m.component.label} pressed'
)
bot.run('TOKEN')
|
Could you put |
import discord
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
bot = commands.Bot("!")
@bot.event
async def on_ready():
#DiscordComponents(bot)
#^ uncomment this to init discord-components when the bot is 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.red, label="EMOJI", emoji="😂", disabled=True),
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):
DiscordComponents(bot)
#^ Inits discordcomponents when the event is fired.
"""Possible interaction types:
Pong
ChannelMessageWithSource
DeferredChannelMessageWithSource
DeferredUpdateMessage
UpdateMessage
"""
await m.respond(
type=InteractionType.ChannelMessageWithSource,
content=f'{m.component.label} pressed'
)
bot.run('TOKEN')
|
Without comment |
import discord
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
bot = commands.Bot("!")
@bot.event
async def on_ready():
DiscordComponents(bot)
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.red, label="EMOJI", emoji="😂", disabled=True),
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):
DiscordComponents(bot)
#^ Inits discordcomponents when the event is fired.
"""Possible interaction types:
Pong
ChannelMessageWithSource
DeferredChannelMessageWithSource
DeferredUpdateMessage
UpdateMessage
"""
await m.respond(
type=InteractionType.ChannelMessageWithSource,
content=f'{m.component.label} pressed'
)
bot.run('TOKEN')
|
you don't have to put |
Well this isnt my pull, i was just editing some things but ill fix that in my pull request which you can go see here Here is the modified simple.py: import discord
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
bot = commands.Bot("!")
@bot.event
async def on_ready():
DiscordComponents(bot)
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.red, label="EMOJI", emoji="😂", disabled=True),
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):
"""Possible interaction types:
Pong
ChannelMessageWithSource
DeferredChannelMessageWithSource
DeferredUpdateMessage
UpdateMessage
"""
await m.respond(
type=InteractionType.ChannelMessageWithSource,
content=f'{m.component.label} pressed'
)
bot.run('TOKEN') |
PR TYPE
Added example file. I'm planning to add more examples like calculator, etc
Checks