Skip to content

Commit a69b208

Browse files
Merge pull request #69 from LewisProjects/development
2.1 XP boost reintroduction and some smaller fixes and more logs
2 parents 4940db7 + a769083 commit a69b208

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2075
-530
lines changed

CONTRIBUTING.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The following is a set of guidelines for contributing to Ogiroid, which is a par
1515
> This project and everyone participating in it is governed by the Ogiroid code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the developers.
1616
1717
## [What do I require before getting started?](#prerequisites)
18-
We expect you to be experienced with [Python](https://www.python.org/) and [Disnake](https://disnake.dev/) (a fork of [Discord.py](https://github.com/Rapptz/discord.py)). Having experience with Discord.py should also get you sailing, disnake and discord.py are almost the same.
18+
We expect you to be experienced with [Python](https://www.python.org/) and [Disnake](https://disnake.dev/) (a fork of [Discord.py](https://github.com/Rapptz/discord.py)). Having experience with Discord.py should also get you sailing, disnake and discord.py are almost the same, or you could also take a look at the very helpful disnake documentation.
1919

2020
## [What can I do to contribute?](#contribution)
2121
**1. Reporting any bugs 🐞:**
@@ -48,3 +48,37 @@ Alternatively, you can headover to our [Discord Server](https://discord.com/5uw4
4848
With that being said, you have officially reported a bug! Thank you so much 🤩!
4949

5050
<!--Contributing.md: writeup #1-->
51+
52+
### Contributing Code
53+
54+
Fork the repository and then clone it using: (make sure to insert your username)
55+
56+
```git clone https://github.com/YOURGITHUBUSERNAME/Ogiroid.git```
57+
58+
After this get into the folder you cloned the repository to.
59+
We always work on the development branch so make sure you are on the dev branch.
60+
61+
```git checkout development```
62+
63+
Now you need to create a Discord Bot if you don't already have one. Please look up a guide for how to do this.
64+
Invite the bot to a test server you own or create a test server.
65+
66+
Now copy secrets.env.template and rename the copy to secrets.env
67+
Insert your bots token in the correct field.
68+
Set development to true. The rest can be ignored for now.
69+
70+
To install the requirements:
71+
72+
```pip install -r requirements.txt```
73+
74+
And finally to run the bot:
75+
76+
```python main.py```
77+
78+
utils/CONSTANTS.py stores the ids for various channels, for the main server and for the official development server, to wich you will gain access after a significant contribution.
79+
80+
Use ```black . --safe``` for formatting (need to install black with pip)
81+
82+
If you need any help contact us on discord or open an issue.
83+
84+
After you have finished writing the code open a PR with the base branch being development.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Main Contributors/Developers:
1717
</ul>
1818
The bot is currently on release: <b>2.0</b><br>
1919
License: MIT<br>
20+
21+
<h3>Contributing</h3>
2022
Wish to Contribute to this bot? Checkout: <a href="https://github.com/LewisProjects/Ogiroid/blob/development/CONTRIBUTING.md">contribution guidelines</a>
2123
<hr>
2224

cogs/AI.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import base64
2-
from io import BytesIO
32
import time
3+
from io import BytesIO
4+
45
import disnake
56
from disnake.ext import commands
7+
68
from utils.bot import OGIROID
79

810

@@ -13,11 +15,19 @@ def __init__(self, bot: OGIROID):
1315
@commands.slash_command(description="Generates ai art")
1416
async def ai_art(self, inter: disnake.ApplicationCommandInteraction, text):
1517
ETA = int(time.time() + 60)
16-
await inter.send(f"Go grab a coffee this may take a while... ETA: <t:{ETA}:R>", ephemeral=True)
17-
response = await self.bot.session.post("https://backend.craiyon.com/generate", json={"prompt": text})
18+
await inter.send(
19+
f"Go grab a coffee this may take a while... ETA: <t:{ETA}:R>",
20+
ephemeral=True,
21+
)
22+
response = await self.bot.session.post(
23+
"https://backend.craiyon.com/generate", json={"prompt": text}
24+
)
1825
r = await response.json()
1926
raw_images = r["images"]
20-
images = [disnake.File(BytesIO(base64.decodebytes(i.encode("utf-8"))), "image.png") for i in raw_images]
27+
images = [
28+
disnake.File(BytesIO(base64.decodebytes(i.encode("utf-8"))), "image.png")
29+
for i in raw_images
30+
]
2131

2232
await inter.edit_original_response(files=images, content="Here you go!")
2333

cogs/Animals.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ async def cat(self, inter):
2626
color=0xFFFFFF,
2727
)
2828
embed.set_image(url=data["image"])
29-
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
29+
embed.set_footer(
30+
text=f"Command issued by: {inter.author.name}",
31+
icon_url=inter.author.display_avatar,
32+
)
3033
await inter.response.send_message(f"**Fun Fact: **" + data["fact"], embed=embed)
3134

3235
@animal.sub_command(name="dog", description="Get a random dog picture")
@@ -40,7 +43,10 @@ async def dog(self, inter):
4043
color=0xFFFFFF,
4144
)
4245
embed.set_image(url=data["image"])
43-
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
46+
embed.set_footer(
47+
text=f"Command issued by: {inter.author.name}",
48+
icon_url=inter.author.display_avatar,
49+
)
4450
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
4551

4652
@animal.sub_command(name="bird", description="Get a random bird picture")
@@ -54,7 +60,10 @@ async def bird(self, inter):
5460
color=0xFFFFFF,
5561
)
5662
embed.set_image(url=data["image"])
57-
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
63+
embed.set_footer(
64+
text=f"Command issued by: {inter.author.name}",
65+
icon_url=inter.author.display_avatar,
66+
)
5867
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
5968

6069
@animal.sub_command(name="fox", description="Get a random fox picture")
@@ -68,7 +77,10 @@ async def fox(self, inter):
6877
color=0xFFFFFF,
6978
)
7079
embed.set_image(url=data["image"])
71-
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
80+
embed.set_footer(
81+
text=f"Command issued by: {inter.author.name}",
82+
icon_url=inter.author.display_avatar,
83+
)
7284
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
7385

7486
@animal.sub_command(name="panda", description="Get a random panda picture")
@@ -82,7 +94,10 @@ async def panda(self, inter):
8294
color=0xFFFFFF,
8395
)
8496
embed.set_image(url=data["image"])
85-
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
97+
embed.set_footer(
98+
text=f"Command issued by: {inter.author.name}",
99+
icon_url=inter.author.display_avatar,
100+
)
86101
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
87102

88103
@animal.sub_command(name="koala", description="Get a random cat picture")
@@ -96,7 +111,10 @@ async def koala(self, inter):
96111
color=0xFFFFFF,
97112
)
98113
embed.set_image(url=data["image"])
99-
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
114+
embed.set_footer(
115+
text=f"Command issued by: {inter.author.name}",
116+
icon_url=inter.author.display_avatar,
117+
)
100118
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
101119

102120

cogs/Birthdays.py

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import datetime
2+
import datetime as dt
3+
import random
24

35
import disnake
4-
import datetime as dt
56
from disnake.ext import commands, tasks
6-
import random
77

8+
from utils.CONSTANTS import months, congrats_messages
89
from utils.DBhandlers import BirthdayHandler
10+
from utils.bot import OGIROID
911
from utils.exceptions import UserAlreadyExists, UserNotFound
1012
from utils.shortcuts import QuickEmb, sucEmb, errorEmb
11-
from utils.CONSTANTS import months, congrats_messages
12-
from utils.bot import OGIROID
1313

1414

1515
class Birthday(commands.Cog):
@@ -30,11 +30,18 @@ def cog_unload(self):
3030
async def birthday(self, inter: disnake.ApplicationCommandInteraction):
3131
pass
3232

