Home Manual Reference Source Repository
import BotPermissions from 'discord-graf/src/bot/permissions.js'
public class | source

BotPermissions

Contains methods to test whether a user has permissions in a guild

Static Method Summary

Static Public Methods
public static

isAdmin(client: Client, config: BotConfig, guild: Guild | string, user: User | string): boolean

Tests to see if a user is an administrator in a guild with a specified client.

public static

isMod(client: Client, modRoles: ModRoleStorage, settings: SettingStorage, config: BotConfig, guild: Guild | string, user: User | string): boolean

Tests to see if a user is a moderator in a guild using a specified client and config.

public static

isOwner(config: BotConfig, user: User | string): boolean

Tests to see if a user is the owner of the bot

public static

resolve(client: Client, guild: Guild | string, user: User | string): [guild, user]

Resolves a guild and user to Discord.js instances with a specified client

Constructor Summary

Public Constructor
public

constructor(client: Client, modRoles: ModRoleStorage, settings: SettingStorage, config: BotConfig)

Member Summary

Public Members
public
public
public
public

Method Summary

Public Methods
public

isAdmin(guild: Guild | string, user: User | string): boolean

Tests to see if a user is an administrator in a guild.

public

isMod(guild: Guild | string, user: User | string): boolean

Tests to see if a user is a moderator in a guild.

public

Tests to see if a user is the owner of the bot

public

resolve(guild: Guild | string, user: User | string): [guild, user]

Resolves a guild and user to Discord.js instances

Static Public Methods

public static isAdmin(client: Client, config: BotConfig, guild: Guild | string, user: User | string): boolean source

Tests to see if a user is an administrator in a guild with a specified client. If the user is the bot owner or has any roles assigned with the "Administrate" permission, they are considered an administrator.

Params:

NameTypeAttributeDescription
client Client

The Client to use

config BotConfig

The bot config to use

guild Guild | string

The Guild or the guild ID

user User | string

The User or the user ID

Return:

boolean

Whether or not the user is considered an administrator

See:

public static isMod(client: Client, modRoles: ModRoleStorage, settings: SettingStorage, config: BotConfig, guild: Guild | string, user: User | string): boolean source

Tests to see if a user is a moderator in a guild using a specified client and config. If the guild has not set any moderator roles, then they will be a moderator if any of their assigned roles contain the "Manage messages" permission. If the guild has set moderator roles, then they will instead be a moderator if they have any of the moderator roles assigned. The bot owner and users with the "Administrate" permission are always moderators.

Params:

NameTypeAttributeDescription
client Client

The Client to use

modRoles ModRoleStorage

The mod role storage to use

settings SettingStorage

The setting storage to use

config BotConfig

The bot config to use

guild Guild | string

The Guild or the guild ID

user User | string

The User or the user ID

Return:

boolean

Whether or not the user is considered a moderator

See:

public static isOwner(config: BotConfig, user: User | string): boolean source

Tests to see if a user is the owner of the bot

Params:

NameTypeAttributeDescription
config BotConfig

The bot config to use

user User | string

The User or the user ID

Return:

boolean

Whether or not the user is the bot owner

See:

public static resolve(client: Client, guild: Guild | string, user: User | string): [guild, user] source

Resolves a guild and user to Discord.js instances with a specified client

Params:

NameTypeAttributeDescription
client Client

The Client to use

guild Guild | string

The Guild or the guild ID

user User | string

The User or the user ID

Return:

[guild, user]

The Guild and User instance pair

See:

Public Constructors

public constructor(client: Client, modRoles: ModRoleStorage, settings: SettingStorage, config: BotConfig) source

Params:

NameTypeAttributeDescription
client Client

The Client to use

modRoles ModRoleStorage

The mod role storage to use

settings SettingStorage

The setting storage to use

config BotConfig

The bot config to use

Public Members

public client: Client source

public config: BotConfig source

public modRoles: ModRoleStorage source

public settings: SettingStorage source

Public Methods

public isAdmin(guild: Guild | string, user: User | string): boolean source

Tests to see if a user is an administrator in a guild. If the user is the bot owner or has any roles assigned with the "Administrate" permission, they are considered an administrator.

Params:

NameTypeAttributeDescription
guild Guild | string

The Guild or the guild ID

user User | string

The User or the user ID

Return:

boolean

Whether or not the user is considered an administrator

See:

public isMod(guild: Guild | string, user: User | string): boolean source

Tests to see if a user is a moderator in a guild. If the guild has not set any moderator roles, then they will be a moderator if any of their assigned roles contain the "Manage messages" permission. If the guild has set moderator roles, then they will instead be a moderator if they have any of the moderator roles assigned. The bot owner and users with the "Administrate" permission are always moderators.

Params:

NameTypeAttributeDescription
guild Guild | string

The Guild or the guild ID

user User | string

The User or the user ID

Return:

boolean

Whether or not the user is considered a moderator

See:

public isOwner(user: User | string): boolean source

Tests to see if a user is the owner of the bot

Params:

NameTypeAttributeDescription
user User | string

The User or the user ID

Return:

boolean

Whether or not the user is the bot owner

See:

public resolve(guild: Guild | string, user: User | string): [guild, user] source

Resolves a guild and user to Discord.js instances

Params:

NameTypeAttributeDescription
guild Guild | string

The Guild or the guild ID

user User | string

The User or the user ID

Return:

[guild, user]

The Guild and User instance pair

See: