role to discord user
added the ability to give a role to the discord user that has verified there discord
This commit is contained in:
parent
c9571988a5
commit
4b628988ee
|
@ -25,8 +25,10 @@ PAYPAL_EMAIL=
|
||||||
DISCORD_CLIENT_ID=
|
DISCORD_CLIENT_ID=
|
||||||
DISCORD_CLIENT_SECRET=
|
DISCORD_CLIENT_SECRET=
|
||||||
#set-up will join users automaticly to your discord
|
#set-up will join users automaticly to your discord
|
||||||
DISCORD_BOT_TOKEN=YOUR_DISCORD_BOT_TOKEN
|
DISCORD_BOT_TOKEN=
|
||||||
DISCORD_GUILD_ID=YOUR_DISCORD_SERVER_ID
|
DISCORD_GUILD_ID=
|
||||||
|
#set-up will give the verified user the given role
|
||||||
|
DISCORD_ROLE_ID=
|
||||||
|
|
||||||
#nesseary URL's
|
#nesseary URL's
|
||||||
PTERODACTYL_URL=https://panel.bitsec.dev
|
PTERODACTYL_URL=https://panel.bitsec.dev
|
||||||
|
|
|
@ -29,8 +29,9 @@ class SocialiteController extends Controller
|
||||||
$discord = Socialite::driver('discord')->user();
|
$discord = Socialite::driver('discord')->user();
|
||||||
$discordUser = DiscordUser::find($discord->id);
|
$discordUser = DiscordUser::find($discord->id);
|
||||||
|
|
||||||
$guildId = env('DISCORD_GUILD_ID');
|
|
||||||
$botToken = env('DISCORD_BOT_TOKEN');
|
$botToken = env('DISCORD_BOT_TOKEN');
|
||||||
|
$guildId = env('DISCORD_GUILD_ID');
|
||||||
|
$roleId = env('DISCORD_ROLE_ID');
|
||||||
|
|
||||||
//force user into discord server
|
//force user into discord server
|
||||||
//TODO Add event on failure, to notify ppl involved
|
//TODO Add event on failure, to notify ppl involved
|
||||||
|
@ -42,6 +43,17 @@ class SocialiteController extends Controller
|
||||||
]
|
]
|
||||||
)->put("https://discord.com/api/guilds/{$guildId}/members/{$discord->id}",
|
)->put("https://discord.com/api/guilds/{$guildId}/members/{$discord->id}",
|
||||||
['access_token' => $discord->token]);
|
['access_token' => $discord->token]);
|
||||||
|
|
||||||
|
//give user a role in the discord server
|
||||||
|
if (!empty($roleId)){
|
||||||
|
$response = Http::withHeaders(
|
||||||
|
[
|
||||||
|
'Authorization' => 'Bot ' . $botToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
]
|
||||||
|
)->put("https://discord.com/api/guilds/{$guildId}/members/{$discord->id}/roles/{$roleId}",
|
||||||
|
['access_token' => $discord->token]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue