Discord whoami (signed-in account)
Report which Discord account this browser is signed in as: the user id, username, display name and email. Fails with a signed-out error when the browser is not signed in to Discord, or when Discord is open in another tab of the same account.
Input
None
Output
name requiredThe display name Discord shows.
email requireduserId requiredloggedIn requiredAlways true: signed out is a SignedOutError.
username requiredFAQ
Read Discord messages
Reads the messages of one Discord channel or direct message, newest first, up to limit. To read further back, pass nextBefore from the answer as before: each call goes on from there, so a whole history is read in pages, and complete is true once the start of the channel is reached. before also takes any message id to start from. Each message comes with its author, timestamp, text and edit time, its attachments (file name, link, type, size and image dimensions), its embeds and link previews (title, description, provider, image, thumbnail and video), its stickers, and the message it replies to. Attachment links expire after about a day, so download them soon. Reading marks nothing as read. A long read stops after about 10 minutes with complete false and nextBefore set. Requires being signed in. A DM or group DM is read the same way: pass its url from discord.com/list_dms. It also reads a thread or a forum post, since both are channels in their own right: pass the post's url (from discord.com/list_forum_posts). To list the posts of a forum channel rather than its messages, use discord.com/list_forum_posts. To read several channels, run the script once per channel.
Search Discord server messages
Search one Discord server's message history with Discord's own search, as the signed-in account, newest first. Search by words (content), and narrow by authors, channels, mentioned users and content type, each given as ids: get user ids from discord.com/get_member_list and channel ids from discord.com/list_channels. Returns one page of up to 25 matching messages with their author, text, time and link, Discord's total count of matches, and next_offset to read the next page (null on the last one). Fails with a clear error when the browser is not signed in to Discord, when the account is not a member of the server or can see no text channel in it, or when Discord is still indexing the server. Direct messages are not searched.
List Discord direct messages
Lists the direct messages (DMs) of the signed-in Discord account, one-to-one and group DMs, most recent first, as the Direct Messages sidebar shows them: the conversation's name, its channelId, its url, whether it has unread messages (unread) and the number on its sidebar badge (mentionCount, 0 when none; in a DM Discord counts each unread message). Reading the list marks nothing as read. Pass a conversation's url to discord.com/read_messages to read it, or use discord.com/list_unreads for the unread messages themselves. Requires being logged in.
