Skip to content

Instantly share code, notes, and snippets.

@s626ch
Forked from JoubaMety/README.md
Last active March 1, 2025 20:55
Show Gist options
  • Save s626ch/eaef5fd6f991ef8e51877b225ba95a3b to your computer and use it in GitHub Desktop.
Save s626ch/eaef5fd6f991ef8e51877b225ba95a3b to your computer and use it in GitHub Desktop.
Early Discord Mastodon Connection

howʻs it going guys

discord added mastodon linking! i took this script for early bsky linking and modified it, PLEASE read it, as you have to put in your own handle i donʻt know enough about powershell to make it give an input for the instance, so this is what weʻre making do with for the moment mostly original readme from parent gist below:

Prerequisites

Instructions

  1. paste the ps1 attached to this gist into powershell ISE
  2. replace the part that says "YOUR HANDLE HERE PUT YOUR HANDLE HERE" with your own handle, instructions are commented below on line 2
  3. script should spit out a link, paste into browser and authorize
  4. Profit!

Mastodon Connections on Discord

Caveats

  • While the Mastodon Connection will display on official Desktop/Browser client, it might not display on official Android/iOS client.
$discordApiUri = "https://discord.com/api/v9/connections/mastodon/authorize?handle=YOUR HANDLE HERE PUT YOUR HANDLE HERE"
# YOUR HANDLE SHOULD BE FORMATTED AS (USER)%40(INSTANCE).(TLD), DO NOT INCLUDE THE FIRST @.
$helpDiscordToken = "https://gist.github.com/MarvNC/e601f3603df22f36ebd3102c501116c6"
# Convert from Secure String to Plain Text (for Powershell below v7.0)
# Source: https://gist.github.com/JeremyTBradshaw/10c67244cf380a66b6ca0e59139cd11d
function ConvertFrom-SecureStringToPlainText ([System.Security.SecureString]$SecureString) {
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
)
}
New-Alias -Name s2p -Value ConvertFrom-SecureStringToPlainText
Write-Host "Help: Discord Token Get Tutorial: $helpDiscordToken" -f Yellow
$_token = s2p(Read-Host "Please enter your Discord token" -AsSecureString)
$request = try {
Invoke-WebRequest -Uri $discordApiUri -Headers @{"authorization"=$_token}
} catch {
$_obj = $_ | ConvertFrom-Json
Write-Host "$($_obj.message)" -f Red
if ($_obj.code -eq 0) { Write-Host "Possible reason for error: Invalid token" -f Yellow }
}
$reqContent = $request.Content | ConvertFrom-Json
$url = $reqContent.url
Write-Host "Successfully got link: " -f Green -NoNewline
Write-Host $url -f Blue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment