Compare commits
4 commits
81b740ea95
...
a048cfda07
Author | SHA1 | Date | |
---|---|---|---|
a048cfda07 | |||
0978163b1d | |||
601db8da65 | |||
9a848c55ad |
3 changed files with 41 additions and 0 deletions
3
bot.py
3
bot.py
|
@ -29,9 +29,12 @@ if __name__ == '__main__':
|
|||
async def on_ready():
|
||||
try:
|
||||
bot.load_extension('cogs.events')
|
||||
bot.load_extension('cogs.commands')
|
||||
except ExtensionAlreadyLoaded as eal:
|
||||
pass
|
||||
|
||||
logger.info('We\'re ready to go!')
|
||||
|
||||
|
||||
@bot.event
|
||||
async def on_message(message: disnake.Message):
|
||||
|
|
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))
|
BIN
requirements.txt
Normal file
BIN
requirements.txt
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue