Add stuff
This commit is contained in:
parent
985392ec16
commit
12c15fc62d
18
helpers.js
18
helpers.js
|
@ -1,3 +1,5 @@
|
|||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
module.exports = {}
|
||||
const change = 62167219200; // Subtract a year, whoops
|
||||
module.exports.convertSLTimestamp = (timestamp) => {
|
||||
|
@ -69,6 +71,22 @@ module.exports.diff = (oldData, newData) => {
|
|||
return result;
|
||||
}
|
||||
|
||||
module.exports.generateBanFile = (bans) => {
|
||||
let banFile = "";
|
||||
Object.keys(bans).forEach(key => {
|
||||
ban = bans[key];
|
||||
banFile += `${ban.banned_username};${ban.banned_id};${module.exports.toSLTimestamp(ban.expires)};${ban.reason};${ban.moderator};${module.exports.toSLTimestamp(ban.banned_timestamp)}\n`
|
||||
})
|
||||
return banFile;
|
||||
};
|
||||
|
||||
module.exports.generateBanLine = (ban) => {
|
||||
return `${ban.banned_username};${ban.banned_id};${module.exports.toSLTimestamp(ban.expires)};${ban.reason};${ban.moderator};${module.exports.toSLTimestamp(ban.banned_timestamp)}`
|
||||
}
|
||||
|
||||
module.exports.removeBan = (bans, id) => {
|
||||
delete bans[id];
|
||||
return bans;
|
||||
}
|
||||
|
||||
return module.exports
|
98
index.js
98
index.js
|
@ -91,6 +91,104 @@ client.on('ready', async () => {
|
|||
watchFiles();
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async interaction => {
|
||||
if (!interaction.isCommand()) return;
|
||||
switch (interaction.commandName) {
|
||||
case "ban":
|
||||
switch (interaction.options.getSubcommand()) {
|
||||
case "lookup":
|
||||
type = interaction.options.getString("type");
|
||||
value = interaction.options.getString("value");
|
||||
if (type == "ip") {
|
||||
if (ipBans[value]) {
|
||||
embed = {
|
||||
fields: [
|
||||
{
|
||||
name: "Banned Username",
|
||||
value: ipBans[value].banned_username,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Banned ID",
|
||||
value: ipBans[value].banned_id,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Banned",
|
||||
value: `<t:${new Date(ipBans[value].banned_timestamp) / 1000}:f> <t:${new Date(ipBans[value].banned_timestamp) / 1000}:R>`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Expires",
|
||||
value: `<t:${new Date(ipBans[value].expires) / 1000}:f> <t:${new Date(ipBans[value].expires) / 1000}:R>`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Reason",
|
||||
value: ipBans[value].reason,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Moderator",
|
||||
value: ipBans[value].moderator,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
}
|
||||
embed.title = "IP Ban Lookup"
|
||||
embed.color = 0xffff00
|
||||
interaction.reply({ embeds: [embed] })
|
||||
} else {
|
||||
interaction.reply("No ban found for that IP")
|
||||
}
|
||||
} else if (type == "id") {
|
||||
if (idBans[value]) {
|
||||
embed = {
|
||||
fields: [
|
||||
{
|
||||
name: "Banned Username",
|
||||
value: idBans[value].banned_username,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Banned ID",
|
||||
value: idBans[value].banned_id,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Banned",
|
||||
value: `<t:${new Date(idBans[value].banned_timestamp) / 1000}:f> <t:${new Date(idBans[value].banned_timestamp) / 1000}:R>`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Expires",
|
||||
value: `<t:${new Date(idBans[value].expires) / 1000}:f> <t:${new Date(idBans[value].expires) / 1000}:R>`,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Reason",
|
||||
value: idBans[value].reason,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "Moderator",
|
||||
value: idBans[value].moderator,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
}
|
||||
embed.title = "ID Ban Lookup"
|
||||
embed.color = 0xffff00
|
||||
interaction.reply({ embeds: [embed] })
|
||||
} else {
|
||||
interaction.reply("No ban found for that ID")
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const sendMessages = async (data) => {
|
||||
|
|
17
package-lock.json
generated
17
package-lock.json
generated
|
@ -11,7 +11,9 @@
|
|||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"discord.js": "^14.15.3",
|
||||
"dotenv": "^16.4.5"
|
||||
"dotenv": "^16.4.5",
|
||||
"moment": "^2.30.1",
|
||||
"moment-duration-format": "^2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/builders": {
|
||||
|
@ -257,6 +259,19 @@
|
|||
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.10.0.tgz",
|
||||
"integrity": "sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ=="
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.30.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
|
||||
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/moment-duration-format": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/moment-duration-format/-/moment-duration-format-2.3.2.tgz",
|
||||
"integrity": "sha512-cBMXjSW+fjOb4tyaVHuaVE/A5TqkukDWiOfxxAjY+PEqmmBQlLwn+8OzwPiG3brouXKY5Un4pBjAeB6UToXHaQ=="
|
||||
},
|
||||
"node_modules/ts-mixer": {
|
||||
"version": "6.0.4",
|
||||
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz",
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"discord.js": "^14.15.3",
|
||||
"dotenv": "^16.4.5"
|
||||
"dotenv": "^16.4.5",
|
||||
"moment": "^2.30.1",
|
||||
"moment-duration-format": "^2.3.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue