Skip to content

Commit 8af5b29

Browse files
committed
Add course cog, and minor changes
1 parent 5a70ed3 commit 8af5b29

File tree

4 files changed

+50
-20
lines changed

4 files changed

+50
-20
lines changed

cogs/courses.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import libsql_experimental as libsql
2+
import discord
3+
from discord.ext import commands
4+
from ..settings import COURSES
5+
6+
class Courses(commands.Cog):
7+
def __init__(self, bot):
8+
self.bot = bot
9+
10+
@commands.hybrid_command(aliases=["formations"])
11+
async def cours(self, ctx):
12+
"""Affiche la liste des cours disponibles."""
13+
embed = discord.Embed(
14+
title="Mes Cours Udemy",
15+
description="Découvrez mes cours pour apprendre à coder !",
16+
color=discord.Color.blue()
17+
)
18+
19+
for course in COURSES:
20+
embed.add_field(
21+
name=course["name"],
22+
value=f"[Lien vers le cours]({course['url']})",
23+
inline=False
24+
)
25+
26+
embed.set_footer(text="N'hésitez pas à me poser des questions si besoin !")
27+
await ctx.send(embed=embed)
28+
29+
30+
async def setup(bot):
31+
await bot.add_cog(Courses(bot))

cogs/leveling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def xp(self, ctx):
9393
color=5814783
9494
)
9595

96-
embed.add_field(name="⭐ Noter un de mes cours Udemy", value="Donner une note à une de mes formations payantes Udemy : **+100 XP**", inline=False)
96+
embed.add_field(name="⭐ Noter un de mes cours Udemy", value="Donner une note à une de mes formations payantes Udemy !cours pour avoir la liste: **+100 XP**", inline=False)
9797
embed.add_field(name="📩 Inviter un nouveau membre", value="Invitez vos amis à rejoindre le serveur : **+30 XP**", inline=False)
9898
embed.add_field(name="🤝 Aider quelqu'un dans [le forum d'aide])(https://discord.com/channels/1115999077776240682/1307900991563108382)", value="Donnez une réponse utile ou résolvez un problème : **+30 XP**", inline=False)
9999
embed.add_field(name="💬 Poster un message", value="Postez un message (1 fois par minute pour éviter le flood) : **+1 XP**", inline=False)

cogs/social.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
from discord.ext import commands
2+
from ..settings import SOCIALS
23

3-
socials = {
4-
"youtube": "https://www.youtube.com/channel/UCEztUC2WwKEDkVl9c6oUoTw?sub_confirmation=1",
5-
"udemy": "https://www.udemy.com/user/thomas-collart/?referralCode=F0901265E01C7FDADABC",
6-
"tiktok": "https://www.tiktok.com/@commentcoder",
7-
"instagram": "https://www.instagram.com/commentcoder_com",
8-
"github": "https://github.com/commentcoder",
9-
"linkedin": "https://linkedin.com/in/thomascollart/"
10-
}
114

125
class Social(commands.Cog):
136
def __init__(self, bot):
@@ -16,27 +9,27 @@ def __init__(self, bot):
169

1710
@commands.hybrid_command()
1811
async def github(self, ctx):
19-
await ctx.send(socials["github"])
12+
await ctx.send(SOCIALS["github"])
2013

2114
@commands.hybrid_command()
2215
async def instagram(self, ctx):
23-
await ctx.send(socials["instagram"])
16+
await ctx.send(SOCIALS["instagram"])
2417

2518
@commands.hybrid_command()
2619
async def linkedin(self, ctx):
27-
await ctx.send(socials["linkedin"])
20+
await ctx.send(SOCIALS["linkedin"])
2821

2922
@commands.hybrid_command()
3023
async def tiktok(self, ctx):
31-
await ctx.send(socials["tiktok"])
24+
await ctx.send(SOCIALS["tiktok"])
3225

3326
@commands.hybrid_command()
3427
async def udemy(self, ctx):
35-
await ctx.send(socials["udemy"])
28+
await ctx.send(SOCIALS["udemy"])
3629

3730
@commands.hybrid_command()
3831
async def youtube(self, ctx):
39-
await ctx.send(socials["youtube"])
32+
await ctx.send(SOCIALS["youtube"])
4033

4134

4235
async def setup(bot):

main.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@
88
token : str = os.getenv("DISCORD_TOKEN") or ""
99

1010
class CommentBotter(commands.Bot):
11-
async def setup_hook(self):
12-
for extension in ["database", "leveling", "social", "welcome"]:
13-
await self.load_extension(f'cogs.{extension}')
11+
async def setup_hook(self):
12+
for filename in os.listdir("./cogs"):
13+
if filename.endswith(".py"):
14+
extension = f"cogs.{filename[:-3]}"
15+
try:
16+
await self.load_extension(extension)
17+
print(f"Loaded extension: {extension}")
18+
except Exception as e:
19+
print(f"Failed to load extension {extension}: {e}")
1420

15-
await self.tree.sync()
16-
print("Les commandes slash ont été synchronisées.")
21+
await self.tree.sync()
22+
print("Les commandes slash ont été synchronisées.")
1723

1824
intents = discord.Intents.all()
1925
bot = CommentBotter(command_prefix='!', intents=intents)

0 commit comments

Comments
 (0)