diff --git a/app/bot.py b/app/bot.py index 9bc2c1cc..ea1324e8 100755 --- a/app/bot.py +++ b/app/bot.py @@ -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!") diff --git a/app/cogs/poll.py b/app/cogs/poll.py index 4313f524..cd264ab6 100644 --- a/app/cogs/poll.py +++ b/app/cogs/poll.py @@ -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):