mirror of
https://gitlab.com/ddorn/tfjm-discord-bot.git
synced 2025-07-28 00:25:24 +02:00
♻️ File and Emoji enum
This commit is contained in:
@ -1,12 +1,11 @@
|
||||
import datetime
|
||||
import itertools
|
||||
import random
|
||||
import datetime
|
||||
from operator import attrgetter
|
||||
from pprint import pprint
|
||||
from time import time
|
||||
|
||||
import discord
|
||||
from discord import Guild, Emoji
|
||||
from discord import Guild
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import (
|
||||
Cog,
|
||||
@ -19,6 +18,7 @@ from discord.ext.commands import (
|
||||
)
|
||||
|
||||
from src.constants import *
|
||||
from src.constants import Emoji
|
||||
from src.utils import has_role
|
||||
|
||||
|
||||
@ -47,14 +47,14 @@ class MiscCog(Cog, name="Divers"):
|
||||
@command(name="joke", aliases=["blague"], hidden=True)
|
||||
async def joke_cmd(self, ctx):
|
||||
await ctx.message.delete()
|
||||
with open(JOKES_FILE) as f:
|
||||
with open(File.JOKES) as f:
|
||||
jokes = f.read().split("\n\n\n")
|
||||
|
||||
msg = random.choice(jokes)
|
||||
message: discord.Message = await ctx.send(msg)
|
||||
|
||||
await message.add_reaction("😂")
|
||||
await message.add_reaction("😭")
|
||||
await message.add_reaction(Emoji.JOY)
|
||||
await message.add_reaction(Emoji.SOB)
|
||||
|
||||
@command(name="status")
|
||||
@commands.has_role(Role.CNO)
|
||||
|
@ -18,7 +18,7 @@ class TeamsCog(Cog, name="Teams"):
|
||||
self.teams = self.load_teams()
|
||||
|
||||
def load_teams(self):
|
||||
with open(TEAMS_FILE) as f:
|
||||
with open(File.TEAMS) as f:
|
||||
# first line is header
|
||||
lines = f.read().splitlines()[1:]
|
||||
teams = [
|
||||
|
@ -140,15 +140,15 @@ class Tirage(yaml.YAMLObject):
|
||||
await ctx.channel.edit(overwrites={ctx.guild.default_role: send})
|
||||
|
||||
tl = {}
|
||||
if TIRAGES_FILE.exists():
|
||||
with open(TIRAGES_FILE) as f:
|
||||
if File.TIRAGES.exists():
|
||||
with open(File.TIRAGES) as f:
|
||||
tl = yaml.load(f)
|
||||
else:
|
||||
TIRAGES_FILE.touch()
|
||||
File.TIRAGES.touch()
|
||||
|
||||
key = max(0, *tl.keys()) + 1
|
||||
tl[key] = self
|
||||
with open(TIRAGES_FILE, "w") as f:
|
||||
with open(File.TIRAGES, "w") as f:
|
||||
yaml.dump(tl, f)
|
||||
|
||||
await ctx.send(
|
||||
@ -785,10 +785,10 @@ class TirageCog(Cog, name="Tirages"):
|
||||
await tirage.update_phase(ctx)
|
||||
|
||||
def get_tirages(self) -> Dict[int, Tirage]:
|
||||
if not TIRAGES_FILE.exists():
|
||||
if not File.TIRAGES.exists():
|
||||
return {}
|
||||
|
||||
with open(TIRAGES_FILE) as f:
|
||||
with open(File.TIRAGES) as f:
|
||||
tirages = yaml.load(f)
|
||||
|
||||
return tirages
|
||||
|
Reference in New Issue
Block a user