Add commands.py - added /8ball
This commit is contained in:
parent
9a848c55ad
commit
601db8da65
1 changed files with 38 additions and 0 deletions
38
cogs/commands.py
Normal file
38
cogs/commands.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# -*- 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('Liza 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))
|
Loading…
Add table
Reference in a new issue