-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_bot.php
36 lines (27 loc) · 1.13 KB
/
example_bot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* This example shows how one would use a bot that is in the server to access some information or award a role.
* See https://discordapp.com/developers/docs/resources/guild
*
* Use this as a guide only. It duplicates code for ease of assessibility.
*
* Author: Lachee
* Last Updated: Feb 2021
* License: MIT
*/
require "discord_bot.php";
$guildID = "81384788765712384"; //ID of the guild the role is in
$roleID = "454876643257876480"; //ID of the role to award
$userID = "130973321683533824"; //ID of the user we are going to award the role too
$botToken = file_get_contents("bot.key"); //The secret and SENSITIVE bot token.
//Send the PUT request, updating the user to the new award url
$route = "/guilds/{$guildID}/members/{$userID}/roles/{$roleID}";
$result = discord_put($route, $botToken, null);
//Dump the result
echo "<h3>Result</h3>"; var_dump($result); "<hr>";
//Get the users new roles
$route = "/guilds/{$guildID}/members/{$userID}";
$result = discord_get($route, $botToken);
//Dump the result
echo "<h3>Guild Member</h3>"; var_dump($result); "<hr>";
exit;