Created
February 5, 2025 19:42
-
-
Save thomasrayner/f09604ed296612eca47ab86759a0a2a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Mandatory = $true, HelpMessage = "Enter your Discord token. Open Discord in your web browser. Press Ctrl + Shift + I to open the developer tools. Go to the Network tab and look for a request from discord.com. Click on a request and under the Headers tab, look for the Authorization header. Copy the value of the Authorization header - this is your token. Do not share your token with anyone, ever.")] | |
| [string] | |
| $DiscordToken | |
| ) | |
| $baseUrl = "https://discord.com/api/v9" | |
| $headers = @{ | |
| "Authorization" = $discordToken | |
| } | |
| $guilds = Invoke-RestMethod -Uri "$baseUrl/users/@me/guilds" -Headers $headers | |
| $emojisDir = "DiscordEmojis" | |
| if (-Not (Test-Path -Path $emojisDir)) { | |
| New-Item -Path $emojisDir -ItemType Directory | Out-Null | |
| } | |
| foreach ($guild in $guilds) { | |
| $guildName = ($guild.name -replace '[^\w\s-]', '').Trim() | |
| $guildEmojiDir = Join-Path -Path $emojisDir -ChildPath $guildName | |
| $response = Read-Host "Do you want to download emojis from the server '$guildName'? (y/n)" | |
| if ($response -eq 'y') { | |
| if (-Not (Test-Path -Path $guildEmojiDir)) { | |
| New-Item -Path $guildEmojiDir -ItemType Directory | Out-Null | |
| } | |
| $emojis = Invoke-RestMethod -Uri "$baseUrl/guilds/$($guild.id)/emojis" -Headers $headers | |
| foreach ($emoji in $emojis) { | |
| $emojiId = $emoji.id | |
| $emojiName = $emoji.name | |
| $isAnimated = $emoji.animated | |
| if ($isAnimated) { | |
| $fileExtension = "gif" | |
| } else { | |
| $fileExtension = "png" | |
| } | |
| $emojiUrl = "https://cdn.discordapp.com/emojis/$emojiId.$fileExtension" | |
| $emojiPath = Join-Path -Path $guildEmojiDir -ChildPath "$emojiName.$fileExtension" | |
| Invoke-RestMethod -Uri $emojiUrl -OutFile $emojiPath | |
| Write-Host "Downloaded $emojiName from $guildName" | |
| } | |
| } else { | |
| Write-Host "Skipping $guildName" | |
| } | |
| } | |
| Write-Host "Download complete. All emojis saved in $emojisDir." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment