2020-12-10 09:10:00 +00:00
|
|
|
import { Client, Intents, event, slash } from '../../mod.ts'
|
2020-12-10 08:19:43 +00:00
|
|
|
import { Embed } from '../structures/embed.ts'
|
2020-12-10 09:10:00 +00:00
|
|
|
import { Interaction } from '../structures/slash.ts'
|
2020-12-10 04:36:36 +00:00
|
|
|
import { TOKEN } from './config.ts'
|
|
|
|
|
2020-12-10 09:10:00 +00:00
|
|
|
export class MyClient extends Client {
|
|
|
|
@event()
|
|
|
|
ready(): void {
|
|
|
|
console.log(`Logged in as ${this.user?.tag}!`)
|
|
|
|
}
|
2020-12-10 04:36:36 +00:00
|
|
|
|
2021-01-07 13:46:56 +00:00
|
|
|
@event('debug')
|
|
|
|
debugEvt(txt: string): void {
|
|
|
|
console.log(txt)
|
|
|
|
}
|
|
|
|
|
2020-12-10 09:10:00 +00:00
|
|
|
@slash()
|
|
|
|
send(d: Interaction): void {
|
|
|
|
d.respond({
|
2020-12-16 10:42:52 +00:00
|
|
|
content: d.data.options?.find((e) => e.name === 'content')?.value
|
2020-12-10 09:10:00 +00:00
|
|
|
})
|
|
|
|
}
|
2020-12-10 04:36:36 +00:00
|
|
|
|
2020-12-10 09:10:00 +00:00
|
|
|
@slash()
|
|
|
|
async eval(d: Interaction): Promise<void> {
|
2020-12-10 10:42:03 +00:00
|
|
|
if (
|
|
|
|
d.user.id !== '422957901716652033' &&
|
|
|
|
d.user.id !== '682849186227552266'
|
|
|
|
) {
|
2020-12-10 06:55:52 +00:00
|
|
|
d.respond({
|
|
|
|
content: 'This command can only be used by owner!'
|
|
|
|
})
|
|
|
|
} else {
|
2020-12-16 10:42:52 +00:00
|
|
|
const code = d.data.options?.find((e) => e.name === 'code')
|
2020-12-10 06:55:52 +00:00
|
|
|
?.value as string
|
|
|
|
try {
|
|
|
|
// eslint-disable-next-line no-eval
|
|
|
|
let evaled = eval(code)
|
|
|
|
if (evaled instanceof Promise) evaled = await evaled
|
|
|
|
if (typeof evaled === 'object') evaled = Deno.inspect(evaled)
|
|
|
|
let res = `${evaled}`.substring(0, 1990)
|
|
|
|
while (client.token !== undefined && res.includes(client.token)) {
|
|
|
|
res = res.replace(client.token, '[REMOVED]')
|
|
|
|
}
|
|
|
|
d.respond({
|
|
|
|
content: '```js\n' + `${res}` + '\n```'
|
2020-12-10 08:19:43 +00:00
|
|
|
}).catch(() => {})
|
2020-12-10 06:55:52 +00:00
|
|
|
} catch (e) {
|
|
|
|
d.respond({
|
|
|
|
content: '```js\n' + `${e.stack}` + '\n```'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-12-10 09:10:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@slash()
|
|
|
|
async hug(d: Interaction): Promise<void> {
|
2020-12-16 10:42:52 +00:00
|
|
|
const id = d.data.options?.find((e) => e.name === 'user')?.value as string
|
2020-12-10 08:19:43 +00:00
|
|
|
const user = (await client.users.get(id)) ?? (await client.users.fetch(id))
|
|
|
|
const url = await fetch('https://nekos.life/api/v2/img/hug')
|
|
|
|
.then((r) => r.json())
|
|
|
|
.then((e) => e.url)
|
|
|
|
|
|
|
|
d.respond({
|
|
|
|
embeds: [
|
|
|
|
new Embed()
|
|
|
|
.setTitle(`${d.user.username} hugged ${user?.username}!`)
|
|
|
|
.setImage({ url })
|
|
|
|
.setColor(0x2f3136)
|
|
|
|
]
|
|
|
|
})
|
2020-12-10 06:55:52 +00:00
|
|
|
}
|
2020-12-10 10:42:03 +00:00
|
|
|
|
|
|
|
@slash()
|
|
|
|
async kiss(d: Interaction): Promise<void> {
|
2020-12-16 10:42:52 +00:00
|
|
|
const id = d.data.options?.find((e) => e.name === 'user')?.value as string
|
2020-12-10 10:42:03 +00:00
|
|
|
const user = (await client.users.get(id)) ?? (await client.users.fetch(id))
|
|
|
|
const url = await fetch('https://nekos.life/api/v2/img/kiss')
|
|
|
|
.then((r) => r.json())
|
|
|
|
.then((e) => e.url)
|
|
|
|
|
|
|
|
d.respond({
|
|
|
|
embeds: [
|
|
|
|
new Embed()
|
|
|
|
.setTitle(`${d.user.username} kissed ${user?.username}!`)
|
|
|
|
.setImage({ url })
|
|
|
|
.setColor(0x2f3136)
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
@slash('ping')
|
|
|
|
pingCmd(d: Interaction): void {
|
|
|
|
d.respond({
|
|
|
|
content: `Pong!`
|
|
|
|
})
|
|
|
|
}
|
2020-12-10 09:10:00 +00:00
|
|
|
}
|
2020-12-10 04:36:36 +00:00
|
|
|
|
2021-01-07 13:46:56 +00:00
|
|
|
const client = new MyClient({
|
|
|
|
presence: {
|
|
|
|
status: 'dnd',
|
|
|
|
activity: { name: 'Slash Commands', type: 'LISTENING' }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-12-10 04:36:36 +00:00
|
|
|
client.connect(TOKEN, Intents.None)
|