mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
change: prettier code
This commit is contained in:
committed by
GitHub Action
parent
6f6099abc6
commit
e88e63aaaa
+8
-13
@@ -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]>;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user