-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist gagged users.js
47 lines (39 loc) · 1.7 KB
/
list gagged users.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const { SlashCommandBuilder } = require("@discordjs/builders")
const { MessageEmbed } = require('discord.js');
const Enmap = require('enmap');
const run = async (client, interaction) => {
const gaglist = new Enmap({
name: "gaglist",
fetchAll: true, // Important, we fetch all of the entries when we run it, so this can get quite laggy in the future.
autoFetch: true,
cloneLevel: 'deep'
})
// Joe's terrible date management(TM)
const d = new Date()
const datesetup = new Date(d.valueOf());
const currentDate = datesetup.toLocaleString()
const gaggedUsers = gaglist.filter(user => user.guild === interaction.guild.id).array();
const embed = new MessageEmbed()
.setTitle("Gagged List")
.setColor(0x00AE86);
for (const data of gaggedUsers) {
// Loops through each entry of list and adds a line in the embed for each one.
let key = `${data.guild}-${data.name}`
let fetchExperitationDate = gaglist.get(key, "expirationdate")
let expirationDate = fetchExperitationDate.toLocaleString()
if (currentDate >= expirationDate) {
// Drops them if they are outdated, so we never have outdated entries.
gaglist.delete(key);
break;
}
embed.addField(client.users.cache.get(data.name).tag, `until ${data.expirationdate}`, true);
}
return interaction.reply({ embeds: [embed], ephemeral: true })
}
module.exports = {
data: new SlashCommandBuilder().setName("list-gagged-users").setDescription("Lists all the users that have been gagged."),
name: "list-gagged-users",
perms: "useperms",
description: "Lists all the users that have been gagged.",
run
}