This commit is contained in:
Skillz
2020-05-12 11:32:13 -04:00
parent c9c66f73b7
commit fc7700c8e6
5 changed files with 13 additions and 19 deletions

View File

@@ -10,8 +10,6 @@ import { cache } from "../utils/cache.ts";
export let authorization = "";
export let botID = "";
/** The bot's token. This should never be used by end users. It is meant to be used internally to make requests to the Discord API. */
export let token = "";
export let eventHandlers: EventHandlers = {};
@@ -31,7 +29,6 @@ export const identifyPayload = {
export const createClient = async (data: ClientOptions) => {
botID = data.botID;
token = data.token;
if (data.eventHandlers) eventHandlers = data.eventHandlers;
authorization = `Bot ${data.token}`;

View File

@@ -12,7 +12,6 @@ import {
import { logRed } from "../utils/logger.ts";
import { sendConstantHeartbeats, previousSequenceNumber } from "./gateway.ts";
logRed("shard file running");
export const USELESS_ARG_TO_MAKE_DENO_CACHE_WORK = undefined;
/** The session id is needed for RESUME functionality when discord disconnects randomly. */
let sessionID = "";

View File

@@ -315,7 +315,7 @@ function handleDiscordPayload(data: DiscordPayload) {
guild?.members.set(
options.author.id,
createMember(
options.member,
{ ...options.member, user: options.author },
options.guild_id,
[...guild.roles.values()].map((r) => r.raw),
guild.owner_id,

View File

@@ -88,19 +88,17 @@ export function createChannel(data: ChannelCreatePayload) {
if (options?.limit && options.limit > 100) return;
const result =
(await RequestManager.get(
endpoints.CHANNEL_MESSAGES(data.id),
options,
)) as MessageCreateOptions[];
const result = (await RequestManager.get(
endpoints.CHANNEL_MESSAGES(data.id),
options,
)) as MessageCreateOptions[];
return result.map((res) => createMessage(res));
},
/** Get pinned messages in this channel. */
getPins: async () => {
const result =
(await RequestManager.get(
endpoints.CHANNEL_PINS(data.id),
)) as MessageCreateOptions[];
const result = (await RequestManager.get(
endpoints.CHANNEL_PINS(data.id),
)) as MessageCreateOptions[];
return result.map((res) => createMessage(res));
},
/** Send a message to the channel. Requires SEND_MESSAGES permission. */
@@ -133,6 +131,7 @@ export function createChannel(data: ChannelCreatePayload) {
endpoints.CHANNEL_MESSAGES(data.id),
content,
);
console.log(result);
return createMessage(result);
},

View File

@@ -229,11 +229,10 @@ export const createGuild = (data: CreateGuildPayload) => {
) {
throw new Error(Errors.MISSING_KICK_MEMBERS);
}
const result =
(await RequestManager.get(
endpoints.GUILD_PRUNE(data.id),
{ days },
)) as PrunePayload;
const result = (await RequestManager.get(
endpoints.GUILD_PRUNE(data.id),
{ days },
)) as PrunePayload;
return result.pruned;
},
/** Begin pruning all members in the given time period */