Added automatic role change
parent
abdab986a7
commit
af3a6d49d4
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "omnicron/toadling",
|
||||||
|
"description": "Toadling bot for Discord",
|
||||||
|
"type": "project",
|
||||||
|
"license": "MIT",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Omnicron\\Toadling\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Dany Thach",
|
||||||
|
"email": "d.thach4@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"require": {
|
||||||
|
"team-reflex/discord-php": "^6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
$toadling = new \Omnicron\Toadling\Toadling;
|
||||||
|
|
||||||
|
$toadling->run();
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Omnicron\Toadling;
|
||||||
|
|
||||||
|
use \Discord\Discord;
|
||||||
|
use \Discord\Parts\User\Member;
|
||||||
|
use \Discord\WebSockets\Intents;
|
||||||
|
use \Discord\WebSockets\Event;
|
||||||
|
|
||||||
|
class Toadling
|
||||||
|
{
|
||||||
|
|
||||||
|
protected Discord $discord;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->discord = new Discord([
|
||||||
|
'token' => 'OTAyODgxNTUzMjU5MDQ0OTM1.YXk3-Q.VYjX0smJWx4eCRVbxP_ACA3veXI',
|
||||||
|
'intents' => Intents::getDefaultIntents() | Intents::GUILD_MEMBERS | Intents::GUILD_PRESENCES,
|
||||||
|
'loadAllMembers' => true,
|
||||||
|
]);
|
||||||
|
$this->discord->on('ready', [$this, 'initialize']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initialize(Discord $discord) {
|
||||||
|
$discord->on(Event::GUILD_MEMBER_ADD, [$this, 'moveMemberToNotToad']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function moveMemberToNotToad(Member $member, Discord $discord) {
|
||||||
|
if('902654364685074522' !== $member->guild_id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$notToadRole = $member->guild->roles->find(function ($role) {
|
||||||
|
return '902655062982148106' === $role->id;
|
||||||
|
});
|
||||||
|
if(null === $notToadRole) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$member->addRole($notToadRole);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run() {
|
||||||
|
$this->discord->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue