mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-12 04:55:01 +00:00
Finish preliminary rework, ready to test
This commit is contained in:
parent
57893e7f76
commit
d0a1beb809
177 changed files with 854 additions and 707 deletions
|
@ -1,7 +1,6 @@
|
|||
import { utilityCmd } from "../types";
|
||||
import { EmbedWith, multiSorter, resolveMember, sorter } from "../../../utils";
|
||||
|
||||
|
||||
import { getCurrentUptime } from "../../../uptime";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import LCL from "last-commit-log";
|
||||
|
@ -9,6 +8,7 @@ import path from "path";
|
|||
import moment from "moment-timezone";
|
||||
import { rootDir } from "../../../paths";
|
||||
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
|
||||
import { GuildChannel, MessageOptions } from "discord.js";
|
||||
|
||||
export const AboutCmd = utilityCmd({
|
||||
trigger: "about",
|
||||
|
@ -41,7 +41,7 @@ export const AboutCmd = utilityCmd({
|
|||
version = "?";
|
||||
}
|
||||
|
||||
const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!;
|
||||
//const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!; FIXME Sharding stuff
|
||||
|
||||
const lastReload = humanizeDuration(Date.now() - pluginData.state.lastReload, {
|
||||
largest: 2,
|
||||
|
@ -53,7 +53,7 @@ export const AboutCmd = utilityCmd({
|
|||
["Last reload", `${lastReload} ago`],
|
||||
["Last update", lastUpdate],
|
||||
["Version", version],
|
||||
["API latency", `${shard.latency}ms`],
|
||||
// ["API latency", `${shard.latency}ms`],
|
||||
["Server timezone", timeAndDate.getGuildTz()],
|
||||
];
|
||||
|
||||
|
@ -65,7 +65,7 @@ export const AboutCmd = utilityCmd({
|
|||
);
|
||||
loadedPlugins.sort();
|
||||
|
||||
const aboutContent: MessageContent & { embed: EmbedWith<"title" | "fields"> } = {
|
||||
const aboutContent: MessageOptions & { embed: EmbedWith<"title" | "fields"> } = {
|
||||
embed: {
|
||||
title: `About ${pluginData.client.user!.username}`,
|
||||
fields: [
|
||||
|
@ -102,7 +102,7 @@ export const AboutCmd = utilityCmd({
|
|||
|
||||
// For the embed color, find the highest colored role the bot has - this is their color on the server as well
|
||||
const botMember = await resolveMember(pluginData.client, pluginData.guild, pluginData.client.user!.id);
|
||||
let botRoles = botMember?.roles.map(r => (msg.channel as GuildChannel).guild.roles.get(r)!) || [];
|
||||
let botRoles = botMember?.roles.cache.map(r => (msg.channel as GuildChannel).guild.roles.cache.get(r.id)!) || [];
|
||||
botRoles = botRoles.filter(r => !!r); // Drop any unknown roles
|
||||
botRoles = botRoles.filter(r => r.color); // Filter to those with a color
|
||||
botRoles.sort(sorter("position", "DESC")); // Sort by position (highest first)
|
||||
|
@ -111,10 +111,10 @@ export const AboutCmd = utilityCmd({
|
|||
}
|
||||
|
||||
// Use the bot avatar as the embed image
|
||||
if (pluginData.client.user!avatarURL) {
|
||||
aboutContent.embed.thumbnail = { url: pluginData.client.user!.avatarURL };
|
||||
if (pluginData.client.user!.avatarURL()) {
|
||||
aboutContent.embed.thumbnail = { url: pluginData.client.user!.avatarURL()! };
|
||||
}
|
||||
|
||||
msg.channel.createMessage(aboutContent);
|
||||
msg.channel.send(aboutContent);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ import { utilityCmd } from "../types";
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { UnknownUser } from "../../../utils";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { MessageEmbedOptions } from "discord.js";
|
||||
|
||||
export const AvatarCmd = utilityCmd({
|
||||
trigger: ["avatar", "av"],
|
||||
|
@ -15,15 +16,16 @@ export const AvatarCmd = utilityCmd({
|
|||
async run({ message: msg, args, pluginData }) {
|
||||
const user = args.user || msg.author;
|
||||
if (!(user instanceof UnknownUser)) {
|
||||
let extension = user.avatarURL.slice(user.avatarURL.lastIndexOf("."), user.avatarURL.lastIndexOf("?"));
|
||||
const avatar = user.avatarURL() || user.defaultAvatarURL;
|
||||
let extension = avatar.slice(avatar.lastIndexOf("."), avatar.lastIndexOf("?"));
|
||||
// Some pngs can have the .jpg extention for some reason, so we always use .png for static images
|
||||
extension = extension === ".gif" ? extension : ".png";
|
||||
const avatarUrl = user.avatarURL.slice(0, user.avatarURL.lastIndexOf("."));
|
||||
const embed: EmbedOptions = {
|
||||
const avatarUrl = avatar.slice(0, avatar.lastIndexOf("."));
|
||||
const embed: MessageEmbedOptions = {
|
||||
image: { url: avatarUrl + `${extension}?size=2048` },
|
||||
};
|
||||
embed.title = `Avatar of ${user.username}#${user.discriminator}:`;
|
||||
msg.channel.createMessage({ embed });
|
||||
msg.channel.send({ embed });
|
||||
} else {
|
||||
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");
|
||||
}
|
||||
|
|
|
@ -20,6 +20,6 @@ export const ChannelInfoCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ import { SavedMessage } from "../../../data/entities/SavedMessage";
|
|||
import { LogType } from "../../../data/LogType";
|
||||
import { allowTimeout } from "../../../RegExpRunner";
|
||||
import { ModActionsPlugin } from "../../../plugins/ModActions/ModActionsPlugin";
|
||||
import { TextChannel, User, Message } from "discord.js";
|
||||
|
||||
const MAX_CLEAN_COUNT = 150;
|
||||
const MAX_CLEAN_TIME = 1 * DAYS;
|
||||
|
@ -32,7 +33,7 @@ async function cleanMessages(
|
|||
pluginData.state.logs.ignoreLog(LogType.MESSAGE_DELETE_BULK, idsToDelete[0]);
|
||||
|
||||
// Actually delete the messages
|
||||
await pluginData.client.deleteMessages(channel.id, idsToDelete);
|
||||
(pluginData.guild.channels.cache.get(channel.id) as TextChannel).bulkDelete(idsToDelete);
|
||||
await pluginData.state.savedMessages.markBulkAsDeleted(idsToDelete);
|
||||
|
||||
// Create an archive
|
||||
|
@ -106,18 +107,18 @@ export const CleanCmd = utilityCmd({
|
|||
}
|
||||
}
|
||||
|
||||
const cleaningMessage = msg.channel.createMessage("Cleaning...");
|
||||
const cleaningMessage = msg.channel.send("Cleaning...");
|
||||
|
||||
const messagesToClean: SavedMessage[] = [];
|
||||
let beforeId = msg.id;
|
||||
const timeCutoff = msg.timestamp - MAX_CLEAN_TIME;
|
||||
const timeCutoff = msg.createdTimestamp - MAX_CLEAN_TIME;
|
||||
const upToMsgId = args["to-id"];
|
||||
let foundId = false;
|
||||
|
||||
const deletePins = args["delete-pins"] != null ? args["delete-pins"] : false;
|
||||
let pins: Message[] = [];
|
||||
if (!deletePins) {
|
||||
pins = await msg.channel.getPins();
|
||||
pins = (await msg.channel.messages.fetchPinned()).array();
|
||||
}
|
||||
|
||||
while (messagesToClean.length < args.count) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import { messageLink } from "../../../utils";
|
|||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
|
||||
import { canReadChannel } from "../../../utils/canReadChannel";
|
||||
import { TextChannel } from "discord.js";
|
||||
|
||||
export const ContextCmd = utilityCmd({
|
||||
trigger: "context",
|
||||
|
@ -35,12 +36,17 @@ export const ContextCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const previousMessage = (await pluginData.client.getMessages(channel.id, 1, messageId))[0];
|
||||
const previousMessage = (
|
||||
await (pluginData.guild.channels.cache.get(channel.id) as TextChannel).messages.fetch({
|
||||
limit: 1,
|
||||
before: messageId,
|
||||
})
|
||||
)[0];
|
||||
if (!previousMessage) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Message context not found");
|
||||
return;
|
||||
}
|
||||
|
||||
msg.channel.createMessage(messageLink(pluginData.guild.id, previousMessage.channel.id, previousMessage.id));
|
||||
msg.channel.send(messageLink(pluginData.guild.id, previousMessage.channel.id, previousMessage.id));
|
||||
},
|
||||
});
|
||||
|
|
|
@ -27,6 +27,6 @@ export const EmojiInfoCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -71,7 +71,7 @@ export const HelpCmd = utilityCmd({
|
|||
});
|
||||
|
||||
if (totalResults === 0) {
|
||||
msg.channel.createMessage("No matching commands found!");
|
||||
msg.channel.send("No matching commands found!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ export const InfoCmd = utilityCmd({
|
|||
if (channel) {
|
||||
const embed = await getChannelInfoEmbed(pluginData, channelId!, message.author.id);
|
||||
if (embed) {
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ export const InfoCmd = utilityCmd({
|
|||
|
||||
// 2. Server
|
||||
if (userCfg.can_server) {
|
||||
const guild = pluginData.client.guilds.get(value);
|
||||
const guild = pluginData.client.guilds.fetch(value);
|
||||
if (guild) {
|
||||
const embed = await getServerInfoEmbed(pluginData, value, message.author.id);
|
||||
if (embed) {
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ export const InfoCmd = utilityCmd({
|
|||
if (user && userCfg.can_userinfo) {
|
||||
const embed = await getUserInfoEmbed(pluginData, user.id, Boolean(args.compact), message.author.id);
|
||||
if (embed) {
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ export const InfoCmd = utilityCmd({
|
|||
message.author.id,
|
||||
);
|
||||
if (embed) {
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ export const InfoCmd = utilityCmd({
|
|||
if (invite) {
|
||||
const embed = await getInviteInfoEmbed(pluginData, inviteCode);
|
||||
if (embed) {
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ export const InfoCmd = utilityCmd({
|
|||
if (serverPreview) {
|
||||
const embed = await getServerInfoEmbed(pluginData, value, message.author.id);
|
||||
if (embed) {
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ export const InfoCmd = utilityCmd({
|
|||
const role = roleId && pluginData.guild.roles.cache.get(roleId);
|
||||
if (role) {
|
||||
const embed = await getRoleInfoEmbed(pluginData, role, message.author.id);
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ export const InfoCmd = utilityCmd({
|
|||
if (emojiIdMatch?.[2]) {
|
||||
const embed = await getEmojiInfoEmbed(pluginData, emojiIdMatch[2]);
|
||||
if (embed) {
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ export const InfoCmd = utilityCmd({
|
|||
// 9. Arbitrary ID
|
||||
if (isValidSnowflake(value) && userCfg.can_snowflake) {
|
||||
const embed = await getSnowflakeInfoEmbed(pluginData, value, true, message.author.id);
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,6 @@ export const InviteInfoCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -83,6 +83,6 @@ export const JumboCmd = utilityCmd({
|
|||
};
|
||||
}
|
||||
|
||||
msg.channel.createMessage("", file);
|
||||
msg.channel.send("", file);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -17,6 +17,8 @@ export const LevelCmd = utilityCmd({
|
|||
run({ message, args, pluginData }) {
|
||||
const member = args.member || message.member;
|
||||
const level = getMemberLevel(pluginData, member);
|
||||
message.channel.createMessage(`The permission level of ${member.username}#${member.discriminator} is **${level}**`);
|
||||
message.channel.send(
|
||||
`The permission level of ${member.user.username}#${member.user.discriminator} is **${level}**`,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -31,6 +31,6 @@ export const MessageInfoCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -16,24 +16,24 @@ export const NicknameCmd = utilityCmd({
|
|||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (msg.member.id !== args.member.id && !canActOn(pluginData, msg.member, args.member)) {
|
||||
msg.channel.createMessage(errorMessage("Cannot change nickname: insufficient permissions"));
|
||||
msg.channel.send(errorMessage("Cannot change nickname: insufficient permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
const nicknameLength = [...args.nickname].length;
|
||||
if (nicknameLength < 2 || nicknameLength > 32) {
|
||||
msg.channel.createMessage(errorMessage("Nickname must be between 2 and 32 characters long"));
|
||||
msg.channel.send(errorMessage("Nickname must be between 2 and 32 characters long"));
|
||||
return;
|
||||
}
|
||||
|
||||
const oldNickname = args.member.nick || "<none>";
|
||||
const oldNickname = args.member.nickname || "<none>";
|
||||
|
||||
try {
|
||||
await args.member.edit({
|
||||
nick: args.nickname,
|
||||
});
|
||||
} catch {
|
||||
msg.channel.createMessage(errorMessage("Failed to change nickname"));
|
||||
msg.channel.send(errorMessage("Failed to change nickname"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ export const NicknameResetCmd = utilityCmd({
|
|||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (msg.member.id !== args.member.id && !canActOn(pluginData, msg.member, args.member)) {
|
||||
msg.channel.createMessage(errorMessage("Cannot reset nickname: insufficient permissions"));
|
||||
msg.channel.send(errorMessage("Cannot reset nickname: insufficient permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ export const NicknameResetCmd = utilityCmd({
|
|||
nick: "",
|
||||
});
|
||||
} catch {
|
||||
msg.channel.createMessage(errorMessage("Failed to reset nickname"));
|
||||
msg.channel.send(errorMessage("Failed to reset nickname"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { utilityCmd } from "../types";
|
||||
import { noop, trimLines } from "../../../utils";
|
||||
import { Message } from "discord.js";
|
||||
|
||||
const { performance } = require("perf_hooks");
|
||||
|
||||
|
@ -15,12 +16,12 @@ export const PingCmd = utilityCmd({
|
|||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const start = performance.now();
|
||||
const message = await msg.channel.createMessage(`Calculating ping... ${i + 1}`);
|
||||
const message = await msg.channel.send(`Calculating ping... ${i + 1}`);
|
||||
times.push(performance.now() - start);
|
||||
messages.push(message);
|
||||
|
||||
if (msgToMsgDelay === undefined) {
|
||||
msgToMsgDelay = message.timestamp - msg.timestamp;
|
||||
msgToMsgDelay = message.createdTimestamp - msg.createdTimestamp;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,25 +29,19 @@ export const PingCmd = utilityCmd({
|
|||
const lowest = Math.round(Math.min(...times));
|
||||
const mean = Math.round(times.reduce((total, ms) => total + ms, 0) / times.length);
|
||||
|
||||
const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!;
|
||||
// const shard = pluginData.client.shards.get(pluginData.client.guildShardMap[pluginData.guild.id])!; FIXME sharding stuff
|
||||
|
||||
msg.channel.createMessage(
|
||||
msg.channel.send(
|
||||
trimLines(`
|
||||
**Ping:**
|
||||
Lowest: **${lowest}ms**
|
||||
Highest: **${highest}ms**
|
||||
Mean: **${mean}ms**
|
||||
Time between ping command and first reply: **${msgToMsgDelay!}ms**
|
||||
Shard latency: **${shard.latency}ms**
|
||||
`),
|
||||
`), // Omitted line: Shard latency: **${shard.latency}ms**
|
||||
);
|
||||
|
||||
// Clean up test messages
|
||||
pluginData.client
|
||||
.deleteMessages(
|
||||
messages[0].channel.id,
|
||||
messages.map(m => m.id),
|
||||
)
|
||||
.catch(noop);
|
||||
msg.channel.bulkDelete(messages).catch(noop);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { utilityCmd } from "../types";
|
||||
|
||||
import { activeReloads } from "../guildReloads";
|
||||
import { TextChannel } from "discord.js";
|
||||
|
||||
export const ReloadGuildCmd = utilityCmd({
|
||||
trigger: "reload_guild",
|
||||
|
@ -11,7 +12,7 @@ export const ReloadGuildCmd = utilityCmd({
|
|||
if (activeReloads.has(pluginData.guild.id)) return;
|
||||
activeReloads.set(pluginData.guild.id, msg.channel as TextChannel);
|
||||
|
||||
msg.channel.createMessage("Reloading...");
|
||||
msg.channel.send("Reloading...");
|
||||
pluginData.getKnubInstance().reloadGuild(pluginData.guild.id);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -15,6 +15,6 @@ export const RoleInfoCmd = utilityCmd({
|
|||
|
||||
async run({ message, args, pluginData }) {
|
||||
const embed = await getRoleInfoEmbed(pluginData, args.role, message.author.id);
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import { commandTypeHelpers as ct } from "../../../commandTypes";
|
|||
import { chunkArray, sorter, trimLines } from "../../../utils";
|
||||
import { refreshMembersIfNeeded } from "../refreshMembers";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { Role, TextChannel } from "discord.js";
|
||||
|
||||
export const RolesCmd = utilityCmd({
|
||||
trigger: "roles",
|
||||
|
@ -21,7 +22,9 @@ export const RolesCmd = utilityCmd({
|
|||
async run({ message: msg, args, pluginData }) {
|
||||
const { guild } = pluginData;
|
||||
|
||||
let roles: Array<{ _memberCount?: number } & Role> = Array.from((msg.channel as TextChannel).guild.roles.values());
|
||||
let roles: Array<{ _memberCount?: number } & Role> = Array.from(
|
||||
(msg.channel as TextChannel).guild.roles.cache.values(),
|
||||
);
|
||||
let sort = args.sort;
|
||||
|
||||
if (args.search) {
|
||||
|
@ -33,8 +36,8 @@ export const RolesCmd = utilityCmd({
|
|||
await refreshMembersIfNeeded(guild);
|
||||
|
||||
// If the user requested role member counts as well, calculate them and sort the roles by their member count
|
||||
const roleCounts: Map<string, number> = Array.from(guild.members.values()).reduce((map, member) => {
|
||||
for (const roleId of member.roles) {
|
||||
const roleCounts: Map<string, number> = Array.from(guild.members.cache.values()).reduce((map, member) => {
|
||||
for (const roleId of member.roles.cache) {
|
||||
if (!map.has(roleId)) map.set(roleId, 0);
|
||||
map.set(roleId, map.get(roleId) + 1);
|
||||
}
|
||||
|
@ -97,14 +100,14 @@ export const RolesCmd = utilityCmd({
|
|||
});
|
||||
|
||||
if (i === 0) {
|
||||
msg.channel.createMessage(
|
||||
msg.channel.send(
|
||||
trimLines(`
|
||||
${args.search ? "Total roles found" : "Total roles"}: ${roles.length}
|
||||
\`\`\`py\n${roleLines.join("\n")}\`\`\`
|
||||
`),
|
||||
);
|
||||
} else {
|
||||
msg.channel.createMessage("```py\n" + roleLines.join("\n") + "```");
|
||||
msg.channel.send("```py\n" + roleLines.join("\n") + "```");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -21,6 +21,6 @@ export const ServerInfoCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
message.channel.createMessage({ embed: serverInfoEmbed });
|
||||
message.channel.send({ embed: serverInfoEmbed });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -16,6 +16,6 @@ export const SnowflakeInfoCmd = utilityCmd({
|
|||
|
||||
async run({ message, args, pluginData }) {
|
||||
const embed = await getSnowflakeInfoEmbed(pluginData, args.id, false, message.author.id);
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -22,9 +22,7 @@ export const SourceCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
const message = await pluginData.client
|
||||
.getMessage(args.message.channel.id, args.message.messageId)
|
||||
.catch(() => null);
|
||||
const message = await args.message.channel.messages.fetch(args.message.messageId).catch(() => null);
|
||||
if (!message) {
|
||||
sendErrorMessage(pluginData, cmdMessage.channel, "Unknown message");
|
||||
return;
|
||||
|
@ -44,6 +42,6 @@ export const SourceCmd = utilityCmd({
|
|||
const archiveId = await pluginData.state.archives.create(source, moment.utc().add(1, "hour"));
|
||||
const baseUrl = getBaseUrl(pluginData);
|
||||
const url = pluginData.state.archives.getUrl(baseUrl, archiveId);
|
||||
cmdMessage.channel.createMessage(`Message source: ${url}`);
|
||||
cmdMessage.channel.send(`Message source: ${url}`);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -23,6 +23,6 @@ export const UserInfoCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
message.channel.createMessage({ embed });
|
||||
message.channel.send({ embed });
|
||||
},
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { resolveChannel } from "knub/dist/helpers";
|
||||
import { VoiceChannel } from "discord.js";
|
||||
|
||||
export const VcdisconnectCmd = utilityCmd({
|
||||
trigger: ["vcdisconnect", "vcdisc", "vcdc", "vckick", "vck"],
|
||||
|
@ -28,16 +28,14 @@ export const VcdisconnectCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
if (!args.member.voiceState || !args.member.voiceState.channelID) {
|
||||
if (!args.member.voice || !args.member.voice.channelID) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
|
||||
return;
|
||||
}
|
||||
const channel = (await resolveChannel(pluginData.guild, args.member.voiceState.channelID)) as VoiceChannel;
|
||||
const channel = pluginData.guild.channels.cache.get(args.member.voice.channelID) as VoiceChannel;
|
||||
|
||||
try {
|
||||
await args.member.edit({
|
||||
channelID: null,
|
||||
});
|
||||
await args.member.voice.kick();
|
||||
} catch {
|
||||
sendErrorMessage(pluginData, msg.channel, "Failed to disconnect member");
|
||||
return;
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { VoiceChannel } from "discord.js";
|
||||
|
||||
export const VcmoveCmd = utilityCmd({
|
||||
trigger: "vcmove",
|
||||
|
@ -47,7 +48,7 @@ export const VcmoveCmd = utilityCmd({
|
|||
channel = potentialChannel;
|
||||
} else {
|
||||
// Search string -> find closest matching voice channel name
|
||||
const voiceChannels = pluginData.guild.channels.filter(theChannel => {
|
||||
const voiceChannels = pluginData.guild.channels.cache.array().filter(theChannel => {
|
||||
return theChannel instanceof VoiceChannel;
|
||||
}) as VoiceChannel[];
|
||||
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name);
|
||||
|
@ -59,21 +60,21 @@ export const VcmoveCmd = utilityCmd({
|
|||
channel = closestMatch;
|
||||
}
|
||||
|
||||
if (!args.member.voiceState || !args.member.voiceState.channelID) {
|
||||
if (!args.member.voice || !args.member.voice.channelID) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.member.voiceState.channelID === channel.id) {
|
||||
if (args.member.voice.channelID === channel.id) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Member is already on that channel!");
|
||||
return;
|
||||
}
|
||||
|
||||
const oldVoiceChannel = pluginData.guild.channels.cache.get(args.member.voiceState.channelID);
|
||||
const oldVoiceChannel = pluginData.guild.channels.cache.get(args.member.voice.channelID);
|
||||
|
||||
try {
|
||||
await args.member.edit({
|
||||
channelID: channel.id,
|
||||
channel: channel.id,
|
||||
});
|
||||
} catch {
|
||||
sendErrorMessage(pluginData, msg.channel, "Failed to move member");
|
||||
|
@ -130,7 +131,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
channel = potentialChannel;
|
||||
} else {
|
||||
// Search string -> find closest matching voice channel name
|
||||
const voiceChannels = pluginData.guild.channels.filter(theChannel => {
|
||||
const voiceChannels = pluginData.guild.channels.cache.array().filter(theChannel => {
|
||||
return theChannel instanceof VoiceChannel;
|
||||
}) as VoiceChannel[];
|
||||
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name);
|
||||
|
@ -142,7 +143,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
channel = closestMatch;
|
||||
}
|
||||
|
||||
if (args.oldChannel.voiceMembers.size === 0) {
|
||||
if (args.oldChannel.members.size === 0) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Voice channel is empty");
|
||||
return;
|
||||
}
|
||||
|
@ -154,9 +155,9 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
|
||||
// Cant leave null, otherwise we get an assignment error in the catch
|
||||
let currMember = msg.member;
|
||||
const moveAmt = args.oldChannel.voiceMembers.size;
|
||||
const moveAmt = args.oldChannel.members.size;
|
||||
let errAmt = 0;
|
||||
for (const memberWithId of args.oldChannel.voiceMembers) {
|
||||
for (const memberWithId of args.oldChannel.members) {
|
||||
currMember = memberWithId[1];
|
||||
|
||||
// Check for permissions but allow self-moves
|
||||
|
@ -164,7 +165,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`Failed to move ${currMember.username}#${currMember.discriminator} (${currMember.id}): You cannot act on this member`,
|
||||
`Failed to move ${currMember.user.username}#${currMember.user.discriminator} (${currMember.id}): You cannot act on this member`,
|
||||
);
|
||||
errAmt++;
|
||||
continue;
|
||||
|
@ -172,7 +173,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
|
||||
try {
|
||||
currMember.edit({
|
||||
channelID: channel.id,
|
||||
channel: channel.id,
|
||||
});
|
||||
} catch {
|
||||
if (msg.member.id === currMember.id) {
|
||||
|
@ -182,7 +183,7 @@ export const VcmoveAllCmd = utilityCmd({
|
|||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`Failed to move ${currMember.username}#${currMember.discriminator} (${currMember.id})`,
|
||||
`Failed to move ${currMember.user.username}#${currMember.user.discriminator} (${currMember.id})`,
|
||||
);
|
||||
errAmt++;
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue