get rid of the remaining calls to BaseManager#resolve to make all cache access explicit

This commit is contained in:
Dmytro Meleshko 2021-01-29 18:21:06 +02:00
parent a21ed7a97f
commit 417bfc8a18
3 changed files with 7 additions and 8 deletions

View File

@ -145,7 +145,7 @@ export default new Command({
description: "Displays info about mentioned user.",
async run($: CommonLibrary): Promise<any> {
// Transforms the User object into a GuildMember object of the current guild.
const member = $.guild?.members.resolve($.args[0]) ?? (await $.guild?.members.fetch($.args[0]));
const member = await $.guild?.members.fetch($.args[0]);
if (!member)
return $.channel.send(

View File

@ -9,15 +9,14 @@ export default new Command({
if (!voiceChannel) return $.channel.send("You are not in a voice channel.");
if (!$.guild?.me?.hasPermission("MANAGE_CHANNELS"))
if (!voiceChannel.guild.me?.hasPermission("MANAGE_CHANNELS"))
return $.channel.send("I am lacking the required permissions to perform this action.");
if ($.args.length === 0) return $.channel.send("Please provide a new voice channel name.");
const changeVC = $.guild.channels.resolve(voiceChannel.id);
$.channel
.send(`Changed channel name from "${voiceChannel}" to "${$.args.join(" ")}".`)
/// @ts-ignore
.then(changeVC?.setName($.args.join(" ")));
const prevName = voiceChannel.name;
const newName = $.args.join(" ");
await voiceChannel.setName(newName);
await $.channel.send(`Changed channel name from "${prevName}" to "${newName}".`);
}
});

View File

@ -172,7 +172,7 @@ export function formatUTCTimestamp(now = new Date()) {
}
export function botHasPermission(guild: Guild | null, permission: number): boolean {
return !!(client.user && guild?.members.resolve(client.user)?.hasPermission(permission));
return !!(guild?.me?.hasPermission(permission));
}
export function updateGlobalEmoteRegistry(): void {