chore!: make cmds ONLY for me

This commit is contained in:
Saahil 2024-09-08 20:52:19 -04:00
parent 1312263c7f
commit f65fb28c66
No known key found for this signature in database
GPG key ID: 8A8B64515254CFC6
4 changed files with 11 additions and 3 deletions

View file

@ -1,5 +1,5 @@
import { App } from "@slack/bolt";
import { Command } from "../modules/BaseCommand";
import { Command, onlyForMe } from "../modules/BaseCommand";
export default class Ping implements Command {
name: string;
@ -11,6 +11,8 @@ this.description = `Pings zeon`
run(app: App) {
// app.command()
app.command('/ping',async ({ command, ack, respond }) => {
if(!onlyForMe(command.user_id)) return respond(`:x: You cannot use this command.`)
const stamp = Date.now()
await ack()
respond(`Pong took: \`${Date.now() - stamp}ms\``).then(d => {

View file

@ -8,6 +8,7 @@ import path from "path"
app.start(process.env.PORT || 3000).then((d) => {
console.log(`App is UP (please help)`)
})
// app.client.cha
const cmdLoader = new Loader(app, path.join(__dirname, 'commands'))
// this is temp i swear
cmdLoader.runQuery()

View file

@ -10,3 +10,10 @@ export interface Command {
[k: string]: any
}
}
export function onlyForMe(user: string):boolean {
if(user === process.env.MY_USER_ID) {
return true;
} else {
return false;
}
}

View file

@ -36,12 +36,10 @@ const files = this.getFiles()
for (const file of files) {
try {
const commandClass = await import(path.join(this.dir, file))
console.log(commandClass)
const cmd = new commandClass.default()
cmd.run(this._app)
} catch (e) {
console.error(e)
console.error(`Failed to load ${file}`)
}