From 385b2a2bba91f3134a042bac510df79fef722e2b Mon Sep 17 00:00:00 2001 From: Helixu Date: Mon, 22 Nov 2021 22:42:39 +0000 Subject: [PATCH] Add bonk command --- devs.json | 2 +- index.js | 45 +++++++++++++++++++++++++++-- index.js.save | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ led.py | 11 ++++++++ start | 4 +++ 5 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 index.js.save create mode 100644 led.py create mode 100755 start diff --git a/devs.json b/devs.json index d19652b..010b914 100644 --- a/devs.json +++ b/devs.json @@ -1,3 +1,3 @@ { - "devlist": ["831598877320413244"] + "devlist": ["831598877320413244", "287885666941927424"] } diff --git a/index.js b/index.js index aeea96d..a49a810 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const dc = require("discord.js"); const client = new dc.Client({intents: ["GUILDS"]}); const fs = require("fs"); + client.login(JSON.parse(fs.readFileSync("token.json").toString())["token"]); function readJson(path){ @@ -12,7 +13,11 @@ function writeJson(path, content){ } function getUserCount(){ - return 69420; + var memCount = 0; + client.guilds.cache.forEach(guild => { + memCount += guild.memberCount; + }); + return memCount; } var int; @@ -20,7 +25,6 @@ function startLoop(){ try { clearInterval(int); int = setInterval(()=>{ - //console.log("Ayup"); client.user.setActivity("over " + getUserCount() + " people", {type: "WATCHING"}); },5000); } catch(e){console.log(e)} @@ -68,6 +72,36 @@ client.on("ready", () => { type: 3 } ] + }, + { + name: "kick", + description: "Kick members.", + options: [ + { + name: "user", + description: "User to kick", + type: 6, + required: true + }, + { + name: "reason", + description: "Reason to kick them", + type: 3, + required: false + } + ] + }, + { + name: "bonk", + description: "Bonks someone", + options: [ + { + name: "user", + description: "Whomst to bonk", + type: 6, + required: true + } + ] } ]).then(cmds => { console.log("Finished loading all commands"); @@ -97,6 +131,13 @@ client.on("interactionCreate", (int) => { } catch(e){ int.reply(e.stack).catch(e => {}); }; + } else if(int.commandName == "kick"){ + var mem = int.guild.members.cache.get(int.user.id); + if(!mem.permissions.has("KICK_MEMBERS")) return int.reply("You tried kicking without perms? You're sus"); + var mem2 = int.guild.members.cache.get(int.options.getUser("user").id); + mem2.kick(int.options.getString("reason")); + } else if(int.commandName == "bonk"){ + int.reply("<@!" + int.options.getUser("user").id + "> BONK!"); } } }); diff --git a/index.js.save b/index.js.save new file mode 100644 index 0000000..dbd5aa9 --- /dev/null +++ b/index.js.save @@ -0,0 +1,78 @@ +const dc = require("discord.js"); +const client = new dc.Client({intents: ["GUILDS"]}); +const fs = require("fs"); +client.login(JSON.parse(fs.readFileSync("token.json").toString())["token"]); + +function readJson(path){ + return JSON.parse(fs.readFileSync(path).toString()); +} + +function writeJson(path, content){ + fs.writeFileSync(path, JSON.stringify(content)); +} + +var inter; +function startLoop(){ + try { + clearInterval(int); + console + inter = setInterval(()=>{ + client.user.setActivity("over " + client.users.cache.length, {type: "WATCHING"}); + },5000); + } catch(e){} +} + +function stopLoop(){ + try { + clearInterval(int); + } catch(e){} +} + +client.on("ready", () => { + console.log("I'm alive"); + client.guilds.cache.get("879081086817288264").commands.set([ + { + name: "ping", + description: "Am alive???" + }, + { + name: "activity", + description: "Sets funny activity", + options: [ + { + name: "type", + description: "The type, for example playing or watching or listening or streaming or competing.", + type: 3, + required: true + }, + { + name: "activity", + description: "What you want it to say", + type: 3, + required: false + } + ] + } + ]).then(cmds => { + console.log("Finished loading all commands"); + }); +}); + +client.on("interactionCreate", (int) => { + if(int.isCommand()){ + if(int.commandName == "ping"){ + int.reply(`Yup, I'm alive (${client.ws.ping} ms)`); + } else if(int.commandName == "activity"){ + var devs = readJson("devs.json"); + if(!devs.devlist.includes(int.user.id)) return int.reply("You shall not pass"); + if(int.options.getString("activity") !== null){ + stopLoop(); + client.user.setActivity(int.options.getString("activity"), {type: int.options.getString("type")}); + int.reply("Stopped activity loop, and switched to custom set status."); + } else { + startLoop(); + int.reply("Resat activity, and started activity loop."); + } + } + } +}); diff --git a/led.py b/led.py new file mode 100644 index 0000000..1539a43 --- /dev/null +++ b/led.py @@ -0,0 +1,11 @@ +import RPi.GPIO as GPIO +import time +GPIO.setmode(GPIO.BOARD) +GPIO.setup(7, GPIO.OUT) +# loop through 50 times, on/off for 1 second +for i in range(50): + GPIO.output(7,True) + time.sleep(1) + GPIO.output(7,False) + time.sleep(1) +GPIO.cleanup() diff --git a/start b/start new file mode 100755 index 0000000..14b5991 --- /dev/null +++ b/start @@ -0,0 +1,4 @@ +while [ true ] +do + node . +done