aboutsummaryrefslogtreecommitdiff
path: root/commands/mod
diff options
context:
space:
mode:
Diffstat (limited to 'commands/mod')
-rw-r--r--commands/mod/blacklist.js56
-rw-r--r--commands/mod/confirm.js11
-rw-r--r--commands/mod/defaults/blacklist.js.json2
3 files changed, 64 insertions, 5 deletions
diff --git a/commands/mod/blacklist.js b/commands/mod/blacklist.js
new file mode 100644
index 0000000..a585640
--- /dev/null
+++ b/commands/mod/blacklist.js
@@ -0,0 +1,56 @@
+const fs = require('fs')
+const path = require("path");
+let config_loc = __filename+".json"
+const { PermissionsBitField } = require('discord.js');
+let config = JSON.parse(fs.readFileSync(config_loc))
+const { EmbedBuilder, ActionRowBuilder,ButtonBuilder,ButtonStyle } = require("discord.js");
+const settings = require("../../src/settings")
+const {upload_limit} = require("../../src/util")
+
+module.exports = {
+ name : "blacklist",
+ command: ["blacklist"],
+ mod_only: true,
+ config:config,
+ config_loc:config_loc,
+ async main (client,Discord,message,args){
+
+ let del = false
+ switch(args[0]){
+ case "del":
+ del = true;
+ args.shift()
+ break;
+ case "dump":
+ let flist = ""
+ for(let l of await global.preserve.blacklist.values())
+ flist+=l + " "
+ let filename = "/tmp/blacklist.txt"
+ fs.writeFileSync(filename,flist)
+
+ let stats = fs.statSync(filename)
+ if(stats.size / (1024*1024) > upload_limit(message.guild))
+ return message.reply("file too large:( file is "+stats.size / (1024*1024)+"mb")
+ message.reply({files:[filename]})
+ return
+ break;
+ case "test":
+ return message.reply(await global.preserve.blacklist.getItem(args[1]) != null ? "found" : "not found")
+ break;
+ }
+
+ let len = await global.preserve.blacklist.length()
+ for(let id of args){
+ console.log(id)
+ if(del){
+ await global.preserve.blacklist.removeItem(id);
+ } else {
+ await global.preserve.blacklist.setItem(id,id);
+ }
+ }
+
+ return message.reply("wrote " + (await global.preserve.blacklist.length() - len) + " entrie(s)")
+
+
+ },
+} \ No newline at end of file
diff --git a/commands/mod/confirm.js b/commands/mod/confirm.js
index 9ef0ed0..e4d2233 100644
--- a/commands/mod/confirm.js
+++ b/commands/mod/confirm.js
@@ -7,6 +7,7 @@ const message = require("../../events/message");
let config_loc = __filename+".json"
let config = JSON.parse(fs.readFileSync(config_loc))
let { Events, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
+const llog = require("../../src/logg")
const preserve = require("../../src/interaction-preserve")
module.exports = {
name: "ban",
@@ -181,14 +182,14 @@ module.exports = {
try {
await user.send({embeds:[ban_embed]})
} catch (e) {
- console.log(e)
+ console.error(e)
could_send = false;
}
try{
user = param.message.guild.members.cache.get(user.id)
await user.ban({deleteMessageSeconds: 60 * 60 * 24 * 7, reason: param.reason})
} catch (e) {
- console.log(e)
+ console.error(e)
could_ban = false;
}
@@ -206,7 +207,7 @@ module.exports = {
mess.edit({embeds:[embed],components:[]})
}
} catch (e) {
- console.log(e)
+ console.error(e)
}
}
//await rec_read();
@@ -248,14 +249,14 @@ module.exports = {
try {
await user.send({embeds:[ban_embed]})
} catch (e) {
- console.log(e)
+ console.error(e)
could_send = false;
}
try{
user = interaction.guild.members.cache.get(user.id)
await user.ban({deleteMessageSeconds: 60 * 60 * 24 * 7, reason: data.param.reason})
} catch (e) {
- console.log(e)
+ console.error(e)
could_ban = false;
}
diff --git a/commands/mod/defaults/blacklist.js.json b/commands/mod/defaults/blacklist.js.json
new file mode 100644
index 0000000..513645f
--- /dev/null
+++ b/commands/mod/defaults/blacklist.js.json
@@ -0,0 +1,2 @@
+{"cooldown":-1,"desc":"Blacklist a user id, once banned blacklist will be removed","restrict":[],"restricted":[],
+"usage":"{command} (del | dump) [id, ...]"} \ No newline at end of file