|
1 | 1 | import { Message, MessageAttachment } from "discord.js"; |
2 | 2 | import { Command } from "../../base/Command.js"; |
3 | 3 | import serverJS from "../../servers"; |
4 | | -import lastLines from "read-last-lines" |
| 4 | +import lastLines from "read-last-lines"; |
5 | 5 |
|
6 | 6 | const Rollback: Command<Message> = { |
7 | | - name: "getlogs", |
8 | | - description: "Get logs from a Factorio server", |
9 | | - usage: "(channel) [logcount]", |
10 | | - category: "Administration", |
11 | | - aliases: [], |
12 | | - examples: ["{{p}}getlogs #awf-regular 50"], |
13 | | - dirname: __dirname, |
14 | | - enabled: true, |
15 | | - guildOnly: false, |
16 | | - memberPermissions: ["ADMINISTRATOR"], |
17 | | - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], |
18 | | - nsfw: false, |
19 | | - ownerOnly: false, |
20 | | - customPermissions: ["MANAGE_SERVER"], |
21 | | - run: async ({ client, message, args }) => { |
22 | | - if (!message.mentions.channels.first()) |
23 | | - return message.reply("No channel to get logs of provided!"); |
24 | | - args.shift(); // remove mention |
25 | | - const lineCount = Math.min(Number(args.shift()) || 50, 200) |
26 | | - const server = serverJS.find( |
27 | | - (server) => server.discordid === message.mentions.channels.first().id |
28 | | - ); |
29 | | - if (!server) return message.reply("Invalid channel, not tied to a server!"); |
30 | | - const fullPath = `${client.config.serverpath}/${server.path}/factorio-current.log` |
31 | | - const lines = await lastLines.read(fullPath, lineCount < 0 ? lineCount : 50) |
32 | | - const attachment = new MessageAttachment(Buffer.from(lines), "log.txt") |
33 | | - return message.channel.send(`Logs for <#${server.discordid}> are sent as an attachement`, {files: [attachment]}) |
34 | | - }, |
| 7 | + name: "getlogs", |
| 8 | + description: "Get logs from a Factorio server", |
| 9 | + usage: "(channel) [logcount]", |
| 10 | + category: "Administration", |
| 11 | + aliases: [], |
| 12 | + examples: ["{{p}}getlogs #awf-regular 50"], |
| 13 | + dirname: __dirname, |
| 14 | + enabled: true, |
| 15 | + guildOnly: false, |
| 16 | + memberPermissions: ["ADMINISTRATOR"], |
| 17 | + botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], |
| 18 | + nsfw: false, |
| 19 | + ownerOnly: false, |
| 20 | + customPermissions: ["MANAGE_SERVER"], |
| 21 | + run: async ({ client, message, args }) => { |
| 22 | + if (!message.mentions.channels.first()) |
| 23 | + return message.reply("No channel to get logs of provided!"); |
| 24 | + args.shift(); // remove mention |
| 25 | + const lineCount = Math.min(Number(args.shift()) || 50, 200); |
| 26 | + const server = serverJS.find( |
| 27 | + (server) => server.discordid === message.mentions.channels.first().id |
| 28 | + ); |
| 29 | + if (!server) return message.reply("Invalid channel, not tied to a server!"); |
| 30 | + const fullPath = `${client.config.serverpath}/${server.path}/factorio-current.log`; |
| 31 | + const lines = await lastLines.read( |
| 32 | + fullPath, |
| 33 | + lineCount < 0 ? lineCount : 50 |
| 34 | + ); |
| 35 | + const attachment = new MessageAttachment(Buffer.from(lines), "log.txt"); |
| 36 | + return message.channel.send({ |
| 37 | + files: [attachment], |
| 38 | + content: `Logs for <#${server.discordid}> are sent as an attachement`, |
| 39 | + }); |
| 40 | + }, |
35 | 41 | }; |
36 | 42 |
|
37 | 43 | export default Rollback; |
0 commit comments