change: prettier code

This commit is contained in:
Skillz4Killz
2021-10-29 15:47:12 +00:00
committed by GitHub Action
parent 6f6099abc6
commit e88e63aaaa
2 changed files with 11 additions and 21 deletions
+8 -13
View File
@@ -629,16 +629,11 @@ export interface Helpers {
suppressEmbeds: typeof helpers.suppressEmbeds; suppressEmbeds: typeof helpers.suppressEmbeds;
} }
export function createHelpers( export function createHelpers(bot: Bot, customHelpers?: Partial<Helpers>): FinalHelpers {
bot: Bot,
customHelpers?: Partial<Helpers>,
): FinalHelpers {
const converted = {} as FinalHelpers; const converted = {} as FinalHelpers;
for (const [name, fun] of Object.entries({ ...createBaseHelpers(customHelpers || {}) })) { for (const [name, fun] of Object.entries({ ...createBaseHelpers(customHelpers || {}) })) {
// @ts-ignore - TODO: make the types better // @ts-ignore - TODO: make the types better
converted[name as keyof FinalHelpers] = ( converted[name as keyof FinalHelpers] = (...args: RemoveFirstFromTuple<Parameters<typeof fun>>) =>
...args: RemoveFirstFromTuple<Parameters<typeof fun>>
) =>
// @ts-ignore - TODO: make the types better // @ts-ignore - TODO: make the types better
fun(bot, ...args); fun(bot, ...args);
} }
@@ -1254,11 +1249,11 @@ export function createBotGatewayHandlers(
}; };
} }
export type RemoveFirstFromTuple<T extends any[]> = T["length"] extends 0 ? [] export type RemoveFirstFromTuple<T extends any[]> = T["length"] extends 0
: ((...b: T) => void) extends (a: any, ...b: infer I) => void ? I ? []
: ((...b: T) => void) extends (a: any, ...b: infer I) => void
? I
: []; : [];
export type FinalHelpers = { export type FinalHelpers = {
[K in keyof Helpers]: ( [K in keyof Helpers]: (...args: RemoveFirstFromTuple<Parameters<Helpers[K]>>) => ReturnType<Helpers[K]>;
...args: RemoveFirstFromTuple<Parameters<Helpers[K]>> };
) => ReturnType<Helpers[K]>;
};
+3 -8
View File
@@ -10,14 +10,9 @@ export async function sendDirectMessage(bot: Bot, memberId: bigint, content: str
let dmChannel = await bot.cache.channels.get(memberId); let dmChannel = await bot.cache.channels.get(memberId);
if (!dmChannel) { if (!dmChannel) {
// If not available in cache create a new one. // If not available in cache create a new one.
const dmChannelData = await bot.rest.runMethod<Channel>( const dmChannelData = await bot.rest.runMethod<Channel>(bot.rest, "post", bot.constants.endpoints.USER_DM, {
bot.rest, recipient_id: memberId,
"post", });
bot.constants.endpoints.USER_DM,
{
recipient_id: memberId,
}
);
const discordenoChannel = await bot.transformers.channel(bot, { channel: dmChannelData }); const discordenoChannel = await bot.transformers.channel(bot, { channel: dmChannelData });
// Recreate the channel and add it under the users id // Recreate the channel and add it under the users id
await bot.cache.channels.set(memberId, discordenoChannel); await bot.cache.channels.set(memberId, discordenoChannel);