Sending initial files of Vulkan BOT

This commit is contained in:
Rafael Vargas 2021-12-22 20:52:26 -04:00
commit 86255355c4
8 changed files with 211 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
__pycache__
cogs/music*
.env

34
cogs/control.py Normal file
View File

@ -0,0 +1,34 @@
from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument
from discord.ext import commands
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(f'Bot {self.__bot.user.name} inicializado')
@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
cogs/filter.py Normal file
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))

48
cogs/phrases.py Normal file
View File

@ -0,0 +1,48 @@
import requests
import json
import discord
from discord.ext import commands
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):
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.author.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
def setup(bot):
bot.add_cog(Phrases(bot))

20
cogs/talk.py Normal file
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))

51
cogs/warframe.py Normal file
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))

23
main.py Normal file
View File

@ -0,0 +1,23 @@
import os
import discord
from dotenv import dotenv_values
from discord.ext import commands
TOKEN_BOT = dotenv_values('.env')['TOKEN_BOT']
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="!",
case_insensitive=True, intents=intents)
client.remove_command('help')
def load_cogs(bot):
for filename in os.listdir('cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
load_cogs(client)
client.run(TOKEN_BOT)

4
requirements.txt Normal file
View File

@ -0,0 +1,4 @@
discord.py
discord.py[voice]
youtube_dl
PyNaCl