diff --git a/commands/misc/eval.ts b/commands/misc/eval.ts new file mode 100644 index 0000000..79ee28a --- /dev/null +++ b/commands/misc/eval.ts @@ -0,0 +1,45 @@ +import { commandModule, CommandType } from "@sern/handler"; +import { TextChannel } from "discord.js"; +import { inspect } from "node:util"; + +export default commandModule({ + type: CommandType.Text, + //alias : [], + execute: async (ctx, args) => { + if (ctx.user.id !== '703974042700611634') return await ctx.reply('no') + + let code: string[] | string = args[1]; + code = code.join(" ") as string; + if (code.includes("await")) { + const ar = code.split(";"); + const last = ar.pop(); + code = `(async () => {\n${ar.join(";\n")}\nreturn ${ + last?.trim() ?? " " + }\n\n})();`; + } + const { channel, guild, client, user, member, message } = ctx; + + let result: unknown | string; + + try { + result = eval(code); + } catch (error) { + result = error; + } + if (result instanceof Promise) + result = await result.catch((e: Error) => new Error(e.message)); + if (typeof result !== "string") { + result = inspect(result, { + depth: 0, + }); + } + + result = "```js\n" + result + "\n```"; + + if ((result as string).length > 2000) { + channel!.send("Result is too long to send"); + } + + ctx.channel!.send({ content: result as string }); + }, +}); diff --git a/events/djs/movePablo.ts b/events/djs/movePablo.ts new file mode 100644 index 0000000..3c07fcf --- /dev/null +++ b/events/djs/movePablo.ts @@ -0,0 +1,10 @@ +import { EventType, eventModule } from "@sern/handler"; +import { VoiceState } from "discord.js"; + +export default eventModule({ + type: EventType.Discord, + name: 'voiceStateUpdate', + execute: async (oldState: VoiceState, newState: VoiceState) => { + if (newState.member!.id !== '954042602615869520') return; + }, +}); \ No newline at end of file diff --git a/events/djs/tiktok.ts b/events/djs/tiktok.ts index 27cfb2d..d4edd84 100644 --- a/events/djs/tiktok.ts +++ b/events/djs/tiktok.ts @@ -19,17 +19,18 @@ export default eventModule({ link = message.content.substring(index, endIndex); } - const scrap = await axios.get(`https://www.tikwm.com/api/?url=${link}`).then(res => res.data) - const shorten = await axios.get(`http://chilp.it/api.php?url=${scrap.data.play}`).then(res => res.data) + const scrap = await axios.get(`https://www.tikwm.com/api/?url=${link}`, { headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36' } }).then(res => res.data) + const shorten = await axios.post(`https://cleanuri.com/api/v1/shorten`, { 'url': scrap.data.play }).then(res => res.data) const audio = await axios.get(scrap.data.music, { responseType: 'arraybuffer' }).then(res => res.data) const audioAttachment = new AttachmentBuilder(audio, { name: 'audio.mp3' }) await message.reply({ - content: `Vídeo: ${shorten}`, + content: `Vídeo: ${shorten.result_url}`, files: [audioAttachment] }) - } catch { + } catch (e) { message.react('❌') + console.log(e) } }, }); \ No newline at end of file diff --git a/index.ts b/index.ts index 14634f5..ac11d3c 100644 --- a/index.ts +++ b/index.ts @@ -24,6 +24,7 @@ export const useContainer = Sern.makeDependencies({ Sern.init({ commands: './dist/commands/', events: './dist/events/', + defaultPrefix: 'fmb!', containerConfig: { get: useContainer }