mirror of
https://github.com/System-End/slack-end.git
synced 2026-04-19 22:05:10 +00:00
chore!: make cmds ONLY for me
This commit is contained in:
parent
1312263c7f
commit
f65fb28c66
4 changed files with 11 additions and 3 deletions
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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}`)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue