Compare commits

...

4 commits

Author SHA1 Message Date
a048cfda07 Add requirements.txt 2024-12-25 20:20:58 +09:00
0978163b1d Update bot.py 2024-12-25 20:20:28 +09:00
601db8da65 Add commands.py - added /8ball 2024-12-25 20:20:13 +09:00
9a848c55ad Update bot.py 2024-12-25 20:03:09 +09:00
3 changed files with 41 additions and 0 deletions

3
bot.py
View file

@ -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
View 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

Binary file not shown.