add cross-guild peek
This commit is contained in:
parent
cf82ae0a97
commit
7bee5755ae
1 changed files with 46 additions and 1 deletions
|
@ -53,7 +53,6 @@ addCommand("p", "peek at channel", function () {
|
|||
return;
|
||||
}
|
||||
|
||||
listChannels();
|
||||
startPrompt(":peek> ", async function (input) {
|
||||
console.log("");
|
||||
if (input == "") {
|
||||
|
@ -79,3 +78,49 @@ addCommand("p", "peek at channel", function () {
|
|||
}
|
||||
});
|
||||
});
|
||||
addCommand("P", "cross-guild peek", function () {
|
||||
startPrompt(":guild> ", async function (input) {
|
||||
console.log("");
|
||||
if (input == "") {
|
||||
return;
|
||||
}
|
||||
let targetGuild;
|
||||
for (const guild of comcord.client.guilds.values()) {
|
||||
if (guild.name.toLowerCase().indexOf(input.toLowerCase()) > -1) {
|
||||
targetGuild = guild.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetGuild == null) {
|
||||
console.log("<guild not found>");
|
||||
} else {
|
||||
startPrompt(":peek> ", async function (input) {
|
||||
console.log("");
|
||||
if (input == "") {
|
||||
return;
|
||||
}
|
||||
let target;
|
||||
|
||||
const guild = comcord.client.guilds.get(targetGuild);
|
||||
const channels = [...guild.channels.values()].filter(
|
||||
(c) => c.type == 0
|
||||
);
|
||||
channels.sort((a, b) => a.position - b.position);
|
||||
|
||||
for (const channel of channels) {
|
||||
if (channel.name.toLowerCase().indexOf(input.toLowerCase()) > -1) {
|
||||
target = channel.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
console.log("<channel not found>");
|
||||
} else {
|
||||
await getHistory(20, target);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue