Add bonk command

This commit is contained in:
Helixu 2021-11-22 22:42:39 +00:00
parent e599080b39
commit 385b2a2bba
5 changed files with 137 additions and 3 deletions

View file

@ -1,3 +1,3 @@
{ {
"devlist": ["831598877320413244"] "devlist": ["831598877320413244", "287885666941927424"]
} }

View file

@ -1,6 +1,7 @@
const dc = require("discord.js"); const dc = require("discord.js");
const client = new dc.Client({intents: ["GUILDS"]}); const client = new dc.Client({intents: ["GUILDS"]});
const fs = require("fs"); const fs = require("fs");
client.login(JSON.parse(fs.readFileSync("token.json").toString())["token"]); client.login(JSON.parse(fs.readFileSync("token.json").toString())["token"]);
function readJson(path){ function readJson(path){
@ -12,7 +13,11 @@ function writeJson(path, content){
} }
function getUserCount(){ function getUserCount(){
return 69420; var memCount = 0;
client.guilds.cache.forEach(guild => {
memCount += guild.memberCount;
});
return memCount;
} }
var int; var int;
@ -20,7 +25,6 @@ function startLoop(){
try { try {
clearInterval(int); clearInterval(int);
int = setInterval(()=>{ int = setInterval(()=>{
//console.log("Ayup");
client.user.setActivity("over " + getUserCount() + " people", {type: "WATCHING"}); client.user.setActivity("over " + getUserCount() + " people", {type: "WATCHING"});
},5000); },5000);
} catch(e){console.log(e)} } catch(e){console.log(e)}
@ -68,6 +72,36 @@ client.on("ready", () => {
type: 3 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 => { ]).then(cmds => {
console.log("Finished loading all commands"); console.log("Finished loading all commands");
@ -97,6 +131,13 @@ client.on("interactionCreate", (int) => {
} catch(e){ } catch(e){
int.reply(e.stack).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!");
} }
} }
}); });

78
index.js.save Normal file
View file

@ -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.");
}
}
}
});

11
led.py Normal file
View file

@ -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()

4
start Executable file
View file

@ -0,0 +1,4 @@
while [ true ]
do
node .
done