38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import random
|
|
|
|
import disnake
|
|
from disnake.ext import commands
|
|
from disnake.ext.commands import slash_command, Param
|
|
|
|
from logger import Logger
|
|
|
|
logger = Logger('Melody\'s Servant Modules')
|
|
|
|
|
|
class SlashCommands(commands.Cog):
|
|
GUILD = 1321397320620965909
|
|
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
logger.info('/8ball.py loaded.')
|
|
|
|
@slash_command(name='8ball', description='Ask a question.', guild_ids=[GUILD])
|
|
async def eightball(self,
|
|
ctx: disnake.AppCommandInter,
|
|
question: str = Param(name='question', description='Question.')):
|
|
answers = ['Outlook good.', 'It is certain.', 'You may rely on it.', 'Ask again later.',
|
|
'Concentrate and ask again.', 'Reply hazy, try again.', 'My reply is no.', 'My sources say no.']
|
|
|
|
if question.endswith('?'):
|
|
if len(question) >= 1:
|
|
await ctx.response.send_message(f'Q: {question}\nA: {random.choice(answers)}')
|
|
else:
|
|
await ctx.response.send_message(':x: Please ask me a question first.', ephemeral=True)
|
|
else:
|
|
await ctx.response.send_message(':x: Your question must end with a question mark.', ephemeral=True)
|
|
|
|
|
|
def setup(bot):
|
|
bot.add_cog(SlashCommands(bot))
|