Adding commands, calling works

This commit is contained in:
Stijn De Clercq 2021-05-17 20:10:07 +02:00
parent 3cfc87b7e1
commit 4bcd00826e
5 changed files with 96 additions and 17 deletions

View file

@ -76,8 +76,9 @@ class Events(commands.Cog):
await message.channel.send(eER)
# Check for custom commands
custom = custom_commands.is_custom_command(message.content)
if custom:
custom = custom_commands.is_custom_command(message)
if custom.id is not None:
await message.channel.send(custom.response)
# Earn XP & Message count

View file

@ -8,6 +8,8 @@ from functions.database import memes, githubs, twitch, dadjoke
import json
import os
from functions.database.custom_commands import is_name_free, add_command, add_alias
class ModCommands(commands.Cog):
@ -106,13 +108,35 @@ class ModCommands(commands.Cog):
return await ctx.send("Ik kan geen bericht zien met dit Id.")
await message.add_reaction(emoji)
# Adds stuff into their databases
@commands.group(name="Add", usage="[Category] [Args]", case_insensitive=True, invoke_without_command=False)
@commands.check(checks.isMe)
@help.Category(category=Category.Mod)
async def add(self, ctx):
"""
Commands group that adds database entries
"""
pass
@add.command(name="Custom", usage="[Name] [Response]")
async def custom(self, ctx, name, *, resp):
err_msg = add_command(name, resp)
# Something went wrong
if err_msg:
return await ctx.send(err_msg)
else:
await ctx.message.add_reaction("")
@add.command(name="Alias", usage="[Name] [Alias]")
async def add_alias(self, ctx, command, alias):
err_msg = add_alias(command, alias)
# Something went wrong
if err_msg:
return await ctx.send(err_msg)
else:
await ctx.message.add_reaction("")
@add.command(name="Dadjoke", aliases=["Dj", "Dad"], usage="[Joke]")
async def dadjoke(self, ctx, *, joke):
dadjoke.addJoke(joke)