aboutsummaryrefslogtreecommitdiff
path: root/commands/util
diff options
context:
space:
mode:
authorame <[email protected]>2023-09-26 23:12:35 -0500
committerame <[email protected]>2023-09-26 23:12:35 -0500
commitadc05627661e4b229037dc1e43410846078f4996 (patch)
tree8bbd7d34085007e36207f8e8c5976b7de64a7b3b /commands/util
init
Diffstat (limited to 'commands/util')
-rw-r--r--commands/util/defaults/emote.js.json45
-rw-r--r--commands/util/defaults/help.js.json2
-rw-r--r--commands/util/defaults/poll.js.json2
-rw-r--r--commands/util/defaults/say.js.json2
-rw-r--r--commands/util/defaults/status.js.json2
-rw-r--r--commands/util/emote.js47
-rw-r--r--commands/util/help.js140
-rw-r--r--commands/util/poll.js61
-rw-r--r--commands/util/say.js36
-rw-r--r--commands/util/status.js63
10 files changed, 400 insertions, 0 deletions
diff --git a/commands/util/defaults/emote.js.json b/commands/util/defaults/emote.js.json
new file mode 100644
index 0000000..9dd461b
--- /dev/null
+++ b/commands/util/defaults/emote.js.json
@@ -0,0 +1,45 @@
+{"avaliable_multi":{"value":{
+ "hug":"hugged",
+ "bite":"bit",
+ "boop":"booped",
+ "bonk":"bonked",
+ "cuddle":"cuddled",
+ "dance":"danced with",
+ "feed":"fed",
+ "handhold":"held hands with",
+ "highfive":"highfived",
+ "kiss":"kissed",
+ "lick":"licked",
+ "love":"loved",
+ "nom":"nommed",
+ "nuzzle":"nuzzled",
+ "pat":"pat",
+ "poke":"poked",
+ "punch":"punched",
+ "slap":"slapped",
+ "stare":"stared down",
+ "throw":"threw",
+ "tickle":"tickled"
+}},"avaliable_solo":{"value":{
+ "bath":"bathed",
+ "boom":"exploded",
+ "blush":"blushed",
+ "clap":"clapped",
+ "cookie":"had a cookie",
+ "cringe":"cringed",
+ "cry":"cried",
+ "dab":"dabbed",
+ "facepalm":"facepalmed",
+ "grin":"grinned",
+ "laugh":"laughed",
+ "lurk":"lurked",
+ "panic":"panicked",
+ "pout":"pouted",
+ "sip":"sipped",
+ "think":"thought",
+ "run":"ran",
+ "triggered":"triggered",
+ "wag":"wagged",
+ "wink":"winked"
+}},"cooldown":3600,"desc":"Sends a gif","restrict":[],"restricted":[],
+"usage":"{command} [user]"} \ No newline at end of file
diff --git a/commands/util/defaults/help.js.json b/commands/util/defaults/help.js.json
new file mode 100644
index 0000000..8908911
--- /dev/null
+++ b/commands/util/defaults/help.js.json
@@ -0,0 +1,2 @@
+{"cooldown":3,"desc":"Lists commands and info on them!","restrict":["695872127487967233"],"restricted":[],
+"usage":"{command} [command]"} \ No newline at end of file
diff --git a/commands/util/defaults/poll.js.json b/commands/util/defaults/poll.js.json
new file mode 100644
index 0000000..b45d084
--- /dev/null
+++ b/commands/util/defaults/poll.js.json
@@ -0,0 +1,2 @@
+{"cooldown":3,"desc":"Create a poll","restrict":[],"restricted":[],
+"usage":"{command} {title} [option,.. (up to 10)]"} \ No newline at end of file
diff --git a/commands/util/defaults/say.js.json b/commands/util/defaults/say.js.json
new file mode 100644
index 0000000..4247fd2
--- /dev/null
+++ b/commands/util/defaults/say.js.json
@@ -0,0 +1,2 @@
+{"cooldown":-1,"desc":"Make me say something","restrict":[],"restricted":[],
+"usage":"{command} [channel] {message}"} \ No newline at end of file
diff --git a/commands/util/defaults/status.js.json b/commands/util/defaults/status.js.json
new file mode 100644
index 0000000..53080f3
--- /dev/null
+++ b/commands/util/defaults/status.js.json
@@ -0,0 +1,2 @@
+{"cooldown":3,"desc":"Lists server status for snschan","restrict":[],"restricted":[],
+"usage":"{command}"} \ No newline at end of file
diff --git a/commands/util/emote.js b/commands/util/emote.js
new file mode 100644
index 0000000..b06bbef
--- /dev/null
+++ b/commands/util/emote.js
@@ -0,0 +1,47 @@
+const fs = require('fs')
+const path = require("path");
+const WeebyAPI = require("weeby-js");
+let settings = require("../../src/settings")
+const { EmbedBuilder } = require("discord.js");
+let config_loc = __filename+".json"
+let config = JSON.parse(fs.readFileSync(config_loc))
+let subs = [...Object.keys(config.avaliable_solo.value),...Object.keys(config.avaliable_multi.value)]
+module.exports = {
+ name : "emote",
+ command: subs,
+ mod_only: false,
+ config:config,
+ config_loc:config_loc,
+ async main (client,Discord,message,args,call){
+ let mentioned = message.mentions.users.first();
+ this.exec(client,{message:message,emote:call,mentioned:mentioned})
+ },
+ s_options:[{type:"string",name:"emote",desc:"emote to send",required:true,autocomplete:subs},
+ {type:"user",name:"user",desc:"user to emote to (may be optional)",required:false,autocomplete:false}],
+ async s_main (client,Discord,interaction){
+ this.exec(client,{message:interaction,emote:interaction.options.getString("emote"),mentioned:interaction.options.getUser("user")})
+ },
+ async exec(client,param){
+ let msg = "";
+ if(Object.keys(config.avaliable_multi.value).includes(param.emote)){
+ //let user = await client.users.fetch(userc.id).catch(() => null);
+ if(!param.mentioned)
+ return param.message.reply({content:"please mention someone", ephemeral: true})
+ if(param.mentioned.id==param.message.author.id)
+ msg="<@"+param.message.author.id+"> "+config.avaliable_multi.value[param.emote]+" themselves"
+ else if(param.mentioned.id=="762561860150362142")
+ msg="<@"+param.message.author.id+"> "+config.avaliable_multi.value[param.emote]+" me!"
+ else
+ msg="<@"+param.message.author.id+"> "+config.avaliable_multi.value[param.emote]+" <@"+param.mentioned+">"
+ } else {
+ msg="<@"+param.message.author.id+"> "+config.avaliable_solo.value[param.emote]
+ }
+ const weeby = new WeebyAPI(client.env.WEEBY_TOKEN);
+ let gif = await weeby.gif.fetch(param.emote);
+ let emoteembed = new EmbedBuilder()
+ .setDescription(msg)
+ .setImage(gif)
+ .setColor(settings.defaultColor)
+ param.message.reply({embeds:[emoteembed]})
+ }
+} \ No newline at end of file
diff --git a/commands/util/help.js b/commands/util/help.js
new file mode 100644
index 0000000..b52ee12
--- /dev/null
+++ b/commands/util/help.js
@@ -0,0 +1,140 @@
+const fs = require('fs')
+const path = require("path");
+const { EmbedBuilder,ActionRowBuilder,ButtonBuilder,ButtonStyle } = require("discord.js");
+let config_loc = __filename+".json"
+let settings = require("../../src/settings")
+let config = JSON.parse(fs.readFileSync(config_loc))
+
+//get command names
+let command_names = ["help"]
+fs.readdirSync(path.join(__dirname+"/..")).forEach(folder => {
+ fs.readdirSync(path.join(__dirname+"/../"+folder)).forEach(file => {
+ if(path.extname(file)==".js"){
+ if(path.join(__dirname+"/../"+folder+"/"+file)!=__filename){
+ let info = require("../"+folder+"/"+file)
+ //let commands = info.command.length>3?info.command.slice(0,3).join(",")+"...":info.command.join(",")
+ command_names.push(info.name)
+ }
+
+ }
+ })
+})
+//
+
+module.exports = {
+ name : "help",
+ command: ["help"],
+ mod_only: false,
+ config:config,
+ config_loc:config_loc,
+ async main (client,Discord,message,args){
+ this.exec(client,{message:message,specify:args[0]})
+ },
+ s_options:[{type:"string",name:"command",desc:"command to be specified",required:false,autocomplete:command_names}],
+ async s_main(client,Discord,interaction){
+ this.exec(client,{message:interaction,specify:interaction.options.getString("command")})
+ },
+ async exec(client,param){
+ if(param.specify!=null){
+ let info = null
+ fs.readdirSync(path.join(__dirname+"/..")).forEach(folder => {
+ fs.readdirSync(path.join(__dirname+"/../"+folder)).forEach(file => {
+ if(path.extname(file)==".js"){
+ let tinfo = require("../"+folder+"/"+file)
+ if(tinfo.name==param.specify||tinfo.command.includes(param.specify))
+ info=tinfo
+ }
+ })
+ })
+ if(info==null)
+ return param.message.reply({content:"command not found:c",ephemeral: true})
+ let restricted = info.config.restricted.length==0?"undefined":info.config.restricted.join(",")
+ let restrict = info.config.restrict.length==0?"undefined":info.config.restrict.join(",")
+ const embed = new EmbedBuilder()
+ .setTitle(info.name)
+ .setColor(settings.defaultColor)
+ .addFields([{
+ name:"commands/subcommands",
+ value:info.command.join(",")
+ },{
+ name:"description",
+ value: info.config.desc == undefined ? "undefined" : info.config.desc
+ },{
+ name:"usage",
+ value: info.config.usage == undefined ? "undefined" : info.config.usage
+ },{
+ name:"misc",
+ value:"cooldown: "+info.config.cooldown+", restricted channels: ["+restricted+"], restrict to channels: ["+restrict+"], "+(info.s_main!=null?"supports slash commands":"does not support slash commands")
+ }])
+ param.message.reply({embeds:[embed]})
+ return
+ }
+ //message.reply("not done yet:( give ans-chan some hugs and headpats for faster development")
+ let pages = []
+ let page = 0
+ fs.readdirSync(path.join(__dirname+"/..")).forEach(folder => {
+ const embed = new EmbedBuilder()
+ .setTitle(folder)
+ .setColor(settings.defaultColor)
+ let count = 0;
+ fs.readdirSync(path.join(__dirname+"/../"+folder)).forEach(file => {
+ if(path.extname(file)==".js"){
+ count++;
+ let info = require("../"+folder+"/"+file)
+ let commands = info.command.length>3?info.command.slice(0,3).join(",")+"...":info.command.join(",")
+ embed.addFields([{
+ name:info.name + " [" + commands + "]",
+ value:info.config.desc
+ }])
+ /*page.push({
+ name:info.name,
+ subcommands:info.command,
+ desc:info.desc,
+ cooldown:cooldown
+ })*/
+
+ }
+ })
+ embed.setFooter({text:"use `sns help {command}` to get more info • "+count+" items"})
+ pages.push(embed)
+ })
+ const last = new ButtonBuilder()
+ .setCustomId('last')
+ .setEmoji('⬅️')
+ .setStyle(ButtonStyle.Primary)
+ const next = new ButtonBuilder()
+ .setCustomId('next')
+ .setEmoji('➡️')
+ .setStyle(ButtonStyle.Primary)
+ const row = new ActionRowBuilder()
+ .addComponents(last,next);
+ let mess = await param.message.reply({embeds:[pages[page]],components:[row]})
+ async function rec_edit(mess,page){
+ const collectorFilter = i => i.user.id === param.message.author.id;
+ try {
+ const confirmation = await mess.awaitMessageComponent({ filter: collectorFilter, time: 60000000 });
+ if(confirmation.customId == "next"){
+ if(page+1<pages.length)
+ page++;
+ else
+ page=0;
+ mess.edit({embeds:[pages[page]]})
+ rec_edit(mess,page)
+ confirmation.deferUpdate()
+ }
+ if(confirmation.customId == "last"){
+ if(page-1>=0)
+ page--;
+ else
+ page=pages.length-1;
+ mess.edit({embeds:[pages[page]]})
+ rec_edit(mess,page)
+ confirmation.deferUpdate()
+ }
+ } catch (e) {
+
+ }
+ }
+ await rec_edit(mess,page)
+ }
+} \ No newline at end of file
diff --git a/commands/util/poll.js b/commands/util/poll.js
new file mode 100644
index 0000000..39d4e92
--- /dev/null
+++ b/commands/util/poll.js
@@ -0,0 +1,61 @@
+const fs = require('fs')
+const path = require("path");
+let config_loc = __filename+".json"
+const { PermissionsBitField, EmbedBuilder } = require('discord.js');
+let config = JSON.parse(fs.readFileSync(config_loc))
+const numbers = ["1️⃣" ,"2️⃣", "3️⃣" ,"4️⃣" ,"5️⃣", "6️⃣", "7️⃣", "8️⃣" ,"9️⃣" ,"🔟"]
+let settings = require("../../src/settings")
+module.exports = {
+ name : "poll",
+ command: ["poll"],
+ mod_only: true,
+ config:config,
+ config_loc:config_loc,
+ async main (client,Discord,message,args){
+ let title = args[0];
+ args.shift();
+ if(args.length>10)return message.reply("too many options")
+ this.exec(client,{message:message,title:title,options:args})
+ },
+ s_options:[{type:"string",name:"title",desc:"title of poll",required:true,autocomplete:false},
+ {type:"string",name:"option-1",desc:"poll option",required:true,autocomplete:false},
+ {type:"string",name:"option-2",desc:"poll option",required:false,autocomplete:false},
+ {type:"string",name:"option-3",desc:"poll option",required:false,autocomplete:false},
+ {type:"string",name:"option-4",desc:"poll option",required:false,autocomplete:false},
+ {type:"string",name:"option-5",desc:"poll option",required:false,autocomplete:false},
+ {type:"string",name:"option-6",desc:"poll option",required:false,autocomplete:false},
+ {type:"string",name:"option-7",desc:"poll option",required:false,autocomplete:false},
+ {type:"string",name:"option-8",desc:"poll option",required:false,autocomplete:false},
+ {type:"string",name:"option-9",desc:"poll option",required:false,autocomplete:false},
+ {type:"string",name:"option-10",desc:"poll option",required:false,autocomplete:false},],
+ async s_main (client,Discord,interaction){
+ this.exec(client,
+ {message:interaction,options:[
+ interaction.options.getString("option-1"),
+ interaction.options.getString("option-2") ,
+ interaction.options.getString("option-3") ,
+ interaction.options.getString("option-4") ,
+ interaction.options.getString("option-5") ,
+ interaction.options.getString("option-6") ,
+ interaction.options.getString("option-7") ,
+ interaction.options.getString("option-8") ,
+ interaction.options.getString("option-9") ,
+ interaction.options.getString("option-10") ,
+ ].filter(n => n),title:interaction.options.getString("title")})
+ },
+ async exec(client,info){
+ let embed = new EmbedBuilder()
+ .setTitle(info.title)
+ let desc = "";
+ for(let a in info.options){
+ desc+=numbers[a]+" "+info.options[a]+"\n";
+ }
+ embed.setDescription(desc)
+ .setColor(settings.defaultColor)
+ .setFooter({text: 'poll:'+info.options.length+' | '+info.message.author.username})
+ let m = await info.message.reply({embeds:[embed],fetchReply: true })
+ for(let a in info.options){
+ m.react(numbers[a])
+ }
+ }
+} \ No newline at end of file
diff --git a/commands/util/say.js b/commands/util/say.js
new file mode 100644
index 0000000..17af382
--- /dev/null
+++ b/commands/util/say.js
@@ -0,0 +1,36 @@
+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))
+module.exports = {
+ name : "say",
+ command: ["say"],
+ mod_only: true,
+ config:config,
+ config_loc:config_loc,
+ async main (client,Discord,message,args){
+ let id = message.mentions.channels.first()
+ let echo = message.content.slice(8)
+ if(id){
+ echo = echo.split(/ +/g);
+ echo.shift();
+ echo = echo.join(' ')
+ } else {
+ id = message.channel
+ }
+ this.exec(client,{id:id,echo:echo})
+ },
+ s_options:[{type:"string",name:"echo",desc:"message to be said",required:true,autocomplete:false},
+ {type:"channel",name:"channel",desc:"channel to be sent to",required:false,autocomplete:false}],
+ async s_main (client,Discord,interaction){
+ this.exec(client,
+ {echo:interaction.options.getString("echo"),
+ id:interaction.options.getChannel("channel") ?? interaction.channel})
+ await interaction.reply({ content:'sent', ephemeral: true })
+ interaction.deleteReply()
+ },
+ async exec(client,info){
+ return info.id.send(info.echo)
+ }
+} \ No newline at end of file
diff --git a/commands/util/status.js b/commands/util/status.js
new file mode 100644
index 0000000..27f1e03
--- /dev/null
+++ b/commands/util/status.js
@@ -0,0 +1,63 @@
+const fs = require('fs')
+const path = require("path");
+let settings = require("../../src/settings")
+let {limit_exp} = require("../../src/util")
+const { EmbedBuilder,ActionRowBuilder,ButtonBuilder,ButtonStyle } = require("discord.js");
+const {getLastCommit} = require("git-last-commit")
+var os = require('os');
+let config_loc = __filename+".json"
+let config = JSON.parse(fs.readFileSync(config_loc))
+module.exports = {
+ name : "status",
+ command: ["status","server","uptime","vote","twitter","𝕏"],
+ mod_only: false,
+ config:config,
+ config_loc:config_loc,
+ async main (client,Discord,message,args){
+ this.exec(client,message)
+ },
+ async s_main (client,Discord,interaction){
+ this.exec(client,interaction)
+ },
+ async exec(client,message){
+ getLastCommit((err,commit)=>{
+ let seconds = Math.floor(message.client.uptime / 1000);
+ let minutes = Math.floor(seconds / 60);
+ let hours = Math.floor(minutes / 60);
+ let days = Math.floor(hours / 24);
+ let uptime = "online for: ";
+ if(days>0)uptime+=days+" days"
+ else if(hours>0)uptime+=hours+"h"
+ else if(minutes>0)uptime+=minutes+"m"
+ else uptime+=seconds+"s"
+ uptime+=" | "+limit_exp((message.client.uptime*1000).toExponential(),2)+"μs"
+ const vote = new ButtonBuilder()
+ .setLabel('Vote')
+ .setStyle(ButtonStyle.Link)
+ .setURL('https://top.gg/servers/486957006628847626/vote')
+ /*const twitter = new ButtonBuilder() //0% chance i will call this 𝕏
+ .setLabel('Twitter')
+ .setStyle(ButtonStyle.Link)
+ .setURL('https://twitter.com/sns_chan')*/
+ const discord = new ButtonBuilder()
+ .setLabel('Discord')
+ .setStyle(ButtonStyle.Link)
+ .setURL('https://discord.gg/supernoobs')
+ const github = new ButtonBuilder()
+ .setLabel('Github')
+ .setStyle(ButtonStyle.Link)
+ .setURL('https://github.com/iamAGFX/snschan-bot')
+ const row = new ActionRowBuilder()
+ .addComponents(vote,discord,github);
+ let conv = 1024 * 1024 * 1024
+ let sys = "system: cpus: "+os.cpus().length+", ram (free): "+Math.floor(os.freemem()/conv)+"/"+Math.floor(os.totalmem()/conv)+"gb\nkernel: "+os.release()
+ let emoteembed = new EmbedBuilder()
+ .setThumbnail(client.user.displayAvatarURL())
+ .setTitle("Server info")
+ .setDescription(uptime+"\n"+sys)
+ .setColor(settings.defaultColor)
+ .setFooter({text:"running "+commit.shortHash+" ("+commit.branch+")"})
+ message.reply({embeds:[emoteembed],components:[row]})
+ })
+ }
+} \ No newline at end of file