Largely optimized activity command.

This commit is contained in:
Keanu Timmermans 2020-08-13 20:11:14 +02:00
parent 6a628a4791
commit 8dd87c89a9
No known key found for this signature in database
GPG key ID: A02B486C183D2147

View file

@ -11,6 +11,13 @@ function getLogBuffer(type: string)
}]}; }]};
} }
const activities: { [type: string]: string } = {
playing: "",
listening: "",
streaming: "",
watching: ""
};
export default new Command({ export default new Command({
description: "An all-in-one command to do admin stuff. You need to be either an admin of the server or one of the bot's mechanics to use this command.", description: "An all-in-one command to do admin stuff. You need to be either an admin of the server or one of the bot's mechanics to use this command.",
async run($: CommonLibrary): Promise<any> async run($: CommonLibrary): Promise<any>
@ -139,66 +146,25 @@ export default new Command({
usage: "<type> <string>", usage: "<type> <string>",
async run($: CommonLibrary): Promise<any> async run($: CommonLibrary): Promise<any>
{ {
// if ($.args[0]) {
// $.message.delete();
// $.client.user?.setActivity($.args.join(" "));
// } else {
// $.message.delete();
// $.client.user?.setActivity(".help", {
// type: "LISTENING"
// });
// }
$.client.user?.setActivity(".help", { $.client.user?.setActivity(".help", {
type: "LISTENING" type: "LISTENING"
}); });
$.channel.send("Activity set to default.")
}, },
subcommands: any: new Command({
{ description: `Select an activity type to set. Available levels: \`[${Object.keys(activities)}]\``,
playing: new Command({ async run($: CommonLibrary): Promise<any>
description: "Set the \`Playing\` status for the bot.", {
usage: "<string>", const type = $.args[0];
async run($: CommonLibrary): Promise<any>
{ if(type in activities) {
$.client.user?.setActivity($.args.join(" "), { $.client.user?.setActivity($.args.slice(1).join(" "), {type: $.args[0].toUpperCase()})
type: "PLAYING" $.channel.send(`Set activity to \`${$.args[0].toUpperCase()}\` \`${$.args.slice(1).join(" ")}\`.`)
})
$.channel.send(`Set status to \`Playing ${$.args.join(" ")}\``)
} }
}), else
streaming: new Command({ $.channel.send(`Couldn't find an activity type named \`${type}\`! The available types are \`[${Object.keys(activities)}]\`.`);
description: "Set the \`Streaming\` status for the bot.", }
usage: "<string>", })
async run($: CommonLibrary): Promise<any>
{
$.client.user?.setActivity($.args.join(" "), {
type: "STREAMING"
})
$.channel.send(`Set status to \`Streaming ${$.args.join(" ")}\``)
}
}),
listening: new Command({
description: "Set the \`Listening to\` status for the bot.",
usage: "<string>",
async run($: CommonLibrary): Promise<any>
{
$.client.user?.setActivity($.args.join(" "), {
type: "LISTENING"
})
$.channel.send(`Set status to \`Listening to ${$.args.join(" ")}\``)
}
}),
watching: new Command({
description: "Set the \`Watching\` status for the bot.",
usage: "<string>",
async run($: CommonLibrary): Promise<any>
{
$.client.user?.setActivity($.args.join(" "), {
type: "WATCHING"
})
$.channel.send(`Set status to \`Watching ${$.args.join(" ")}\``)
}
})
}
}) })
} }
}); });