change: prettier code

This commit is contained in:
TriForMine
2021-10-21 16:07:35 +00:00
committed by GitHub Action
parent fe22c5ea73
commit 9a1f8f41a5
14 changed files with 112 additions and 68 deletions
+10 -3
View File
@@ -5,10 +5,17 @@ import type {Bot} from "../../bot.ts";
export async function ban(bot: Bot, guildId: bigint, id: bigint, options?: CreateGuildBan) {
await bot.utils.requireBotGuildPermissions(bot, guildId, ["BAN_MEMBERS"]);
return await bot.rest.runMethod<undefined>(bot.rest,"put", bot.constants.endpoints.GUILD_BAN(guildId, id), (options ? {
return await bot.rest.runMethod<undefined>(
bot.rest,
"put",
bot.constants.endpoints.GUILD_BAN(guildId, id),
options
? {
delete_message_days: options.deleteMessageDays,
reason: options.reason
} : {}));
reason: options.reason,
}
: {}
);
}
// aliases
+7 -2
View File
@@ -4,9 +4,14 @@ import type {Bot} from "../../bot.ts";
export async function editBotNickname(bot: Bot, guildId: bigint, nickname: string | null) {
await bot.utils.requireBotGuildPermissions(bot, guildId, ["CHANGE_NICKNAME"]);
const response = await bot.rest.runMethod<{ nick: string }>(bot.rest,"patch", bot.constants.endpoints.USER_NICK(guildId), {
const response = await bot.rest.runMethod<{ nick: string }>(
bot.rest,
"patch",
bot.constants.endpoints.USER_NICK(guildId),
{
nick: nickname,
});
}
);
return response.nick;
}
+1 -1
View File
@@ -52,7 +52,7 @@ export async function editMember(bot: Bot, guildId: bigint, memberId: bigint, op
roles: options.roles,
mute: options.mute,
deaf: options.deaf,
channel_id: options.channelId
channel_id: options.channelId,
}
);
+6 -1
View File
@@ -13,7 +13,12 @@ import type {DiscordenoMember} from "../../transformers/member.ts";
* REST: 50/s global(across all shards) rate limit with ALL requests this included
* GW(this function): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is now 960/m.
*/
export function fetchMembers(bot: Bot, guildId: bigint, shardId: number, options?: Omit<RequestGuildMembers, "guildId">) {
export function fetchMembers(
bot: Bot,
guildId: bigint,
shardId: number,
options?: Omit<RequestGuildMembers, "guildId">
) {
// You can request 1 member without the intent
// Check if intents is not 0 as proxy ws won't set intents in other instances
if (
+5 -1
View File
@@ -10,7 +10,11 @@ export async function getMember(bot: Bot, guildId: bigint, id: bigint, options?:
const guild = await bot.cache.guilds.get(guildId);
if (!guild && !options?.force) return;
const data = await bot.rest.runMethod<SnakeCasedPropertiesDeep<GuildMemberWithUser>>(bot.rest,"get", bot.constants.endpoints.GUILD_MEMBER(guildId, id));
const data = await bot.rest.runMethod<SnakeCasedPropertiesDeep<GuildMemberWithUser>>(
bot.rest,
"get",
bot.constants.endpoints.GUILD_MEMBER(guildId, id)
);
const discordenoMember = await bot.transformers.member(bot, data, guildId);
await bot.cache.members.set(discordenoMember.id, discordenoMember);
+4 -1
View File
@@ -16,7 +16,10 @@ import type {SnakeCasedPropertiesDeep} from "../../types/util.ts";
*/
export async function getMembers(bot: Bot, guildId: bigint, options?: ListGuildMembers & { addToCache?: boolean }) {
// Check if intents is not 0 as proxy ws won't set intents in other instances
if (bot.gateway.identifyPayload.intents && !(bot.gateway.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)) {
if (
bot.gateway.identifyPayload.intents &&
!(bot.gateway.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)
) {
throw new Error(bot.cache.Errors.MISSING_INTENT_GUILD_MEMBERS);
}
+6 -1
View File
@@ -9,7 +9,12 @@ export async function kick(bot: Bot, guildId: bigint, memberId: bigint, reason?:
await bot.utils.requireBotGuildPermissions(bot, guildId, ["KICK_MEMBERS"]);
return await bot.rest.runMethod<undefined>(bot.rest,"delete", bot.constants.endpoints.GUILD_MEMBER(guildId, memberId), { reason });
return await bot.rest.runMethod<undefined>(
bot.rest,
"delete",
bot.constants.endpoints.GUILD_MEMBER(guildId, memberId),
{ reason }
);
}
// aliases
+8 -3
View File
@@ -12,11 +12,16 @@ export async function pruneMembers(bot: Bot, guildId: bigint, options: BeginGuil
await bot.utils.requireBotGuildPermissions(bot, guildId, ["KICK_MEMBERS"]);
const result = await bot.rest.runMethod<{ pruned: number }>(bot.rest,"post", bot.constants.endpoints.GUILD_PRUNE(guildId), {
const result = await bot.rest.runMethod<{ pruned: number }>(
bot.rest,
"post",
bot.constants.endpoints.GUILD_PRUNE(guildId),
{
days: options.days,
compute_prune_count: options.computePruneCount,
include_roles: options.includeRoles
});
include_roles: options.includeRoles,
}
);
return result.pruned;
}
+7 -2
View File
@@ -25,10 +25,15 @@ export async function searchMembers(
}
}
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<GuildMemberWithUser>[]>(bot.rest,"get", bot.constants.endpoints.GUILD_MEMBERS_SEARCH(guildId), {
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<GuildMemberWithUser>[]>(
bot.rest,
"get",
bot.constants.endpoints.GUILD_MEMBERS_SEARCH(guildId),
{
...options,
query,
});
}
);
const members = await Promise.all(
result.map(async (member) => {
+7 -2
View File
@@ -10,9 +10,14 @@ export async function sendDirectMessage(bot: Bot, memberId: bigint, content: str
let dmChannel = await bot.cache.channels.get(memberId);
if (!dmChannel) {
// If not available in cache create a new one.
const dmChannelData = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Channel>>(bot.rest,"post", bot.constants.endpoints.USER_DM, {
const dmChannelData = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Channel>>(
bot.rest,
"post",
bot.constants.endpoints.USER_DM,
{
recipient_id: memberId,
});
}
);
const discordenoChannel = await bot.transformers.channel(bot, dmChannelData);
// Recreate the channel and add it under the users id
await bot.cache.channels.set(memberId, discordenoChannel);