From 2105de8ca54b17a852a86efa476a4e575042b5a6 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 9 Oct 2022 19:48:42 +0200 Subject: Add more Webpack Commons & utils --- src/utils/discord.ts | 10 ++++++++++ src/utils/misc.tsx | 4 ++++ 2 files changed, 14 insertions(+) create mode 100644 src/utils/discord.ts (limited to 'src/utils') diff --git a/src/utils/discord.ts b/src/utils/discord.ts new file mode 100644 index 0000000..53206bb --- /dev/null +++ b/src/utils/discord.ts @@ -0,0 +1,10 @@ +import { Guild } from "discord-types/general"; +import { ChannelStore, SelectedChannelStore, GuildStore } from "../webpack/common"; + +export function getCurrentChannel() { + return ChannelStore.getChannel(SelectedChannelStore.getChannelId()); +} + +export function getCurrentGuild(): Guild | undefined { + return GuildStore.getGuild(getCurrentChannel()?.guild_id); +} diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index f2228f8..a7d781a 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -125,3 +125,7 @@ export function humanFriendlyJoin(elements: any[], mapper: (e: any) => string = export function classes(...classes: string[]) { return classes.join(" "); } + +export function sleep(ms: number): Promise { + return new Promise(r => setTimeout(r, ms)); +} -- cgit