add guildID

This commit is contained in:
Mylloon 2021-06-08 11:18:30 +02:00
parent 2af04ba300
commit 4d4574ae0d
2 changed files with 13 additions and 12 deletions

View file

@ -509,7 +509,7 @@ class Utils(commands.Cog):
messageID = None
if fromSlash != True:
messageID = ctx.message.id
Reminder().ajoutReminder(messageID, ctx.channel.id, mention, reminder, now, now + seconds, ctx.author.id)
Reminder().ajoutReminder(messageID, ctx.channel.id, mention, reminder, now, now + seconds, ctx.author.id, ctx.guild.id)
return await ctx.send(f"Ok, je t'en parles dans {timedeltaToString(seconds)} avec 1m de retard maximum.")
await ctx.send(embed = embed)
@_reminder.error
@ -566,7 +566,7 @@ class Utils(commands.Cog):
else:
utilisateur = ctx.author.id
reminders = Reminder().listeReminder(utilisateur)
reminders = Reminder().listeReminder(utilisateur, ctx.guild.id)
if fromSlash != True:
await ctx.message.add_reaction(emoji = '')
embed = discord.Embed(description = f"**Rappel{'s' if len(reminders) > 1 else ''} de <@{utilisateur}>**", color = discord.Colour.random())

View file

@ -15,21 +15,22 @@ class Reminder(Database):
reminder_str TEXT,
creation_int INTEGER,
expiration_int INTEGER,
user_id INTEGER
user_id INTEGER,
guild_id INTEGER
);
"""
self.requete(requete)
def ajoutReminder(self, messageID = int, channelID = int, mention = int, reminder = str, creation = int, expiration = int, userID = int):
def ajoutReminder(self, messageID = int, channelID = int, mention = int, reminder = str, creation = int, expiration = int, userID = int, guildID = int):
"""Ajoute un reminder"""
requete = """
INSERT INTO reminder (
message_id, channel_id, mention_bool, reminder_str, creation_int, expiration_int, user_id
message_id, channel_id, mention_bool, reminder_str, creation_int, expiration_int, user_id, guild_id
) VALUES (
?, ?, ?, ?, ?, ?, ?
?, ?, ?, ?, ?, ?, ?, ?
);
"""
self.requete(requete, (messageID, channelID, mention, reminder, creation, expiration, userID))
self.requete(requete, [messageID, channelID, mention, reminder, creation, expiration, userID, guildID])
def suppressionReminder(self, id = int):
"""Supprime un reminder"""
@ -37,15 +38,15 @@ class Reminder(Database):
DELETE FROM reminder
WHERE id = ?
"""
self.requete(requete, [id])
self.requete(requete, id)
def listeReminder(self, userID = int):
def listeReminder(self, userID = int, guildID = int):
"""Retourne la liste des reminders d'un utilisateur"""
requete = """
SELECT reminder_str, creation_int, expiration_int FROM reminder
WHERE user_id = ?
WHERE user_id = ? AND guild_id = ?
"""
return self.affichageResultat(self.requete(requete, [userID]))
return self.affichageResultat(self.requete(requete, [userID, guildID]))
def recuperationExpiration(self, time = int):
"""Récupère les reminders qui sont arrivés à expiration et ses infos"""
@ -53,4 +54,4 @@ class Reminder(Database):
SELECT channel_id, mention_bool, reminder_str, creation_int, user_id, id, message_id FROM reminder
WHERE expiration_int < ?
"""
return self.affichageResultat(self.requete(requete, [time]))
return self.affichageResultat(self.requete(requete, time))