mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
change: prettier code
This commit is contained in:
committed by
GitHub Action
parent
20616e8a36
commit
3a08aa15f4
@@ -15,7 +15,7 @@ export async function createGuild(bot: Bot, options: CreateGuild) {
|
|||||||
roles: options.roles,
|
roles: options.roles,
|
||||||
system_channel_flags: options.systemChannelFlags,
|
system_channel_flags: options.systemChannelFlags,
|
||||||
system_channel_id: options.systemChannelId,
|
system_channel_id: options.systemChannelId,
|
||||||
verification_level: options.verificationLevel
|
verification_level: options.verificationLevel,
|
||||||
});
|
});
|
||||||
|
|
||||||
const guild = bot.transformers.guild(bot, { guild: result, shardId: 0 });
|
const guild = bot.transformers.guild(bot, { guild: result, shardId: 0 });
|
||||||
|
|||||||
@@ -18,16 +18,12 @@ export async function editGuild(bot: Bot, guildId: bigint, options: ModifyGuild)
|
|||||||
options.splash = await bot.utils.urlToBase64(options.splash);
|
options.splash = await bot.utils.urlToBase64(options.splash);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await bot.rest.runMethod<Guild>(bot.rest,"patch", bot.constants.endpoints.GUILDS_BASE(guildId), {
|
const result = await bot.rest.runMethod<Guild>(bot.rest, "patch", bot.constants.endpoints.GUILDS_BASE(guildId), {});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
const cached = await bot.cache.guilds.get(guildId);
|
const cached = await bot.cache.guilds.get(guildId);
|
||||||
return bot.transformers.guild(
|
return bot.transformers.guild(bot, {
|
||||||
bot,
|
|
||||||
{
|
|
||||||
guild: result,
|
guild: result,
|
||||||
shardId: cached?.shardId || Number((BigInt(result.id) >> 22n % BigInt(bot.gateway.botGatewayData.shards)).toString())
|
shardId:
|
||||||
}
|
cached?.shardId || Number((BigInt(result.id) >> 22n % BigInt(bot.gateway.botGatewayData.shards)).toString()),
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ export async function editWelcomeScreen(bot: Bot, guildId: bigint, options: Modi
|
|||||||
channel_id: welcomeScreen.channelId,
|
channel_id: welcomeScreen.channelId,
|
||||||
description: welcomeScreen.description,
|
description: welcomeScreen.description,
|
||||||
emoji_id: welcomeScreen.emojiId,
|
emoji_id: welcomeScreen.emojiId,
|
||||||
emoji_name: welcomeScreen.emojiName
|
emoji_name: welcomeScreen.emojiName,
|
||||||
}
|
};
|
||||||
}),
|
}),
|
||||||
description: options.description
|
description: options.description,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,10 @@ import type { Bot } from "../../bot.ts";
|
|||||||
export async function getAuditLogs(bot: Bot, guildId: bigint, options?: GetGuildAuditLog) {
|
export async function getAuditLogs(bot: Bot, guildId: bigint, options?: GetGuildAuditLog) {
|
||||||
await bot.utils.requireBotGuildPermissions(bot, guildId, ["VIEW_AUDIT_LOG"]);
|
await bot.utils.requireBotGuildPermissions(bot, guildId, ["VIEW_AUDIT_LOG"]);
|
||||||
|
|
||||||
return await bot.rest.runMethod<AuditLog>(
|
return await bot.rest.runMethod<AuditLog>(bot.rest, "get", bot.constants.endpoints.GUILD_AUDIT_LOGS(guildId), {
|
||||||
bot.rest,
|
|
||||||
"get",
|
|
||||||
bot.constants.endpoints.GUILD_AUDIT_LOGS(guildId),
|
|
||||||
{
|
|
||||||
user_id: options.userId,
|
user_id: options.userId,
|
||||||
action_type: options.actionType,
|
action_type: options.actionType,
|
||||||
before: options.before,
|
before: options.before,
|
||||||
limit: options?.limit && options.limit >= 1 && options.limit <= 100 ? options.limit : 50,
|
limit: options?.limit && options.limit >= 1 && options.limit <= 100 ? options.limit : 50,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,10 @@ export async function getGuild(
|
|||||||
with_counts: options.counts,
|
with_counts: options.counts,
|
||||||
});
|
});
|
||||||
|
|
||||||
const guild = await bot.transformers.guild(
|
const guild = await bot.transformers.guild(bot, {
|
||||||
bot,
|
|
||||||
{
|
|
||||||
guild: result,
|
guild: result,
|
||||||
shardId: Number((BigInt(guildId) >> 22n) % BigInt(ws.botGatewayData.shards))
|
shardId: Number((BigInt(guildId) >> 22n) % BigInt(ws.botGatewayData.shards)),
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
if (options.addToCache) {
|
if (options.addToCache) {
|
||||||
await bot.cache.guilds.set(guild.id, guild);
|
await bot.cache.guilds.set(guild.id, guild);
|
||||||
|
|||||||
@@ -10,10 +10,17 @@ export async function getPruneCount(bot: Bot, guildId: bigint, options?: GetGuil
|
|||||||
|
|
||||||
await bot.utils.requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]);
|
await bot.utils.requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]);
|
||||||
|
|
||||||
const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_PRUNE(guildId), options ? {
|
const result = await bot.rest.runMethod(
|
||||||
|
bot.rest,
|
||||||
|
"get",
|
||||||
|
bot.constants.endpoints.GUILD_PRUNE(guildId),
|
||||||
|
options
|
||||||
|
? {
|
||||||
days: options.days,
|
days: options.days,
|
||||||
include_roles: options.includeRoles
|
include_roles: options.includeRoles,
|
||||||
} : {});
|
}
|
||||||
|
: {}
|
||||||
|
);
|
||||||
|
|
||||||
return result.pruned as number;
|
return result.pruned as number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ import type { Bot } from "../../bot.ts";
|
|||||||
|
|
||||||
/** Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. */
|
/** Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. */
|
||||||
export async function getVoiceRegions(boot: Bot, guildId: bigint) {
|
export async function getVoiceRegions(boot: Bot, guildId: bigint) {
|
||||||
const result = await bot.rest.runMethod<VoiceRegion[]>(bot.rest,"get", bot.constants.endpoints.GUILD_REGIONS(guildId));
|
const result = await bot.rest.runMethod<VoiceRegion[]>(
|
||||||
|
bot.rest,
|
||||||
|
"get",
|
||||||
|
bot.constants.endpoints.GUILD_REGIONS(guildId)
|
||||||
|
);
|
||||||
|
|
||||||
return new Collection<string, VoiceRegion>(result.map((region) => [region.id, region]));
|
return new Collection<string, VoiceRegion>(result.map((region) => [region.id, region]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,9 @@ import type { WelcomeScreen } from "../../types/guilds/welcome_screen.ts";
|
|||||||
import type { Bot } from "../../bot.ts";
|
import type { Bot } from "../../bot.ts";
|
||||||
|
|
||||||
export async function getWelcomeScreen(bot: Bot, guildId: bigint) {
|
export async function getWelcomeScreen(bot: Bot, guildId: bigint) {
|
||||||
return await bot.rest.runMethod<WelcomeScreen>(bot.rset,"get", bot.constants.endpoints.GUILD_WELCOME_SCREEN(guildId));
|
return await bot.rest.runMethod<WelcomeScreen>(
|
||||||
|
bot.rset,
|
||||||
|
"get",
|
||||||
|
bot.constants.endpoints.GUILD_WELCOME_SCREEN(guildId)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,9 @@ export async function getWidget(bot: Bot, guildId: bigint, options?: { force: bo
|
|||||||
if (!guild?.widgetEnabled) throw new Error(bot.constants.Errors.GUILD_WIDGET_NOT_ENABLED);
|
if (!guild?.widgetEnabled) throw new Error(bot.constants.Errors.GUILD_WIDGET_NOT_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await bot.rest.runMethod<GuildWidgetDetails>(bot.rest,"get", `${bot.constants.endpoints.GUILD_WIDGET(guildId)}.json`);
|
return await bot.rest.runMethod<GuildWidgetDetails>(
|
||||||
|
bot.rest,
|
||||||
|
"get",
|
||||||
|
`${bot.constants.endpoints.GUILD_WIDGET(guildId)}.json`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import type { Bot } from "../../bot.ts";
|
|||||||
import type { GetGuildWidgetImageQuery } from "../../types/guilds/get_guild_widget_image.ts";
|
import type { GetGuildWidgetImageQuery } from "../../types/guilds/get_guild_widget_image.ts";
|
||||||
|
|
||||||
/** Returns the widget image URL for the guild. */
|
/** Returns the widget image URL for the guild. */
|
||||||
export async function getWidgetImageURL(bot: Bot, guildId: bigint, options?: GetGuildWidgetImageQuery & { force?: boolean }) {
|
export async function getWidgetImageURL(
|
||||||
|
bot: Bot,
|
||||||
|
guildId: bigint,
|
||||||
|
options?: GetGuildWidgetImageQuery & { force?: boolean }
|
||||||
|
) {
|
||||||
if (!options?.force) {
|
if (!options?.force) {
|
||||||
const guild = await bot.cache.guilds.get(guildId);
|
const guild = await bot.cache.guilds.get(guildId);
|
||||||
if (!guild) throw new Error(bot.constants.Errors.GUILD_NOT_FOUND);
|
if (!guild) throw new Error(bot.constants.Errors.GUILD_NOT_FOUND);
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ export function guildIconURL(
|
|||||||
? bot.utils.formatImageURL(
|
? bot.utils.formatImageURL(
|
||||||
bot.constants.endpoints.GUILD_ICON(
|
bot.constants.endpoints.GUILD_ICON(
|
||||||
id,
|
id,
|
||||||
typeof options.icon === "string" ? options.icon : bot.utils.iconBigintToHash(options.icon, options.animated ?? true)
|
typeof options.icon === "string"
|
||||||
|
? options.icon
|
||||||
|
: bot.utils.iconBigintToHash(options.icon, options.animated ?? true)
|
||||||
),
|
),
|
||||||
options.size || 128,
|
options.size || 128,
|
||||||
options.format
|
options.format
|
||||||
|
|||||||
Reference in New Issue
Block a user