3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 14:11:50 +00:00

utility.about: fix git repo path; don't throw an error if a git repo is not found

This commit is contained in:
Dragory 2019-11-28 02:47:15 +02:00
parent 581cf80feb
commit f8444c1a3d

View file

@ -56,6 +56,7 @@ import { getCurrentUptime } from "../uptime";
import LCL from "last-commit-log"; import LCL from "last-commit-log";
import * as t from "io-ts"; import * as t from "io-ts";
import { ICommandDefinition } from "knub-command-manager"; import { ICommandDefinition } from "knub-command-manager";
import path from "path";
const ConfigSchema = t.type({ const ConfigSchema = t.type({
can_roles: t.boolean, can_roles: t.boolean,
@ -344,7 +345,10 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
matchingMembers.sort(sorter(m => BigInt(m.id), realSortDir)); matchingMembers.sort(sorter(m => BigInt(m.id), realSortDir));
} else { } else {
matchingMembers.sort( matchingMembers.sort(
multiSorter([[m => m.username.toLowerCase(), realSortDir], [m => m.discriminator, realSortDir]]), multiSorter([
[m => m.username.toLowerCase(), realSortDir],
[m => m.discriminator, realSortDir],
]),
); );
} }
@ -994,7 +998,12 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
); );
// Clean up test messages // Clean up test messages
this.bot.deleteMessages(messages[0].channel.id, messages.map(m => m.id)).catch(noop); this.bot
.deleteMessages(
messages[0].channel.id,
messages.map(m => m.id),
)
.catch(noop);
} }
@d.command("source", "<messageId:string>", { @d.command("source", "<messageId:string>", {
@ -1192,8 +1201,25 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
const uptime = getCurrentUptime(); const uptime = getCurrentUptime();
const prettyUptime = humanizeDuration(uptime, { largest: 2, round: true }); const prettyUptime = humanizeDuration(uptime, { largest: 2, round: true });
const lcl = new LCL(); let lastCommit;
const lastCommit = await lcl.getLastCommit();
try {
// From project root
// FIXME: Store these paths properly somewhere
const lcl = new LCL(path.resolve(__dirname, "..", "..", ".."));
lastCommit = await lcl.getLastCommit();
} catch (e) {} // tslint:disable-line:no-empty
let lastUpdate;
let version;
if (lastCommit) {
lastUpdate = moment(lastCommit.committer.date, "X").format("LL [at] H:mm [(UTC)]");
version = lastCommit.shortHash;
} else {
lastUpdate = "?";
version = "?";
}
const shard = this.bot.shards.get(this.bot.guildShardMap[this.guildId]); const shard = this.bot.shards.get(this.bot.guildShardMap[this.guildId]);
@ -1205,8 +1231,8 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
const basicInfoRows = [ const basicInfoRows = [
["Uptime", prettyUptime], ["Uptime", prettyUptime],
["Last reload", `${lastReload} ago`], ["Last reload", `${lastReload} ago`],
["Last update", moment(lastCommit.committer.date, "X").format("LL [at] H:mm [(UTC)]")], ["Last update", lastUpdate],
["Version", lastCommit.shortHash], ["Version", version],
["API latency", `${shard.latency}ms`], ["API latency", `${shard.latency}ms`],
]; ];