33-
@birthday.sub_command(name="set", description="Set your birthday. Cant be removed without Staff.")
33+
@birthday.sub_command(
34+
name="set", description="Set your birthday. Cant be removed without Staff."
35+
)
3436
async def set(
3537
self,
3638
inter,
37-
day: int = commands.Param(name="day", ge=1, le=31, description="The day of your birthday. Select carefully."),
39+
day: int = commands.Param(
40+
name="day",
41+
ge=1,
42+
le=31,
43+
description="The day of your birthday. Select carefully.",
44+
),
3845
month: str = commands.Param(
3946
name="month",
4047
description="The month of your birthday. Select carefully.",
@@ -55,17 +62,23 @@ async def set(
5562
await sucEmb(inter, f"Your birthday has been set to {birth_date}")
5663

5764
@commands.has_permissions(manage_roles=True)
58-
@birthday.sub_command(name="edit", description="Edit a users birthday. Can only be done by Staff.")
65+
@birthday.sub_command(
66+
name="edit", description="Edit a users birthday. Can only be done by Staff."
67+
)
5968
async def edit(
6069
self,
6170
inter,
62-
day: int = commands.Param(name="day", ge=1, le=31, description="The day of the birthday."),
71+
day: int = commands.Param(
72+
name="day", ge=1, le=31, description="The day of the birthday."
73+
),
6374
month: str = commands.Param(
6475
name="month",
6576
description="The month of the birthday.",
6677
choices=months,
6778
),
68-
user: disnake.User = commands.Param(name="user", description="User to edit the birthday of."),
79+
user: disnake.User = commands.Param(
80+
name="user", description="User to edit the birthday of."
81+
),
6982
):
7083
try:
7184
await self.birthday.update_user(user.id, f"{day}/{month}")
@@ -74,11 +87,15 @@ async def edit(
7487
return await errorEmb(inter, "The User doesn't have a birthday set")
7588

7689
@commands.has_permissions(manage_roles=True)
77-
@birthday.sub_command(name="remove", description="Remove a birthday. Can only be done by Staff.")
90+
@birthday.sub_command(
91+
name="remove", description="Remove a birthday. Can only be done by Staff."
92+
)
7893
async def remove(
7994
self,
8095
inter: disnake.ApplicationCommandInteraction,
81-
user: disnake.User = commands.Param(name="user", description="Removes the birthday of this user"),
96+
user: disnake.User = commands.Param(
97+
name="user", description="Removes the birthday of this user"
98+
),
8299
):
83100
try:
84101
await self.birthday.delete_user(user.id)
@@ -88,7 +105,9 @@ async def remove(
88105
await sucEmb(inter, "The birthday has been removed")
89106

90107
@birthday.sub_command(name="get", description="Get the birthday of a user")
91-
async def get(self, inter, user: disnake.User = commands.Param(name="user", default=None)):
108+
async def get(
109+
self, inter, user: disnake.User = commands.Param(name="user", default=None)
110+
):
92111
if user is None:
93112
user = inter.author
94113
else:
@@ -98,9 +117,13 @@ async def get(self, inter, user: disnake.User = commands.Param(name="user", defa
98117
if birthday is None:
99118
return await errorEmb(inter, "This user doesn't have a birthday set")
100119

101-
next_birthday = datetime.datetime.strptime(birthday.birthday + f"/{dt.datetime.now().year}", "%d/%m/%Y")
120+
next_birthday = datetime.datetime.strptime(
121+
birthday.birthday + f"/{dt.datetime.now().year}", "%d/%m/%Y"
122+
)
102123
if next_birthday < datetime.datetime.now():
103-
next_birthday = datetime.datetime.strptime(birthday.birthday + f"/{dt.datetime.now().year + 1}", "%d/%m/%Y")
124+
next_birthday = datetime.datetime.strptime(
125+
birthday.birthday + f"/{dt.datetime.now().year + 1}", "%d/%m/%Y"
126+
)
104127
await QuickEmb(
105128
inter,
106129
f"{user.mention}'s birthday is in {(next_birthday - datetime.datetime.now()).days} Days."
@@ -128,11 +151,18 @@ async def birthday_check(self):
128151
# if the birthday is today, congratulate the user
129152
if user.birthday == today:
130153
await member.add_roles(guild.get_role(self.bot.config.roles.birthday))
131-
congrats_msg = await channel.send(f"{random.choice(congrats_messages)} {member.mention}! 🎂")
154+
congrats_msg = await channel.send(
155+
f"{random.choice(congrats_messages)} {member.mention}! 🎂"
156+
)
132157
await congrats_msg.add_reaction("🥳")
133158
# If the birthday isn't today and the user still has the birthday role, remove it
134-
elif user.birthday != today and member.get_role(self.bot.config.roles.birthday) is not None:
135-
await member.remove_roles(guild.get_role(self.bot.config.roles.birthday))
159+
elif (
160+
user.birthday != today
161+
and member.get_role(self.bot.config.roles.birthday) is not None
162+
):
163+
await member.remove_roles(
164+
guild.get_role(self.bot.config.roles.birthday)
165+
)
136166

137167

138168
def setup(bot):

0 commit comments

Comments
 (0)