Skip to content

Commit 4e9b7c3

Browse files
authored
2024-06-05
woah
1 parent 7484026 commit 4e9b7c3

12 files changed

+132
-3
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ You are 100% allowed to have a self-hosted version of Yume under the following c
1515
Soon™ (I'm still planning it)
1616

1717
## Changelog
18-
- Changed the organization of folders and files.
19-
- All GitHub related commands are now meshed into one single command.
20-
- Embeds and Buttons now have their own separated files.
18+
- Yume finally have logs!!.
19+
- A few old commands are working again.
20+
- The Media folder with images for specific commands is back for now.
2121

2222
## Have a suggestion?
2323
If you have any suggestions or ideas for new commands, you can tell them to me and I will analyze then carefully. Thanks for the attention!

cogs/__pycache__/fun.cpython-312.pyc

3.75 KB
Binary file not shown.
2.93 KB
Binary file not shown.

cogs/fun.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Bibliotecas utilizadas neste arquivo
2+
from utils.embeds import GenericEmbed
3+
from discord.ext import commands
4+
from discord import app_commands
5+
import discord
6+
import random
7+
8+
9+
# Realiza a definição da classe cog
10+
class Fun(commands.Cog):
11+
def __init__(self, yume: commands.AutoShardedBot):
12+
self.yume = yume
13+
14+
# Avisa quando a classe cog iniciar
15+
@commands.Cog.listener()
16+
async def on_ready(self):
17+
print('Fun is Ready!')
18+
19+
# Fortune Cookie
20+
@app_commands.command(name='fortune', description='Let me get a fortune cookie for you!')
21+
async def fortune(self, interaction: discord.Interaction):
22+
23+
cookie = discord.File('./media/cookie.gif', filename='cookie.gif')
24+
lines = open('./texts/fortunes.txt').read().splitlines()
25+
fortune = random.choice(lines)
26+
27+
embed = GenericEmbed.embed
28+
embed.set_author(name=fortune, icon_url=interaction.user.avatar.url)
29+
embed.set_image(url="attachment://cookie.gif")
30+
embed.set_footer(text="And that's what the cookie said to Yume.")
31+
32+
await interaction.response.send_message(embed=embed, file=cookie)
33+
34+
# Reverse Text
35+
@app_commands.command(name='reverse', description='?naem uoy od tahW')
36+
async def reverse(self, interaction: discord.Interaction, text: str):
37+
38+
await interaction.response.send_message(text[::-1])
39+
40+
# Roll
41+
@app_commands.command(name='roll', description='Rolls a random value to you...')
42+
async def roll(self, interaction: discord.Interaction):
43+
44+
points = random.randint(0, 1000)
45+
46+
if points == 727:
47+
await interaction.response.send_message(f'**{points}!! WYSI!! WYFSI!!!!!**')
48+
49+
await interaction.response.send_message(f"You've got **{points}** points! what do you think?? wanna try again?")
50+
51+
52+
# Realiza o registro da classe nos cogs
53+
async def setup(yume: commands.AutoShardedBot) -> None:
54+
await yume.add_cog(Fun(yume))

cogs/utility.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Bibliotecas utilizadas neste arquivo
2+
from discord.ext import commands
3+
from discord import app_commands
4+
import discord
5+
6+
7+
# Realiza a definição da classe cog
8+
class Utility(commands.Cog):
9+
def __init__(self, yume: commands.AutoShardedBot):
10+
self.yume = yume
11+
12+
# Avisa quando a classe cog iniciar
13+
@commands.Cog.listener()
14+
async def on_ready(self):
15+
print('Utility is Ready!')
16+
17+
# Ping
18+
@app_commands.command(name='ping', description='You can use this to verify my ping')
19+
async def ping(self, interaction: discord.Interaction):
20+
21+
ping = round(self.yume.latency * 1000)
22+
await interaction.response.send_message(f'{ping}ms')
23+
24+
# Avatar
25+
@app_commands.command(name='avatar', description="Sends a embed with the user's avatar")
26+
async def avatar(self, interaction: discord.Interaction, user: discord.Member = None):
27+
28+
avatar = discord.Embed(color=discord.Color.random())
29+
avatar.set_author(name=f"This is your avatar! Look how cute it is!")
30+
avatar.set_image(url=interaction.user.avatar)
31+
32+
if user is not None:
33+
avatar.set_image(url=user.avatar)
34+
avatar.set_author(name=f"This is {user.name}'s avatar! Cute isn't it?")
35+
36+
await interaction.response.send_message(embed=avatar)
37+
38+
39+
# Realiza o registro da classe nos cogs
40+
async def setup(yume: commands.AutoShardedBot) -> None:
41+
await yume.add_cog(Utility(yume))

media/cookie.gif

752 KB
Loading
0 Bytes
Binary file not shown.
305 Bytes
Binary file not shown.
1.19 KB
Binary file not shown.

utils/embeds.py

+6
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ class GitEmbed:
1010
git_embed.set_image(url="https://cdn.discordapp.com/avatars/944414497966264321/20feb089532248f4665cea9b10b61d81."
1111
"png?size=4096")
1212
git_embed.set_footer(text="Yes, it's AI generated, please don't mind it.")
13+
14+
15+
class GenericEmbed:
16+
17+
embed = discord.Embed(color=discord.Color.random())
18+

utils/logger.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Bibliotecas utilizadas neste arquivo
2+
import logging.handlers
3+
import logging
4+
import discord
5+
6+
7+
class YLogger:
8+
9+
yume_logger = logging.getLogger('discord')
10+
yume_logger.setLevel(logging.INFO)
11+
logging.getLogger('discord.http').setLevel(logging.INFO)
12+
13+
handler = logging.handlers.RotatingFileHandler(
14+
filename='log-yume.log',
15+
encoding='utf-8',
16+
maxBytes=32 * 1024 * 1024,
17+
backupCount=5
18+
)
19+
20+
date_format = '%Y-%m-%d %H:%M:%S'
21+
formatter = logging.Formatter('%(asctime)s: - %(name)s - %(levelname)s - %(message)s')
22+
23+
handler.setFormatter(formatter)
24+
yume_logger.addHandler(handler)
25+
26+
log_handler = None

yume.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Bibliotecas utilizadas para o arquivo principal funcionar corretamente
22
from utils.envkeys import yume_key, app_id
33
from discord.ext import commands, tasks
4+
from utils.logger import YLogger
45
from dotenv import load_dotenv
56
from itertools import cycle
67
import discord
@@ -66,6 +67,7 @@ async def synctree(ctx):
6667
async def main():
6768
await on_ready()
6869
await load_cog()
70+
YLogger()
6971

7072
print("Yume is Online!!")
7173
await yume.start(yume_key())

0 commit comments

Comments
 (0)