Skip to content

Commit c1b8641

Browse files
committed
Merge Beta-1.2 into main: release v1.2.0-beta-1.2
2 parents 8fe13ad + 720c380 commit c1b8641

35 files changed

+1891
-780
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ bday.json
88
confserver.json
99
reminders.json
1010
sanctions.json
11-
DATABASE_SETUP.md
11+
DATABASE_SETUP.md
12+
rate-limits-solutions.md

commands/administration/annonce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export async function execute(interaction: CommandInteraction) {
172172
.setTitle(`📢 ${titre}`)
173173
.setDescription(message)
174174
.setFooter({
175-
text: `Annonce par ${interaction.user.username}`,
175+
text: `Demandé par ${interaction.user.username}`,
176176
iconURL: interaction.user.displayAvatarURL({ forceStatic: false })
177177
})
178178
.setTimestamp();

commands/administration/logconfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ export const data = new SlashCommandBuilder()
55
.setName('logconfig')
66
.setDescription('Configure les logs du serveur')
77
.addChannelOption(option => option.setName('canal')
8-
.setDescription('Le canal où envoyer les logs')
8+
.setDescription('Le canal où sont envoyés les logs du serveur.')
99
.addChannelTypes(ChannelType.GuildText)
1010
.setRequired(true))
1111
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator);
1212

1313
export async function execute(interaction: CommandInteraction) {
1414
if (!interaction.guild) {
15-
await interaction.reply('Cette commande ne peut être utilisée que sur un serveur.');
15+
await interaction.reply('Cette commande ne peut être utilisée que sur un serveur.');
1616
return;
1717
}
1818

commands/administration/muteroleconfig.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,25 @@ export async function execute(interaction: CommandInteraction) {
3535
try {
3636
switch (subcommand) {
3737
case 'set': {
38+
await interaction.deferReply();
39+
3840
const role = interaction.options.getRole('role') as Role;
3941

4042
if (!role) {
41-
await interaction.reply('Rôle invalide.');
43+
await interaction.editReply('Rôle invalide.');
4244
return;
4345
}
4446

4547
// Vérifier que le rôle existe et est accessible
4648
if (!interaction.guild.roles.cache.has(role.id)) {
47-
await interaction.reply('❌ Ce rôle n\'existe pas ou n\'est pas accessible.');
49+
await interaction.editReply('❌ Ce rôle n\'existe pas ou n\'est pas accessible.');
4850
return;
4951
}
5052

5153
// Vérifier que le bot peut gérer ce rôle
5254
const botMember = interaction.guild.members.me;
5355
if (!botMember || role.position >= botMember.roles.highest.position) {
54-
await interaction.reply('❌ Je ne peux pas gérer ce rôle car il est égal ou supérieur à mon rôle le plus élevé.');
56+
await interaction.editReply('❌ Je ne peux pas gérer ce rôle car il est égal ou supérieur à mon rôle le plus élevé.');
5557
return;
5658
}
5759

@@ -77,11 +79,13 @@ export async function execute(interaction: CommandInteraction) {
7779
})
7880
.setTimestamp();
7981

80-
await interaction.reply({ embeds: [embed] });
82+
await interaction.editReply({ embeds: [embed] });
8183
break;
8284
}
8385

8486
case 'create': {
87+
await interaction.deferReply();
88+
8589
const roleName = interaction.options.getString('nom') || 'Muted';
8690

8791
// Créer le rôle de mute
@@ -148,11 +152,13 @@ export async function execute(interaction: CommandInteraction) {
148152
});
149153
}
150154

151-
await interaction.reply({ embeds: [embed] });
155+
await interaction.editReply({ embeds: [embed] });
152156
break;
153157
}
154158

155159
case 'disable': {
160+
await interaction.deferReply();
161+
156162
// Supprimer la configuration du rôle de mute
157163
await updateMuteRole(interaction.guild.id, '');
158164

@@ -175,12 +181,18 @@ export async function execute(interaction: CommandInteraction) {
175181
})
176182
.setTimestamp();
177183

178-
await interaction.reply({ embeds: [embed] });
184+
await interaction.editReply({ embeds: [embed] });
179185
break;
180186
}
181187
}
182188
} catch (error) {
183189
console.error('Erreur lors de la configuration du rôle de mute:', error);
184-
await interaction.reply('❌ Une erreur est survenue lors de la configuration du rôle de mute.');
190+
191+
// Vérifier si on peut encore répondre
192+
if (interaction.deferred || interaction.replied) {
193+
await interaction.editReply('❌ Une erreur est survenue lors de la configuration du rôle de mute.');
194+
} else {
195+
await interaction.reply('❌ Une erreur est survenue lors de la configuration du rôle de mute.');
196+
}
185197
}
186198
}

