mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 09:50:07 +00:00
rename to mod.ts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { DiscordPayload, GuildBanPayload } from "../../types/types.ts";
|
||||
import { DiscordPayload, GuildBanPayload } from "../../types/mod.ts";
|
||||
import { cacheHandlers } from "./cache.ts";
|
||||
|
||||
export async function handleInternalGuildBanAdd(data: DiscordPayload) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PresenceUpdatePayload } from "../../types/types.ts";
|
||||
import { PresenceUpdatePayload } from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { Channel, Guild, Member, Message } from "../structures/structures.ts";
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
ChannelCreatePayload,
|
||||
ChannelTypes,
|
||||
DiscordPayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { structures } from "../structures/structures.ts";
|
||||
import { cacheHandlers } from "./cache.ts";
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
GuildEmojisUpdatePayload,
|
||||
GuildUpdateChange,
|
||||
UpdateGuildPayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { structures } from "../structures/structures.ts";
|
||||
import { cacheHandlers } from "./cache.ts";
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import {
|
||||
DiscordPayload,
|
||||
InteractionCommandPayload,
|
||||
} from "../../types/types.ts";
|
||||
import { DiscordPayload, InteractionCommandPayload } from "../../types/mod.ts";
|
||||
import { structures } from "../structures/mod.ts";
|
||||
|
||||
export async function handleInternalInteractionsCreate(data: DiscordPayload) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
GuildMemberAddPayload,
|
||||
GuildMemberChunkPayload,
|
||||
GuildMemberUpdatePayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { structures } from "../structures/structures.ts";
|
||||
import { cacheHandlers } from "./cache.ts";
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
MessageCreateOptions,
|
||||
MessageDeleteBulkPayload,
|
||||
MessageDeletePayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { structures } from "../structures/structures.ts";
|
||||
import { cacheHandlers } from "./cache.ts";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
UserPayload,
|
||||
VoiceStateUpdatePayload,
|
||||
WebhookUpdatePayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { delay } from "../../util/utils.ts";
|
||||
import { allowNextShard } from "../../ws/shard_manager.ts";
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
DiscordPayload,
|
||||
MessageReactionPayload,
|
||||
MessageReactionRemoveEmojiPayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { structures } from "../structures/structures.ts";
|
||||
import { cacheHandlers } from "./cache.ts";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
DiscordPayload,
|
||||
GuildRoleDeletePayload,
|
||||
GuildRolePayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { structures } from "../structures/structures.ts";
|
||||
import { cacheHandlers } from "./cache.ts";
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
Permissions,
|
||||
RawOverwrite,
|
||||
WebhookPayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
botHasChannelPermissions,
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
RoleData,
|
||||
UpdateGuildPayload,
|
||||
UserPayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { botHasPermission, calculateBits } from "../../util/permissions.ts";
|
||||
@@ -416,9 +416,9 @@ export async function pruneMembers(guildID: string, options: PruneOptions) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get()
|
||||
*
|
||||
*
|
||||
* ADVANCED:
|
||||
* Highly recommended to use this function to fetch members instead of getMember from REST.
|
||||
* REST: 50/s global(across all shards) rate limit with ALL requests this included
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
ImageFormats,
|
||||
ImageSize,
|
||||
MessageContent,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
botHasPermission,
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
MessageContent,
|
||||
MessageCreateOptions,
|
||||
UserPayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { botHasChannelPermissions } from "../../util/permissions.ts";
|
||||
import { delay } from "../../util/utils.ts";
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
UpsertSlashCommandOptions,
|
||||
WebhookCreateOptions,
|
||||
WebhookPayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { botHasChannelPermissions } from "../../util/permissions.ts";
|
||||
@@ -186,7 +186,7 @@ export function deleteWebhookMessage(
|
||||
* - Your app **cannot** have two guild commands within the same name **on the same guild**
|
||||
* - Your app **can** have a global and guild command with the same name
|
||||
* - Multiple apps **can** have commands with the same names
|
||||
*
|
||||
*
|
||||
* Global commands are cached for **1 hour**. That means that new global commands will fan out slowly across all guilds, and will be guaranteed to be updated in an hour.
|
||||
* Guild commands update **instantly**. We recommend you use guild commands for quick testing, and global commands when they're ready for public use.
|
||||
*/
|
||||
@@ -257,7 +257,7 @@ export function deleteSlashCommand(id: string, guildID?: string) {
|
||||
/**
|
||||
* Send a response to a users slash command. The command data will have the id and token necessary to respond.
|
||||
* Interaction `tokens` are valid for **15 minutes** and can be used to send followup messages.
|
||||
*
|
||||
*
|
||||
* NOTE: By default we will suppress mentions. To enable mentions, just pass any mentions object.
|
||||
*/
|
||||
export function executeSlashCommand(
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
ChannelCreatePayload,
|
||||
ChannelType,
|
||||
RawOverwrite,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { createNewProp } from "../../util/utils.ts";
|
||||
@@ -93,15 +93,15 @@ export interface Channel {
|
||||
|
||||
// GETTERS
|
||||
|
||||
/**
|
||||
/**
|
||||
* Gets the guild object for this channel.
|
||||
*
|
||||
*
|
||||
* ⚠️ ADVANCED: If you use the custom cache, these will not work for you. Getters can not be async and custom cache requires async.
|
||||
*/
|
||||
guild?: Guild;
|
||||
/**
|
||||
/**
|
||||
* Gets the messages from cache that were sent in this channel
|
||||
*
|
||||
*
|
||||
* ⚠️ ADVANCED: If you use the custom cache, these will not work for you. Getters can not be async and custom cache requires async.
|
||||
*/
|
||||
messages: Collection<string, Message>;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { botID } from "../../bot.ts";
|
||||
import {
|
||||
BannedUser,
|
||||
ChannelCreatePayload,
|
||||
CreateGuildPayload,
|
||||
Emoji,
|
||||
GetAuditLogsOptions,
|
||||
@@ -11,8 +12,9 @@ import {
|
||||
ImageSize,
|
||||
MemberCreatePayload,
|
||||
Presence,
|
||||
RoleData,
|
||||
VoiceState,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { createNewProp } from "../../util/utils.ts";
|
||||
@@ -133,11 +135,13 @@ export async function createGuild(data: CreateGuildPayload, shardID: number) {
|
||||
} = data;
|
||||
|
||||
const roles = await Promise.all(
|
||||
data.roles.map((r) => structures.createRole(r)),
|
||||
);
|
||||
data.roles.map((r: RoleData) => structures.createRole(r)),
|
||||
) as Role[];
|
||||
|
||||
await Promise.all(
|
||||
channels.map((c) => structures.createChannel(c, data.id)),
|
||||
channels.map((c: ChannelCreatePayload) =>
|
||||
structures.createChannel(c, data.id)
|
||||
),
|
||||
);
|
||||
|
||||
const restProps: Record<string, ReturnType<typeof createNewProp>> = {};
|
||||
@@ -170,14 +174,14 @@ export async function createGuild(data: CreateGuildPayload, shardID: number) {
|
||||
premiumTier: createNewProp(premiumTier),
|
||||
premiumSubscriptionCount: createNewProp(premiumSubscriptionCount),
|
||||
preferredLocale: createNewProp(preferredLocale),
|
||||
roles: createNewProp(new Collection(roles.map((r) => [r.id, r]))),
|
||||
roles: createNewProp(new Collection(roles.map((r: Role) => [r.id, r]))),
|
||||
joinedAt: createNewProp(Date.parse(joinedAt)),
|
||||
presences: createNewProp(
|
||||
new Collection(data.presences.map((p) => [p.user.id, p])),
|
||||
new Collection(data.presences.map((p: Presence) => [p.user.id, p])),
|
||||
),
|
||||
memberCount: createNewProp(memberCount || 0),
|
||||
voiceStates: createNewProp(
|
||||
new Collection(voiceStates.map((vs) => [vs.user_id, {
|
||||
new Collection(voiceStates.map((vs: VoiceState) => [vs.user_id, {
|
||||
...vs,
|
||||
guildID: vs.guild_id,
|
||||
channelID: vs.channel_id,
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
GuildMember,
|
||||
MemberCreatePayload,
|
||||
MessageContent,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { createNewProp } from "../../util/utils.ts";
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
Reaction,
|
||||
Reference,
|
||||
UserPayload,
|
||||
} from "../../types/types.ts";
|
||||
} from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { createNewProp } from "../../util/utils.ts";
|
||||
import { sendMessage } from "../handlers/channel.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CreateRoleOptions, RoleData } from "../../types/types.ts";
|
||||
import { CreateRoleOptions, RoleData } from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { createNewProp } from "../../util/utils.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GuildTemplate, UserPayload } from "../../types/types.ts";
|
||||
import { GuildTemplate, UserPayload } from "../../types/mod.ts";
|
||||
import { cache } from "../../util/cache.ts";
|
||||
import { createNewProp } from "../../util/utils.ts";
|
||||
import { Guild } from "./guild.ts";
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
BotConfig,
|
||||
DiscordBotGatewayData,
|
||||
EventHandlers,
|
||||
} from "./types/types.ts";
|
||||
} from "./types/mod.ts";
|
||||
import { baseEndpoints, endpoints, GATEWAY_VERSION } from "./util/constants.ts";
|
||||
import { spawnShards } from "./ws/shard_manager.ts";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { authorization, eventHandlers } from "../bot.ts";
|
||||
import { Errors, HttpResponseCode, RequestMethods } from "../types/types.ts";
|
||||
import { Errors, HttpResponseCode, RequestMethods } from "../types/mod.ts";
|
||||
import {
|
||||
API_VERSION,
|
||||
BASE_URL,
|
||||
|
||||
@@ -8,7 +8,6 @@ export * from "./guild.ts";
|
||||
export * from "./interactions.ts";
|
||||
export * from "./member.ts";
|
||||
export * from "./message.ts";
|
||||
export * from "./misc.ts";
|
||||
export * from "./options.ts";
|
||||
export * from "./permission.ts";
|
||||
export * from "./presence.ts";
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
Member,
|
||||
Message,
|
||||
} from "../api/structures/structures.ts";
|
||||
import { PresenceUpdatePayload } from "../types/types.ts";
|
||||
import { PresenceUpdatePayload } from "../types/mod.ts";
|
||||
import { Collection } from "./collection.ts";
|
||||
|
||||
export interface CacheData {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { cacheHandlers } from "../api/controllers/cache.ts";
|
||||
import { Guild, Role } from "../api/structures/structures.ts";
|
||||
import { botID } from "../bot.ts";
|
||||
import { Permission, Permissions, RawOverwrite } from "../types/types.ts";
|
||||
import { Permission, Permissions, RawOverwrite } from "../types/mod.ts";
|
||||
|
||||
/** Checks if the member has this permission. If the member is an owner or has admin perms it will always be true. */
|
||||
export async function memberIDHasPermission(
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
ImageFormats,
|
||||
ImageSize,
|
||||
StatusType,
|
||||
} from "../types/types.ts";
|
||||
} from "../types/mod.ts";
|
||||
import { sendGatewayCommand } from "../ws/shard_manager.ts";
|
||||
|
||||
export const sleep = (timeout: number) => {
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
FetchMembersOptions,
|
||||
GatewayOpcode,
|
||||
ReadyPayload,
|
||||
} from "../types/types.ts";
|
||||
} from "../types/mod.ts";
|
||||
import { BotStatusRequest, delay } from "../util/utils.ts";
|
||||
import { decompressWith } from "./deps.ts";
|
||||
import { handleDiscordPayload } from "./shard_manager.ts";
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
DiscordPayload,
|
||||
FetchMembersOptions,
|
||||
GatewayOpcode,
|
||||
} from "../types/types.ts";
|
||||
} from "../types/mod.ts";
|
||||
import { cache } from "../util/cache.ts";
|
||||
import { BotStatusRequest, delay } from "../util/utils.ts";
|
||||
import {
|
||||
|
||||
Reference in New Issue
Block a user