refactor: resolve async promises, fixed typos, and used inline variable for return (#299)

* Added await in async function, fixed typos and used inline variable for return

* Added await in async function, fixed typos and used inline variable for return

* Revert "Added await in async function, fixed typos and used inline variable for return"

This reverts commit f31caf5d

* Added await in async function, fixed typos and used inline variable for return

* Fixes format

* Fixes format 2

* Fixes format 4475757

* Fixes format 878757854786312378657865785785785785

* Change return to await

* Fixing more issues

* Fixing even more issues

* Fixing even more issues +

* Fixes format
This commit is contained in:
TriForMine
2020-12-30 09:31:11 +01:00
committed by GitHub
parent 6d7aa35d9c
commit 484f86638f
29 changed files with 126 additions and 141 deletions
+7 -7
View File
@@ -16,7 +16,7 @@ import {
} from "../../util/permissions.ts";
import { formatImageURL, urlToBase64 } from "../../util/utils.ts";
import { cacheHandlers } from "../controllers/cache.ts";
import { Member, structures } from "../structures/structures.ts";
import { Member, structures } from "../structures/mod.ts";
import { sendMessage } from "./channel.ts";
/** The users custom avatar or the default avatar if you don't have a member object. */
@@ -127,10 +127,10 @@ export async function sendDirectMessage(
{ recipient_id: memberID },
) as DMChannelCreatePayload;
// Channel create event will have added this channel to the cache
cacheHandlers.delete("channels", dmChannelData.id);
await cacheHandlers.delete("channels", dmChannelData.id);
const channel = await structures.createChannel(dmChannelData);
// Recreate the channel and add it undert he users id
cacheHandlers.set("channels", memberID, channel);
await cacheHandlers.set("channels", memberID, channel);
dmChannel = channel;
}
@@ -240,9 +240,9 @@ export function moveMember(
/** Modifies the bot's username or avatar.
* NOTE: username: if changed may cause the bot's discriminator to be randomized.
*/
export async function editBotProfile(username?: string, avatarURL?: string) {
export async function editBotProfile(username?: string, botAvatarURL?: string) {
// Nothing was edited
if (!username && !avatarURL) return;
if (!username && !botAvatarURL) return;
// Check username requirements if username was provided
if (username) {
if (username.length > 32) {
@@ -259,8 +259,8 @@ export async function editBotProfile(username?: string, avatarURL?: string) {
}
}
const avatar = avatarURL ? await urlToBase64(avatarURL) : undefined;
RequestManager.patch(
const avatar = botAvatarURL ? await urlToBase64(botAvatarURL) : undefined;
return RequestManager.patch(
endpoints.USER_BOT,
{
username: username?.trim(),