From ee717986965f2a1cdfa6f1362fb2f0f3753afa6f Mon Sep 17 00:00:00 2001 From: Toast <96593068+AnxietyisReal@users.noreply.github.com> Date: Sat, 12 Aug 2023 18:17:51 +1000 Subject: [PATCH] Add wake_device command --- src/commands/dev.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/commands/dev.ts b/src/commands/dev.ts index 10cc796..8fe456c 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -127,7 +127,14 @@ export default { else i.edit(`Successfully compiled TypeScript files into JavaScript!\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot', {windowsHide:true})) }) }, - file: ()=>interaction.reply({files:[`./src/database/${interaction.options.getString('name')}.json`]}).catch(()=>'Filesize is too large, upload cancelled.') + file: ()=>interaction.reply({files:[`./src/database/${interaction.options.getString('name')}.json`]}).catch(()=>'Filesize is too large, upload cancelled.'), + wake_device: async()=>{ + const i = await interaction.reply({content: 'Spawning a task...', fetchReply: true}); + exec(`cd "../../Desktop/System Tools/wakemeonlan" && WakeMeOnLan.exe /wakeup ${interaction.options.getString('name',true)}`, {windowsHide:true}, (err:Error)=>{ + if (err) i.edit(removeUsername(err.message)) + else i.edit('Your device should be awake by now!\n||Don\'t blame me if it isn\'t on.||') + }) + } } as any)[interaction.options.getSubcommand()](); }, data: new Discord.SlashCommandBuilder() @@ -149,6 +156,13 @@ export default { .addSubcommand(x=>x .setName('update') .setDescription('Pull from repository and restart')) + .addSubcommand(x=>x + .setName('wake_device') + .setDescription('Remotely wake up a device in the same network as the bot') + .addStringOption(x=>x + .setName('name') + .setDescription('Device name') + .setRequired(true))) .addSubcommand(x=>x .setName('statsgraph') .setDescription('Edit the number of data points to pull')