Skip to content

Instantly share code, notes, and snippets.

@Phoenix616
Last active September 27, 2020 22:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Simple php scripts to redirect to anonymous Discord invite links from a server's widget settings.

Anonvite

Simple php scripts to redirect to anonymous Discord invite links from a server's widget settings.

These will not show a specific user who invited as well as automatically connect to the text channel specified in the widget settings. (And if the widget/invite is disabled it will just not work)

Example

Usage

anonvite.php?serverid=<id> You can get that ID from your server's widget settings after enabling it.

Server ID

You should be caching this somewhow to not spam Discord's API and maybe use some cool URL syntax.

Example

A hosted version is available at https://anonvite.moep.tv/<serverid> (Alias: discvite.moep.tv)

License

AGPLv3

<?php
/*
* Anonymous Discord invite link generator
* Copyright (C) 2020 Max Lee aka Phoenix616 (max@themoep.de)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (!isset($_GET['serverid']) || !preg_match("/^\d+$/", $_GET['serverid'])) {
http_response_code(400);
die();
return;
}
$widgetUrl = "https://discord.com/api/guilds/" . $_GET['serverid'] . "/widget.json";
$json = file_get_contents($widgetUrl);
$widget = json_decode($json);
if (!isset($widget->instant_invite)) {
http_response_code(404);
die();
return;
}
header("Location: " . $widget->instant_invite);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment