mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
allow structures to be overriden
This commit is contained in:
@@ -8,7 +8,6 @@ import { Errors } from "../types/errors.ts";
|
||||
import { RequestManager } from "../module/requestManager.ts";
|
||||
import { endpoints } from "../constants/discord.ts";
|
||||
import { MessageCreateOptions } from "../types/message.ts";
|
||||
import { createMessage } from "../structures/message.ts";
|
||||
import {
|
||||
GetMessagesAfter,
|
||||
GetMessagesBefore,
|
||||
@@ -20,6 +19,7 @@ import {
|
||||
FollowedChannelPayload,
|
||||
} from "../types/channel.ts";
|
||||
import { logYellow } from "../utils/logger.ts";
|
||||
import { structures } from "../structures/mod.ts";
|
||||
|
||||
/** Checks if a user id or a role id has permission in this channel */
|
||||
export function hasChannelPermission(
|
||||
@@ -63,7 +63,7 @@ export async function getMessage(channel: Channel, id: string) {
|
||||
const result = await RequestManager.get(
|
||||
endpoints.CHANNEL_MESSAGE(channel.id, id),
|
||||
) as MessageCreateOptions;
|
||||
return createMessage(result);
|
||||
return structures.createMessage(result);
|
||||
}
|
||||
|
||||
/** Fetches between 2-100 messages. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */
|
||||
@@ -97,7 +97,7 @@ export async function getMessages(
|
||||
endpoints.CHANNEL_MESSAGES(channel.id),
|
||||
options,
|
||||
)) as MessageCreateOptions[];
|
||||
return result.map((res) => createMessage(res));
|
||||
return result.map((res) => structures.createMessage(res));
|
||||
}
|
||||
|
||||
/** Get pinned messages in this channel. */
|
||||
@@ -105,7 +105,7 @@ export async function getPins(channelID: string) {
|
||||
const result = (await RequestManager.get(
|
||||
endpoints.CHANNEL_PINS(channelID),
|
||||
)) as MessageCreateOptions[];
|
||||
return result.map((res) => createMessage(res));
|
||||
return result.map((res) => structures.createMessage(res));
|
||||
}
|
||||
|
||||
/** Send a message to the channel. Requires SEND_MESSAGES permission. */
|
||||
@@ -177,7 +177,7 @@ export async function sendMessage(
|
||||
},
|
||||
);
|
||||
|
||||
return createMessage(result as MessageCreateOptions);
|
||||
return structures.createMessage(result as MessageCreateOptions);
|
||||
}
|
||||
|
||||
/** Delete messages from the channel. 2-100. Requires the MANAGE_MESSAGES permission */
|
||||
|
||||
+7
-12
@@ -1,13 +1,8 @@
|
||||
import { Guild } from "../structures/guild.ts";
|
||||
import { createChannel } from "../structures/channel.ts";
|
||||
|
||||
import { formatImageURL } from "../utils/cdn.ts";
|
||||
import { botHasPermission } from "../utils/permissions.ts";
|
||||
|
||||
import { RequestManager } from "../module/requestManager.ts";
|
||||
|
||||
import { endpoints } from "../constants/discord.ts";
|
||||
|
||||
import { Errors } from "../types/errors.ts";
|
||||
import { Permissions, Permission } from "../types/permission.ts";
|
||||
import {
|
||||
@@ -32,15 +27,15 @@ import {
|
||||
UserPayload,
|
||||
} from "../types/guild.ts";
|
||||
import { RoleData } from "../types/role.ts";
|
||||
import { createRole } from "../structures/role.ts";
|
||||
import { Intents } from "../types/options.ts";
|
||||
import { identifyPayload } from "../module/client.ts";
|
||||
import { requestAllMembers } from "../module/shardingManager.ts";
|
||||
import { MemberCreatePayload } from "../types/member.ts";
|
||||
import { cache } from "../utils/cache.ts";
|
||||
import { createMember, Member } from "../structures/member.ts";
|
||||
import { Member } from "../structures/member.ts";
|
||||
import { urlToBase64 } from "../utils/utils.ts";
|
||||
import { Collection } from "../utils/collection.ts";
|
||||
import { structures } from "../structures/mod.ts";
|
||||
|
||||
/** Gets an array of all the channels ids that are the children of this category. */
|
||||
export function categoryChildrenIDs(guild: Guild, id: string) {
|
||||
@@ -120,7 +115,7 @@ export async function createGuildChannel(
|
||||
type: options?.type || ChannelTypes.GUILD_TEXT,
|
||||
})) as ChannelCreatePayload;
|
||||
|
||||
const channel = createChannel(result);
|
||||
const channel = structures.createChannel(result);
|
||||
guild.channels.set(result.id, channel);
|
||||
return channel;
|
||||
}
|
||||
@@ -147,7 +142,7 @@ export async function getChannels(guildID: string, addToCache = true) {
|
||||
endpoints.GUILD_CHANNELS(guildID),
|
||||
) as ChannelCreatePayload[];
|
||||
return result.map((res) => {
|
||||
const channel = createChannel(res, guildID);
|
||||
const channel = structures.createChannel(res, guildID);
|
||||
if (addToCache) {
|
||||
cache.channels.set(channel.id, channel);
|
||||
}
|
||||
@@ -163,7 +158,7 @@ export async function getChannel(channelID: string, addToCache = true) {
|
||||
const result = await RequestManager.get(
|
||||
endpoints.GUILD_CHANNEL(channelID),
|
||||
) as ChannelCreatePayload;
|
||||
const channel = createChannel(result, result.guild_id);
|
||||
const channel = structures.createChannel(result, result.guild_id);
|
||||
if (addToCache) cache.channels.set(channel.id, channel);
|
||||
return channel;
|
||||
}
|
||||
@@ -194,7 +189,7 @@ export async function getMember(guildID: string, id: string) {
|
||||
endpoints.GUILD_MEMBER(guildID, id),
|
||||
) as MemberCreatePayload;
|
||||
|
||||
const member = createMember(data, guild);
|
||||
const member = structures.createMember(data, guild);
|
||||
guild.members.set(id, member);
|
||||
return member;
|
||||
}
|
||||
@@ -300,7 +295,7 @@ export async function createGuildRole(
|
||||
);
|
||||
|
||||
const roleData = result as RoleData;
|
||||
const role = createRole(roleData);
|
||||
const role = structures.createRole(roleData);
|
||||
const guild = cache.guilds.get(guildID);
|
||||
guild?.roles.set(role.id, role);
|
||||
return role;
|
||||
|
||||
@@ -13,9 +13,9 @@ import { Errors } from "../types/errors.ts";
|
||||
import { RequestManager } from "../module/requestManager.ts";
|
||||
import { MessageContent, DMChannelCreatePayload } from "../types/channel.ts";
|
||||
import { cache } from "../utils/cache.ts";
|
||||
import { createChannel } from "../structures/channel.ts";
|
||||
import { EditMemberOptions } from "../types/member.ts";
|
||||
import { sendMessage } from "./channel.ts";
|
||||
import { structures } from "../structures/mod.ts";
|
||||
|
||||
/** The users custom avatar or the default avatar if you don't have a member object. */
|
||||
export function rawAvatarURL(
|
||||
@@ -108,7 +108,7 @@ export async function sendDirectMessage(
|
||||
) as DMChannelCreatePayload;
|
||||
// Channel create event will have added this channel to the cache
|
||||
cache.channels.delete(dmChannelData.id);
|
||||
const channel = createChannel(dmChannelData);
|
||||
const channel = structures.createChannel(dmChannelData);
|
||||
// Recreate the channel and add it undert he users id
|
||||
cache.channels.set(memberID, channel);
|
||||
dmChannel = channel;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Message, createMessage } from "../structures/message.ts";
|
||||
import { Message } from "../structures/message.ts";
|
||||
import { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
|
||||
import { botID } from "../module/client.ts";
|
||||
import { Permissions } from "../types/permission.ts";
|
||||
@@ -9,6 +9,7 @@ import { botHasChannelPermissions } from "../utils/permissions.ts";
|
||||
import { MessageContent } from "../types/channel.ts";
|
||||
import { UserPayload } from "../types/guild.ts";
|
||||
import { MessageCreateOptions } from "../types/message.ts";
|
||||
import { structures } from "../structures/mod.ts";
|
||||
|
||||
/** Delete a message */
|
||||
export async function deleteMessage(
|
||||
@@ -221,7 +222,7 @@ export async function editMessage(
|
||||
endpoints.CHANNEL_MESSAGE(message.channelID, message.id),
|
||||
content,
|
||||
);
|
||||
return createMessage(result as MessageCreateOptions);
|
||||
return structures.createMessage(result as MessageCreateOptions);
|
||||
}
|
||||
|
||||
export async function publishMessage(channelID: string, messageID: string) {
|
||||
@@ -229,5 +230,5 @@ export async function publishMessage(channelID: string, messageID: string) {
|
||||
endpoints.CHANNEL_MESSAGE_CROSSPOST(channelID, messageID),
|
||||
) as MessageCreateOptions;
|
||||
|
||||
return createMessage(data);
|
||||
return structures.createMessage(data);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import { Permissions } from "../types/permission.ts";
|
||||
import { Errors } from "../types/errors.ts";
|
||||
import { RequestManager } from "../module/requestManager.ts";
|
||||
import { endpoints } from "../constants/discord.ts";
|
||||
import { createMessage } from "../structures/message.ts";
|
||||
import { MessageCreateOptions } from "../types/message.ts";
|
||||
import { urlToBase64 } from "../utils/utils.ts";
|
||||
import { structures } from "../structures/mod.ts";
|
||||
|
||||
/** Create a new webhook. Requires the MANAGE_WEBHOOKS permission. Returns a webhook object on success. Webhook names follow our naming restrictions that can be found in our Usernames and Nicknames documentation, with the following additional stipulations:
|
||||
*
|
||||
@@ -98,7 +98,7 @@ export async function executeWebhook(
|
||||
);
|
||||
if (!options.wait) return;
|
||||
|
||||
return createMessage(result as MessageCreateOptions);
|
||||
return structures.createMessage(result as MessageCreateOptions);
|
||||
}
|
||||
|
||||
export function getWebhook(webhookID: string) {
|
||||
|
||||
Reference in New Issue
Block a user