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.", description: "Displays info about mentioned user.",
async run($: CommonLibrary): Promise<any> { async run($: CommonLibrary): Promise<any> {
// Transforms the User object into a GuildMember object of the current guild. // 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) if (!member)
return $.channel.send( 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 (!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."); 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."); if ($.args.length === 0) return $.channel.send("Please provide a new voice channel name.");
const changeVC = $.guild.channels.resolve(voiceChannel.id); const prevName = voiceChannel.name;
$.channel const newName = $.args.join(" ");
.send(`Changed channel name from "${voiceChannel}" to "${$.args.join(" ")}".`) await voiceChannel.setName(newName);
/// @ts-ignore await $.channel.send(`Changed channel name from "${prevName}" to "${newName}".`);
.then(changeVC?.setName($.args.join(" ")));
} }
}); });

View file

@ -172,7 +172,7 @@ export function formatUTCTimestamp(now = new Date()) {
} }
export function botHasPermission(guild: Guild | null, permission: number): boolean { 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 { export function updateGlobalEmoteRegistry(): void {