utility: start on presence

This commit is contained in:
Cynthia Foxwell 2022-10-09 22:38:15 -06:00
parent 0a5a95aa05
commit f1b8282ba2

View file

@ -639,3 +639,82 @@ charinfo.callback = async function (msg, line) {
}
};
hf.registerCommand(charinfo);
const PRESENCE_ICONS = {
desktop: {
online: "<:desktop_online:1028887024670871552>",
idle: "<:desktop_idle:1028887022938624033>",
dnd: "<:desktop_dnd:1028887021848121364>",
},
mobile: {
online: "<:mobile_online:1028887017637036043>",
idle: "<:mobile_idle:1028887019226669116>",
dnd: "<:mobile_dnd:1028887020560449637>",
},
web: {
online: "<:web_online:1028887016353574962>",
idle: "<:web_idle:1028887014579392592>",
dnd: "<:web_dnd:1028887012855525486>",
},
embedded: {
online: "<:embedded_online:1028887010636726313>",
idle: "<:embedded_idle:1028887009147760681>",
dnd: "<:embedded_dnd:1028887008149516299>",
},
};
const presence = new Command("presence");
presence.category = CATEGORY;
presence.helpText = "Get presences of a user.";
presence.usage = "<user>";
presence.callback = async function (msg, line) {
if (!msg.guildID) return "Can only be used in guilds.";
let target;
if (line) {
const user = await lookupUser(msg, line);
if (
user == "No results" ||
user == "Canceled" ||
user == "Request timed out"
) {
return user;
} else {
let member = user;
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
if (guild) {
if (guild.members.has(user.id)) {
member = guild.members.get(user.id);
} else {
const fetched = await guild.fetchMembers({
userIDs: [user.id],
});
member = fetched[0];
target = member;
}
}
}
} else {
target = msg.member;
}
if (target) {
if (!target.presence) return `**${target.tag}** is offline.`;
let icons = "";
for (const platform in target.presence.client_status) {
const status = target.presence.client_status[platform];
icons += PRESENCE_ICONS[platform][status] + " ";
}
const embeds = [];
return {
content: `Presence for **${target.tag}**: ${icons}`,
};
} else {
return ":warning: Could not get user???";
}
};
hf.registerCommand(presence);