aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorame <[email protected]>2024-08-28 01:55:32 -0500
committerame <[email protected]>2024-08-28 01:55:32 -0500
commitc47415cd3e4734b111c7035074dd57e32cd60be7 (patch)
treef36d09f3db900e886973f61ac22cdd7e6572cf4a /commands
parenta3b50cdacc5653d49784a84276284e421e96cc8a (diff)
multiple changesHEADmain
Diffstat (limited to 'commands')
-rw-r--r--commands/games/battleship.js9
-rw-r--r--commands/mod/blacklist.js56
-rw-r--r--commands/mod/confirm.js11
-rw-r--r--commands/mod/defaults/blacklist.js.json2
-rw-r--r--commands/util/say.js24
5 files changed, 83 insertions, 19 deletions
diff --git a/commands/games/battleship.js b/commands/games/battleship.js
index 136124a..085365a 100644
--- a/commands/games/battleship.js
+++ b/commands/games/battleship.js
@@ -5,6 +5,7 @@ const { PermissionsBitField, EmbedBuilder, AttachmentBuilder,ActionRowBuilder,Bu
let config = JSON.parse(fs.readFileSync(config_loc))
const util = require("../../src/util.js")
const sharp = require("sharp");
+const llog = require("../../src/logg")
const db = require("../../src/db.js")
module.exports = {
name : "battleship",
@@ -34,9 +35,9 @@ module.exports = {
.setCustomId('up')
.setEmoji('⬆️')
.setStyle(ButtonStyle.Primary);
- const down = new ButtonBuilder()
- .setCustomId('down')
- .setEmoji('⬇️')
+ const down = new ButtonBuilder()
+ .setCustomId('down')
+ .setEmoji('⬇️')
.setStyle(ButtonStyle.Primary);
const right = new ButtonBuilder()
.setCustomId('right')
@@ -146,7 +147,7 @@ module.exports = {
return rec_edit(mess)
} catch (e) {
- console.log(e)
+ llog.error(e)
}
}
return await rec_edit(mess)
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
diff --git a/commands/util/say.js b/commands/util/say.js
index 1966512..eda3675 100644
--- a/commands/util/say.js
+++ b/commands/util/say.js
@@ -55,22 +55,26 @@ module.exports = {
{type:"string",name:"footer",desc:"footer text",required:false,autocomplete:false},
]}],
async s_main (client,Discord,interaction){
- let action = interaction.options.getSubcommand()
- if(action == "text"){
- this.exec(client,
- {echo:interaction.options.getString("echo"),
- id:interaction.options.getChannel("channel") ?? interaction.channel})
- await interaction.reply({ content:'sent', ephemeral: true })
- interaction.deleteReply()
- } else if(action == "embed"){
- this.embed_exec(client, {msg:interaction,id:interaction.channel})
+ try{
+ let action = interaction.options.getSubcommand()
+ if(action == "text"){
+ this.exec(client,
+ {echo:interaction.options.getString("echo"),
+ id:interaction.options.getChannel("channel") ?? interaction.channel})
+ await interaction.reply({ content:'sent', ephemeral: true })
+ interaction.deleteReply()
+ } else if(action == "embed"){
+ this.embed_exec(client, {msg:interaction,id:interaction.channel})
+ }
+ } catch(e) {
+ info.interaction.channel.reply({ content: 'error sending message, most likely from permissions or length', ephemeral: true})
}
},
async exec(client,info){
- return info.id.send(info.echo)
+ return await info.id.send(info.echo)
},
async embed_exec(client, info){