aboutsummaryrefslogtreecommitdiff
path: root/commands/mod
diff options
context:
space:
mode:
authorame <[email protected]>2024-04-22 23:46:32 -0500
committerame <[email protected]>2024-04-22 23:46:32 -0500
commit509293de5af9bab66d624fd044e63d8962577af3 (patch)
tree9405af217212020965e68f1c97ff605cddacd2ca /commands/mod
parent6192af17619bba6066807a383375ba6178636cba (diff)
long time no commit
Diffstat (limited to 'commands/mod')
-rw-r--r--commands/mod/add.js54
-rw-r--r--commands/mod/confirm.js70
-rw-r--r--commands/mod/defaults/add.js.json2
-rw-r--r--commands/mod/whois.js4
4 files changed, 117 insertions, 13 deletions
diff --git a/commands/mod/add.js b/commands/mod/add.js
new file mode 100644
index 0000000..b9ac0ab
--- /dev/null
+++ b/commands/mod/add.js
@@ -0,0 +1,54 @@
+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")
+
+module.exports = {
+ name : "add",
+ command: ["add"],
+ mod_only: true,
+ config:config,
+ config_loc:config_loc,
+ async main (client,Discord,message,args){
+
+ },
+ s_options:[{type:"sub",name:"button",options:[
+ {type:"string",name:"message",desc:"message id to edit",required:true,autocomplete:false},
+ {type:"string",name:"label",desc:"text on the button",required:true,autocomplete:false},
+ {type:"string",name:"custom-id",desc:"custom id to do custom things",required:true,autocomplete:false},
+ {type:"string",name:"style",desc:"button type",required:true,autocomplete:["Primary","Secondary","Success","Danger","Link"]}
+ ]}],
+ async s_main (client,Discord,interaction){
+ let action = interaction.options.getSubcommand()
+ if(action == "button"){
+ this.exec_button(client, interaction)
+ //await interaction.reply({ content:'sent', ephemeral: true })
+ //interaction.deleteReply()
+ }
+
+
+ },
+
+ async exec_button(client,interaction){
+ interaction.channel.messages.fetch(interaction.options.getString("message"))
+ .then(msg => {
+ if(msg.author.id != "762561860150362142")
+ return interaction.reply({ content:'message must be owned by me', ephemeral: true })
+ const button = new ButtonBuilder()
+ .setCustomId(interaction.options.getString("custom-id"))
+ .setLabel(interaction.options.getString("label"))
+ .setStyle(ButtonStyle[interaction.options.getString("style")])
+
+ const row = new ActionRowBuilder()
+ .addComponents(button);
+
+ msg.edit({components:[row]})
+ interaction.reply({ content:'success', ephemeral: true })
+ }) .catch(e => {
+ interaction.reply({ content:'unable to add anything, are you in the same channel?', ephemeral: true })
+ })
+ },
+} \ No newline at end of file
diff --git a/commands/mod/confirm.js b/commands/mod/confirm.js
index a0e6714..cbf3846 100644
--- a/commands/mod/confirm.js
+++ b/commands/mod/confirm.js
@@ -18,21 +18,37 @@ module.exports = {
s_options:[
{type:"user",name:"user",desc:"message to be sent",required:true,autocomplete:false},
{type:"string",name:"ban-reason",desc:"ban reason to be sent to the user",required:true,autocomplete:false},
- {type:"string",name:"details",desc:"staff note (mod side only)",required:false,autocomplete:false},
+ {type:"string",name:"staff-note",desc:"viewable only to staff",required:false,autocomplete:false},
{type:"boolean",name:"send-appeal",desc:"whether to send your user id for appealing (default : false)", required:false,autocomplete:false},
{type:"boolean",name:"open-thread",desc:"open a thread for discussion (default : false)", required:false,autocomplete:false},
+ //{type:"boolean",name:"delete-messages",desc:"delete recent messages from user (default : true)", required:false,autocomplete:false},
],
- s_main(client,Discord,interaction){
+ async s_main(client,Discord,interaction){
+
+ await interaction.guild.members.fetch()
+ await interaction.guild.channels.fetch()
+
+
+ /*
+ interaction.channel.messages.fetch({limit:100}).then(m => {
+ m.forEach(message => console.log(message.id))
+ })*/
+
+
this.exec(client, {
message : interaction,
user : interaction.guild.members.cache.get(interaction.options.getUser("user").id),
reason : interaction.options.getString("ban-reason"),
- details : interaction.options.getString("details"),
+ details : interaction.options.getString("staff-note"),
appeal : interaction.options.getBoolean("send-appeal"),
thread : interaction.options.getBoolean("open-thread"),
+ //del_messages : interaction.options.getBoolean("delete-messages") ?? true,
})
},
async exec(client,param){
+ if(!param.user){
+ return param.message.reply({content:"user not found",ephemeral: true })
+ }
let embed = new EmbedBuilder()
.setTitle("Waiting for Confirmation")
.setThumbnail(param.user.displayAvatarURL())
@@ -50,11 +66,22 @@ module.exports = {
.setCustomId('confirm')
.setLabel('Confirm')
.setStyle(ButtonStyle.Primary)
+
+ const cancel_button = new ButtonBuilder()
+ .setCustomId('cancel')
+ .setLabel('Cancel')
+ .setStyle(ButtonStyle.Danger)
+
const row = new ActionRowBuilder()
- .addComponents(confirm_button);
+ .addComponents(confirm_button, cancel_button);
let confirms = [param.message.author.id]
- let mess = await param.message.reply({embeds:[embed],components:[row]})
+ //await param.message.deferReply();
+ //param.message.deferUpdate()
+ let mess = await param.message.deferReply({ fetchReply: true })
+ param.message.editReply({embeds:[embed],components:[row]})
+ //await param.message.editReply({embeds:[embed],components:[row]})
+ //if(mess.partial) mess = mess.fetch()
if(param.thread){
let th = await client.channels.cache.get(param.message.channelId).threads.create({
@@ -66,9 +93,11 @@ module.exports = {
}
async function rec_read(){
- const collectorFilter = i => i.user.id != param.message.author.id && !confirms.includes(i.user.id);
+ const collectorFilter = i => true;//i.user.id != param.message.author.id && !confirms.includes(i.user.id);
try {
const confirmation = await mess.awaitMessageComponent({ filter: collectorFilter, time: 60000000 });
+ //confirmation.deferReply();
+ confirmation.deferUpdate()
if(confirmation.customId == "confirm"){
confirms.push(confirmation.author.id)
let comb_mod = ""
@@ -76,10 +105,10 @@ module.exports = {
comb_mod += "<@" + mod + ">"
if(mod != confirms[confirms.length-1]) comb_mod += ","
}
- embed.setFooter({text:confirms.length - 1 + "/2 confirmations"})
+ embed.setFooter({text:confirms.length - 1 + "/1 confirmations"})
embed.data.fields[0].value = comb_mod
- if(confirms.length >= 3){
+ if(confirms.length >= 2){
let ban_embed = new EmbedBuilder()
.setTitle("Banned from Supernoobs")
.setFooter({text:"You have been banned from this server. Maybe in another life, we could have been friends. But not in this one. 💔"})
@@ -88,21 +117,36 @@ module.exports = {
if(param.appeal) ban_embed.addFields({name : "Appeal id", value : "" + param.message.author.id})
let user = await param.message.client.users.cache.get(param.user.id);
let could_send = true
+ let could_ban = true
+ let could_del = true
+ embed.setTitle("Ban Confirmed, Awaiting User Cleanup");
+ mess.edit({embeds:[embed],components:[]})
try {
await user.send({embeds:[ban_embed]})
} catch (e) {
+ console.log(e)
could_send = false;
}
- await param.user.ban();
-
+ 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)
+ could_ban = false;
+ }
- embed.setTitle("Ban Confirmed" + (!could_send?" | Unable to Message":""));
+ embed.setTitle("Ban Confirmed" + (!could_send?" | Unable to Message":"") + (!could_ban?" | Unable to Ban":"") + (!could_del?" | Unable to Delete Msgs":""));
mess.edit({embeds:[embed],components:[]})
} else {
mess.edit({embeds:[embed]})
rec_read()
- confirmation.deferUpdate()
+ //confirmation.deferUpdate()
}
+ } else if(confirmation.customId == "cancel") {
+ embed.setFooter({text:"canceled"})
+ embed.setTitle("Ban Request Rejected")
+ embed.addFields({name:"Removed By Staff:",value:"<@!"+param.message.author.id+">", inline : true})
+ mess.edit({embeds:[embed],components:[]})
}
} catch (e) {
console.log(e)
@@ -110,4 +154,4 @@ module.exports = {
}
await rec_read();
}
-}; \ No newline at end of file
+};
diff --git a/commands/mod/defaults/add.js.json b/commands/mod/defaults/add.js.json
new file mode 100644
index 0000000..e11116a
--- /dev/null
+++ b/commands/mod/defaults/add.js.json
@@ -0,0 +1,2 @@
+{"cooldown":-1,"desc":"Add an element to sns-chan's message","restrict":[],"restricted":[],
+"usage":"{command}"} \ No newline at end of file
diff --git a/commands/mod/whois.js b/commands/mod/whois.js
index 6ffd8e6..48f3fdf 100644
--- a/commands/mod/whois.js
+++ b/commands/mod/whois.js
@@ -62,7 +62,11 @@ module.exports = {
this.p_role(client,Discord,interaction,role)
if(user!=null){
await interaction.guild.members.fetch()
+ let _user = user
user = interaction.guild.members.cache.get(user.id)
+ if(!user){
+ return interaction.reply({content:"<@"+_user.id+"> not found (have they left?)",ephemeral: true})
+ }
this.p_user(client,Discord,interaction,user)
}
},