commands/games/blague.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ export async function execute(interaction: CommandInteraction) {
7474
{ name: "Question", value: joke.joke },
7575
{ name: "Réponse", value: joke.answer }
7676
)
77-
.setFooter({ text: `Catégorie: ${categories.find(cat => cat.value === category)?.name}` })
77+
.setFooter({
78+
text: `Catégorie: ${categories.find(cat => cat.value === category)?.name} • Demandé par ${interaction.user.username}`,
79+
iconURL: interaction.user.displayAvatarURL({ forceStatic: false })
80+
})
7881
.setTimestamp();
7982

8083
const button = new ButtonBuilder()
@@ -113,7 +116,10 @@ export async function execute(interaction: CommandInteraction) {
113116
{ name: "Question", value: newJoke.joke },
114117
{ name: "Réponse", value: newJoke.answer }
115118
)
116-
.setFooter({ text: `Catégorie: ${categories.find(cat => cat.value === category)?.name}` })
119+
.setFooter({
120+
text: `Catégorie: ${categories.find(cat => cat.value === category)?.name} • Demandé par ${interaction.user.username}`,
121+
iconURL: interaction.user.displayAvatarURL({ forceStatic: false })
122+
})
117123
.setTimestamp();
118124

119125
await i.editReply({

commands/general/stats.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ export async function execute(interaction: CommandInteraction) {
5555
.addFields(
5656
{ name: '🏓 Latence', value: `${interaction.client.ws.ping}ms`, inline: true },
5757
{ name: '⏰ Temps de fonctionnement', value: `${days}j ${hours}h ${minutes}m ${seconds}s`, inline: true },
58+
{ name: '\u200b', value: '\u200b', inline: true },
5859
{ name: '🧠 RAM utilisée', value: `${memoryUsedMB}MB / ${memoryTotalMB}MB`, inline: true },
5960
{ name: '💻 CPU', value: `${cpuPercent}%`, inline: true },
61+
{ name: '\u200b', value: '\u200b', inline: true },
6062
{ name: '🏠 Serveurs', value: interaction.client.guilds.cache.size.toString(), inline: true },
6163
{ name: '👥 Utilisateurs', value: interaction.client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0).toString(), inline: true },
64+
{ name: '\u200b', value: '\u200b', inline: true },
6265
{ name: '📺 Canaux', value: interaction.client.channels.cache.size.toString(), inline: true },
6366
{ name: '🎭 Rôles', value: interaction.client.guilds.cache.reduce((acc, guild) => acc + guild.roles.cache.size, 0).toString(), inline: true }
6467
)

commands/moderation/clear.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { type CommandInteraction, SlashCommandBuilder, ChannelType, TextChannel, PermissionFlagsBits } from "discord.js";
1+
import { type CommandInteraction, SlashCommandBuilder, ChannelType, TextChannel, PermissionFlagsBits, Message } from "discord.js";
2+
import { formatMessagesForArchive, uploadToPastebin } from "../../utils/messageArchiver.ts";
3+
import { storeArchiveUrl } from "../../utils/archiveCache.ts";
24

35
export const data = new SlashCommandBuilder()
46
.setName('clear')
@@ -23,11 +25,43 @@ export async function execute(interaction: CommandInteraction) {
2325

2426
if (interaction.channel?.isTextBased() && interaction.channel.type === ChannelType.GuildText) {
2527
const textChannel = interaction.channel as TextChannel;
28+
2629
await textChannel.bulkDelete(amount, true)
27-
.then(messages => {
30+
.then(async (messages) => {
2831
const messageCount = messages.size;
2932
const messageText = messageCount === 1 ? 'message' : 'messages';
30-
interaction.reply(`🗑️ Suppression de **${messageCount} ${messageText}**.`);
33+
34+
// Archiver uniquement les messages qui ont été effectivement supprimés
35+
console.log(`[Clear] Début de l'archivage de ${messageCount} messages supprimés...`);
36+
37+
if (messages.size > 0) {
38+
const archiveContent = formatMessagesForArchive(messages as any);
39+
const title = `Messages supprimés - ${interaction.guild?.name} - ${new Date().toLocaleString('fr-FR')}`;
40+
41+
console.log(`[Clear] Tentative d'upload sur Pastebin...`);
42+
const pastebinUrl = await uploadToPastebin(archiveContent, title);
43+
44+
if (pastebinUrl) {
45+
console.log(`[Clear] ✅ Archive créée avec succès: ${pastebinUrl}`);
46+
// Stocker l'URL dans le cache pour l'événement MessageBulkDelete
47+
const messageIds = Array.from(messages.keys());
48+
storeArchiveUrl(interaction.guild!.id, textChannel.id, messageIds, pastebinUrl);
49+
} else {
50+
console.error('[Clear] ❌ Échec de la création de l\'archive Pastebin');
51+
console.error('[Clear] Vérifiez les logs ci-dessus pour plus de détails');
52+
}
53+
}
54+
55+
// Répondre et supprimer le message après 10 secondes
56+
interaction.reply(`🗑️ Suppression de **${messageCount} ${messageText}**.`)
57+
.then(reply => {
58+
setTimeout(() => {
59+
reply.delete().catch(() => {});
60+
}, 10000);
61+
})
62+
.catch(error => {
63+
console.error('[Clear] Erreur lors de l\'envoi de la réponse:', error);
64+
});
3165
})
3266
.catch(error => {
3367
console.error('Erreur lors de la suppression des messages :', error);

commands/moderation/modinfo.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export async function execute(interaction: CommandInteraction) {
4242
const activeBan = await getActiveTempBan(interaction.guild.id, target.id);
4343
const activeMute = await getActiveTempMute(interaction.guild.id, target.id);
4444

45+
// Vérifier si l'utilisateur est en timeout Discord
46+
const targetMember = interaction.guild.members.cache.get(target.id);
47+
const isTimedOut = targetMember?.isCommunicationDisabled();
48+
const timeoutUntil = targetMember?.communicationDisabledUntil;
49+
4550
// Créer l'embed
4651
const embed = new EmbedBuilder()
4752
.setAuthor({
@@ -50,6 +55,10 @@ export async function execute(interaction: CommandInteraction) {
5055
})
5156
.setColor('#0099ff')
5257
.setThumbnail(target.displayAvatarURL({ forceStatic: false }))
58+
.setFooter({
59+
text: 'Demandé par ' + interaction.user.username,
60+
iconURL: interaction.user.displayAvatarURL({ forceStatic: false })
61+
})
5362
.setTimestamp();
5463

5564
// Sanctions actives
@@ -58,6 +67,8 @@ export async function execute(interaction: CommandInteraction) {
5867
activeStatus = `🔨 **Ban temporaire actif**\nExpire: <t:${Math.floor(new Date(activeBan.end_time).getTime() / 1000)}:F>\nRaison: ${activeBan.reason}`;
5968
} else if (activeMute) {
6069
activeStatus = `🔇 **Mute temporaire actif**\nExpire: <t:${Math.floor(new Date(activeMute.end_time).getTime() / 1000)}:F>\nRaison: ${activeMute.reason}`;
70+
} else if (isTimedOut && timeoutUntil) {
71+
activeStatus = `⏱️ **Timeout actif**\nExpire: <t:${Math.floor(timeoutUntil.getTime() / 1000)}:F>`;
6172
}
6273

6374
embed.addFields({ name: '📊 Statut actuel', value: activeStatus, inline: false });

commands/moderation/warnings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export async function execute(interaction: CommandInteraction) {
3333
})
3434
.setColor('#ffaa00')
3535
.setThumbnail(target.displayAvatarURL({ forceStatic: false }))
36+
.setFooter({
37+
text: 'Demandé par ' + interaction.user.username,
38+
iconURL: interaction.user.displayAvatarURL({ forceStatic: false })
39+
})
3640
.setTimestamp();
3741

3842
if (warnings.length === 0) {

commands/utilitaires/channelinfo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export async function execute(interaction: CommandInteraction) {
2121
.addFields(
2222
{ name: '📺 Nom', value: targetChannel.name, inline: true },
2323
{ name: '🆔 ID', value: targetChannel.id, inline: true },
24-
{ name: '📅 Créé le', value: `<t:${Math.floor(targetChannel.createdTimestamp / 1000)}:F>`, inline: true },
25-
{ name: '📝 Type', value: getChannelTypeName(targetChannel.type), inline: true },
24+
{ name: '📅 Créé le', value: `<t:${Math.floor(targetChannel.createdTimestamp / 1000)}:F>`},
25+
{ name: '📝 Type', value: getChannelTypeName(targetChannel.type)},
2626
{ name: '📍 Position', value: targetChannel.position.toString(), inline: true }
2727
)
2828
.setFooter({

0 commit comments

Comments
 (0)