mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Adding new classes to upgrade the music code organization
This commit is contained in:
38
vulkanbot/general/Control.py
Normal file
38
vulkanbot/general/Control.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import discord
|
||||
from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument
|
||||
from discord.ext import commands
|
||||
from config import config
|
||||
|
||||
|
||||
class Control(commands.Cog):
|
||||
"""Control the flow of the Bot"""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.__bot = bot
|
||||
|
||||
@property
|
||||
def bot(self):
|
||||
return self.__bot
|
||||
|
||||
@bot.setter
|
||||
def bot(self, newBot):
|
||||
self.__bot = newBot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
print(config.STARTUP_MESSAGE)
|
||||
await self.__bot.change_presence(status=discord.Status.online, activity=discord.Game(name=f"Vulkan | type {config.BOT_PREFIX}help"))
|
||||
print(config.STARTUP_COMPLETE_MESSAGE)
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_command_error(self, ctx, error):
|
||||
if isinstance(error, MissingRequiredArgument):
|
||||
await ctx.channel.send(f'Falta argumentos. Digite {self.__bot.prefix}help para ver os comandos')
|
||||
elif isinstance(error, CommandNotFound):
|
||||
await ctx.channel.send(f'O comando não existe')
|
||||
else:
|
||||
raise error
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Control(bot))
|
||||
28
vulkanbot/general/Filter.py
Normal file
28
vulkanbot/general/Filter.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
class Filter(commands.Cog):
|
||||
"""Deal with filtering of discord messages"""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.__bot = bot
|
||||
|
||||
@property
|
||||
def bot(self):
|
||||
return self.__bot
|
||||
|
||||
@bot.setter
|
||||
def bot(self, newBot):
|
||||
self.__bot = newBot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
if message.author == self.__bot.user:
|
||||
return
|
||||
|
||||
if 'elx' in message.content:
|
||||
await message.channel.send(f'Coé {message.author.name}, tu é gay memo hein bicho')
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Filter(bot))
|
||||
0
vulkanbot/general/__init__.py
Normal file
0
vulkanbot/general/__init__.py
Normal file
Reference in New Issue
Block a user