Changing file organization

This commit is contained in:
Rafael Vargas
2021-12-24 13:11:43 -04:00
parent 9eda65886e
commit d67997140f
9 changed files with 81 additions and 36 deletions

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

View File

@@ -0,0 +1,63 @@
import requests
import json
import discord
from discord.ext import commands
from random import random as rand
class Phrases(commands.Cog):
"""Deal with the generation of motivational phrases"""
def __init__(self, bot):
self.__bot = bot
@property
def bot(self):
return self.__bot
@bot.setter
def bot(self, newBot):
self.__bot = newBot
@commands.command(name='frase', help='Envia uma frase legal no seu PV')
async def send_phrase(self, ctx):
# There is a chance that the phrase will be send for the dev
sended = await self.calculate_rgn(ctx)
if sended:
return
while True:
try:
response = requests.get(
'http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=json&lang=en')
data = json.loads(response.content)
phrase = data['quoteText']
author = data['quoteAuthor']
text = f'{phrase} \nBy: {author}'
await ctx.send(text)
break
except json.decoder.JSONDecodeError:
continue
except discord.errors.Forbidden as e:
print(e)
await ctx.channel.send('Não posso te enviar a frase, habilite para receber mensagens de qualquer pessoa no servidor (Opções > Privacidade)')
break
except Exception as e:
print(e)
await ctx.channel.send('Houve um erro inesperado :/')
break
async def calculate_rgn(self, ctx):
x = rand()
print(x)
if x < 0.15:
await ctx.send('Se leu seu cu é meu\nBy: Minha Pica')
return True
else:
return False
def setup(bot):
bot.add_cog(Phrases(bot))

View File

@@ -0,0 +1,20 @@
from discord.ext import commands
class Talks(commands.Cog):
"""Deal with talks to users"""
def __init__(self, bot):
self.__bot = bot
@property
def bot(self):
return self.__bot
@bot.setter
def bot(self, newBot):
self.__bot = newBot
def setup(bot):
bot.add_cog(Talks(bot))

View File

@@ -0,0 +1,51 @@
import requests
import json
import discord
from dotenv import dotenv_values
from discord.ext import commands
CETUS_API = dotenv_values('.env')['CETUS_API']
class Warframe(commands.Cog):
"""Deal with the generation of warframe data"""
def __init__(self, bot):
self.__bot = bot
@property
def bot(self):
return self.__bot
@bot.setter
def bot(self, newBot):
self.__bot = newBot
@commands.command(name='cetus', help='Informa o tempo atual de Cetus - Warframe')
async def get_cetus(self, ctx):
try:
response = requests.get(CETUS_API)
data = json.loads(response.content)
short = data['shortString']
responseText = f'{short}'
embed = discord.Embed(
title='Warframe Cetus Timing',
description=responseText,
colour=0xFF0000
)
await ctx.send(embed=embed)
except Exception as e:
print(e)
responseText = f'Houve um erro inesperado :/'
embed = discord.Embed(
title='Warframe Cetus Timing',
description=responseText,
colour=0xFF0000
)
await ctx.send(embed=embed)
def setup(bot):
bot.add_cog(Warframe(bot))