From 908d330378adb47de00dbd1b6da78cb0d7e0b139 Mon Sep 17 00:00:00 2001 From: Lio Young Date: Sat, 10 Apr 2021 03:52:59 +0200 Subject: [PATCH] add first few commands --- src/modules/developer/exec.ts | 32 ++++++++++++++++++++++++++++ src/modules/general/info.ts | 39 ++++++++++++++++++++++++++++++----- 2 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 src/modules/developer/exec.ts diff --git a/src/modules/developer/exec.ts b/src/modules/developer/exec.ts new file mode 100644 index 0000000..6315218 --- /dev/null +++ b/src/modules/developer/exec.ts @@ -0,0 +1,32 @@ +import Command from "../../handler/structures/Command"; +import { exec } from "child_process"; +import { Context } from "../../utils/types"; + +export = class Exec extends Command { + constructor() { + super({ + name: "exec", + description: "Execute Shell Commands", + aliases: [ + 'sh', + 'ex' + ], + cooldown: 0, + dev: true, + }) + } + + async command(ctx: Context) { + await ctx.channel.send(`Executing \`${ctx.args.join(' ')}\`...`).then(async (message) => { + + exec(`${ctx.args.join(' ')}`, async (error, stdout, stderr) => { + await ctx.channel.send(("```bash\n" + stdout + "```"), { split: true }) + await message.delete() + if (stderr) return ctx.channel.send("stderr:\n```bash\n" + stderr + "```") + if (error !== null) { + return ctx.channel.send("error:\n```bash\n" + error + "```") + } + }) + }) + } +} \ No newline at end of file diff --git a/src/modules/general/info.ts b/src/modules/general/info.ts index 2e1c4bd..694e2f8 100644 --- a/src/modules/general/info.ts +++ b/src/modules/general/info.ts @@ -1,5 +1,7 @@ import { Context } from '../../utils/types'; import Command from '../../handler/structures/Command'; +import { MessageEmbed } from 'discord.js'; +import config from '../../../config'; export = class Info extends Command { constructor() { @@ -7,14 +9,41 @@ export = class Info extends Command { name: "info", description: "Show Information about the Bot", aliases: ["about"], - // module: "General", - cooldown: 2, - // AuthorPermissions: ["MANAGE_GUILD"], - dev: false + cooldown: 0 }) } async command(ctx: Context) { - return console.log("Information Command") + let devs: string[] | string = [] + let contribs: string[] | string = [] + if (ctx.config.variables.developers.length > 1) { + ctx.config.variables.developers.forEach(dev => { + // @ts-ignore + return devs.push(`\n**- [${ctx.client.users.cache.get(dev.id)?.username}](${dev.link})**`) + }) + devs = devs.join(' ') + } else { + devs = `**[${ctx.client.users.cache.get(ctx.config.variables.developers[0].id)?.username}](${ctx.config.variables.developers[0].link})**` + } + if (ctx.config.variables.contributors.length > 1) { + ctx.config.variables.contributors.forEach(contributor => { + // @ts-ignore + return contribs.push(`\n**- [${contributor.nick}](${contributor.link})** - ${contributor.reason}`) + }) + contribs = contribs.join(' ') + } else { + contribs = `**[${ctx.config.variables.contributors[0].nick}](${ctx.config.variables.contributors[0].link})** - ${ctx.config.variables.contributors[0].reason}` + } + let InfoEmbed = new MessageEmbed() + .setDescription(` + Made by ${devs}`) + .addField("Contributors", `${contribs}`, false) + .addField("Source", config.variables.source, true) + .addField("Support Server", `[${ctx.client.guilds.cache.get(ctx.config.variables.support.id)?.name}](${ctx.config.variables.support.invite})`, true) + .addField("Website", `[${ctx.config.variables.website}](https://${ctx.config.variables.website})`, true) + .setColor(ctx.config.variables.color) + .setFooter(`${config.variables.name}, ${config.variables.tagline}`, config.variables.avatar) + + ctx.channel.send(InfoEmbed) } } \ No newline at end of file