Converting poll to a slash command
This commit is contained in:
parent
ca3f22daea
commit
0986ce64c5
@ -20,6 +20,12 @@ for cogfile in cogfiles:
|
||||
bot.load_extension(cogfile)
|
||||
|
||||
|
||||
@bot.slash_command(guild_ids=None, name="hello", description="Prints hello")
|
||||
async def hello(ctx, name: str = None):
|
||||
name = name or ctx.author.name
|
||||
await ctx.respond(f"Hello {name}!")
|
||||
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
print(f"{bot.user.name} has connected to Discord!")
|
||||
|
@ -1,13 +1,24 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.commands import Option
|
||||
|
||||
|
||||
class QuickPoll(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
async def poll(self, ctx, question, *options: str):
|
||||
@commands.slash_command(
|
||||
guild_ids=None,
|
||||
pass_context=True,
|
||||
description="Create a poll with up to 10 options. Separate your options with a space",
|
||||
)
|
||||
async def poll(
|
||||
self,
|
||||
ctx,
|
||||
question,
|
||||
options: Option(str, "poll options (separated by spaces)", required=True),
|
||||
):
|
||||
options = options.split()
|
||||
if len(options) <= 1:
|
||||
await ctx.send("You need more than one option to make a poll!")
|
||||
return
|
||||
@ -28,7 +39,7 @@ class QuickPoll(commands.Cog):
|
||||
for reaction in reactions[: len(options)]:
|
||||
await react_message.add_reaction(reaction)
|
||||
embed.set_footer(text="Poll ID: {}".format(react_message.id))
|
||||
await react_message.edit_message(embed=embed)
|
||||
await react_message.edit(embed=embed)
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
async def tally(self, ctx, id=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user