diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/discord.ts | 10 | ||||
-rw-r--r-- | src/utils/misc.tsx | 4 |
2 files changed, 14 insertions, 0 deletions
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<void> { + return new Promise(r => setTimeout(r, ms)); +} |