-
Notifications
You must be signed in to change notification settings - Fork 237
Bans are part of Guild (Server).
use Discord\Parts\Guild\Ban;
A Ban is a ban on a user specific to a guild. It is also IP based.
Requires GUILDS
intent
Your BOT must have ban_members
permission
You must first get the Guild object and the Member object to use the code below
Ban the $member
with reason "bad person" and delete their messages from 5 days back:
$member->ban(5, 'bad person')->then(function (Ban $ban) {
// ...
})->done();
https://discord.com/developers/docs/resources/guild#create-guild-ban
Your BOT must have ban_members
permission
You must first get the Guild object and the User object or User ID to use the code below
Unban with $user
object:
$guild->unban($user)->then(function () {
// ...
})->done();
Or, change 123123123123123123
below with the User ID:
$guild->unban('123123123123123123')->then(function () {
// ...
})->done();
https://discord.com/developers/docs/resources/guild#remove-guild-ban
Retrieving a ban requires GUILD_BANS
intent and ban_members
permission
You must first get the Guild object to use the code below. Change 123123123123123123
below with the User ID you want to retrieve
Cached, synchronous (i.e retrieveBans
option is true
):
$ban = $guild->bans->get('user_id', '123123123123123123');
If the code above returns null
, you may need to fetch it first (Promise, asynchronous):
$guild->bans->fetch('123123123123123123')->then(function (Ban $ban) {
// ...
})->done();
https://discord.com/developers/docs/resources/guild#get-guild-ban
Note: This wiki is currently Work In Progress. Consider reading the docs instead.
- Application Command (Slash based)
Command Client (Message based)
- Activity
- Application
- Guild
- Private Channel
- User
Components
-
ActionRow
- Buttons
- Option (commands)
- SelectMenu
- TextInput
Builders