refactor: typings using ReturnType (#2105)

* fix: check new types idea

* fix: type errors

* fix: new style

* fix: more cleanup

* fix: more cleanup

* fix: cleanup audit logs

* fix: cleanup stickers

* fix: cleanup integrations

* fix: more cleanup

* fix: organize into 1 place

* fix: few errors

* fix: some broken import fixes

* fix: quite a lot of fixes across the board

* fix: more fixes for broken imports

* fix: more fixes for broken imports

* fix: handler imports

* fix: all remaining import errors

* fix: more errors needing fixes

* fix: clearing up transformers

* fix: few moer types

* fix: more cleanup of extra types

* fix: fmt

* fix: cleanup discordeno file

* Nuke Base Types (#2102)

* fix: cleanup snake stuff

* convert camelCase to snake_case (#2103)

* fix: add camelize

* fix: finalize remaining errors

* fix: imports in test

Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
This commit is contained in:
Skillz4Killz
2022-03-14 22:11:22 -04:00
committed by GitHub
parent da29ff294d
commit a0a1554756
505 changed files with 5647 additions and 7106 deletions
+2 -5
View File
@@ -1,11 +1,8 @@
import type { Channel } from "../../types/channels/channel.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import type { Bot } from "../../bot.ts";
import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
export async function handleChannelCreate(bot: Bot, payload: DiscordGatewayPayload) {
const channel = bot.transformers.channel(bot, { channel: payload.d as SnakeCasedPropertiesDeep<Channel> });
const channel = bot.transformers.channel(bot, { channel: payload.d as DiscordChannel });
bot.events.channelCreate(bot, channel);
}
+2 -4
View File
@@ -1,10 +1,8 @@
import type { Channel } from "../../types/channels/channel.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import type { Bot } from "../../bot.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
export async function handleChannelDelete(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
const payload = data.d as DiscordChannel;
if (!payload.guild_id) return;
bot.events.channelDelete(
+2 -4
View File
@@ -1,10 +1,8 @@
import type { Bot } from "../../bot.ts";
import type { ChannelPinsUpdate } from "../../types/channels/channelPinsUpdate.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordChannelPinsUpdate, DiscordGatewayPayload } from "../../types/discord.ts";
export async function handleChannelPinsUpdate(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<ChannelPinsUpdate>;
const payload = data.d as DiscordChannelPinsUpdate;
bot.events.channelPinsUpdate(bot, {
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
+2 -4
View File
@@ -1,10 +1,8 @@
import type { Bot } from "../../bot.ts";
import type { Channel } from "../../types/channels/channel.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
export async function handleChannelUpdate(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
const payload = data.d as DiscordChannel;
const channel = bot.transformers.channel(bot, { channel: payload });
bot.events.channelUpdate(bot, channel);
+2 -4
View File
@@ -1,10 +1,8 @@
import type { Bot } from "../../bot.ts";
import type { StageInstance } from "../../types/channels/stageInstance.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts";
export function handleStageInstanceCreate(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<StageInstance>;
const payload = data.d as DiscordStageInstance;
bot.events.stageInstanceCreate(bot, {
id: bot.transformers.snowflake(payload.id),
+2 -4
View File
@@ -1,10 +1,8 @@
import type { Bot } from "../../bot.ts";
import type { StageInstance } from "../../types/channels/stageInstance.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts";
export function handleStageInstanceDelete(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<StageInstance>;
const payload = data.d as DiscordStageInstance;
bot.events.stageInstanceDelete(bot, {
id: bot.transformers.snowflake(payload.id),
+2 -4
View File
@@ -1,10 +1,8 @@
import type { Bot } from "../../bot.ts";
import type { StageInstance } from "../../types/channels/stageInstance.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts";
export function handleStageInstanceUpdate(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<StageInstance>;
const payload = data.d as DiscordStageInstance;
bot.events.stageInstanceUpdate(bot, {
id: bot.transformers.snowflake(payload.id),
+2 -4
View File
@@ -1,10 +1,8 @@
import { Bot } from "../../bot.ts";
import { Channel } from "../../types/channels/channel.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
export async function handleThreadCreate(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
const payload = data.d as DiscordChannel;
bot.events.threadCreate(bot, bot.transformers.channel(bot, { channel: payload }));
}
+2 -4
View File
@@ -1,9 +1,7 @@
import { Bot } from "../../bot.ts";
import { Channel } from "../../types/channels/channel.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
export async function handleThreadDelete(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
const payload = data.d as DiscordChannel;
bot.events.threadDelete(bot, bot.transformers.channel(bot, { channel: payload }));
}
+2 -4
View File
@@ -1,10 +1,8 @@
import { Bot } from "../../bot.ts";
import { ThreadListSync } from "../../types/channels/threads/threadListSync.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordGatewayPayload, DiscordThreadListSync } from "../../types/discord.ts";
export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<ThreadListSync>;
const payload = data.d as DiscordThreadListSync;
const guildId = bot.transformers.snowflake(payload.guild_id);
return {
+2 -4
View File
@@ -1,10 +1,8 @@
import { Bot } from "../../bot.ts";
import { ThreadMembersUpdate } from "../../types/channels/threads/threadMembersUpdate.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordGatewayPayload, DiscordThreadMembersUpdate } from "../../types/discord.ts";
export async function handleThreadMembersUpdate(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<ThreadMembersUpdate>;
const payload = data.d as DiscordThreadMembersUpdate;
bot.events.threadMembersUpdate(bot, {
id: bot.transformers.snowflake(payload.id),
guildId: bot.transformers.snowflake(payload.guild_id),
+1 -1
View File
@@ -1,5 +1,5 @@
import { Bot } from "../../bot.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { DiscordGatewayPayload } from "../../types/discord.ts";
export async function handleThreadMemberUpdate(bot: Bot, data: DiscordGatewayPayload) {
// This event is documented for completeness, but unlikely to be used by most bots
+2 -4
View File
@@ -1,10 +1,8 @@
import { Bot } from "../../bot.ts";
import { Channel } from "../../types/channels/channel.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
export async function handleThreadUpdate(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
const payload = data.d as DiscordChannel;
bot.events.threadUpdate(bot, bot.transformers.channel(bot, { channel: payload }));
}