Add shuffle command

This commit is contained in:
Terry Hearst 2023-02-15 22:41:25 -05:00
parent 84bda4043e
commit 86473c1028

11
bot.py
View file

@ -24,6 +24,8 @@ class Bot(commands.Bot):
commands = self.db_cur.execute("SELECT count(*) FROM custom_commands").fetchone()
print(f"{commands[0]} custom commands available")
self.last_message = "cubes are just balls with corners lmao"
# Adds a custom command from a string
async def add_custom_command(self, ctx, command_str, author):
args = command_str.split(" ", 1)
@ -86,6 +88,9 @@ class Bot(commands.Bot):
await self.handle_commands(message)
if len(message.content.split(" ")) > 1:
self.last_message = message.content
@commands.command()
async def hello(self, ctx: commands.Context):
# Basic hello world command, executed with "!hello". Reply hello to whoever made the command
@ -161,6 +166,12 @@ class Bot(commands.Bot):
r = requests.get("https://taskinoz.com/gdq/api/")
await ctx.send(r.text)
@commands.command()
async def shuffle(self, ctx: commands.Context):
shuffled_message_list = self.last_message.split(" ")
random.shuffle(shuffled_message_list)
await ctx.send(" ".join(shuffled_message_list))
def main():
load_dotenv()