Struct db_adapter::guild::GuildConfig[][src]

pub struct GuildConfig(pub GuildId);
Expand description

Wraps around a guilds row

GuildConfig provides an API covering every common use-case. When it doesn’t piecing methods together is simple and safe. As much as possible it tries to issue as little queries as possible so you can confidently use the methods.

Connection (conn) parameter.

For the sake of flexibility as little constraints as possible were put on the methods. The major example of this is the conn parameter which generally accepts anything that implements: [sqlx::Executor]. This means both sqlx::PgPool and [sqlx::PgConnection] can be used. However some methods need to issue multiple queries. As such it requires a conn that implements Copy. In those cases simply pass a &PgPool

Errors

For simplicty’s sake only methods that can give other errors than [sqlx::Error] have a section detailing the error.

All methods provided by Self return a Result which’s Err variant is AdapterError. One of the later’s variant wraps around [sqlx::Error] which is returned by every [sqlx] method that interacts with the database. These are all about database errors, which for the user of the library, should only be caused by incorrect setup (see crate).

Tuple Fields

0: GuildId

Implementations

Adds a new entry to the guilds table.

Errors

Errors with GuildConfigError::AlreadyExists if a row with the same id already exists in the DB

true if the guild exists in the database, false otherwise.

welcome_message currently in use

This is the message sent to new users when they join. Disabled if None.

goodbye_message currently in use

Change welcome_message

Error

If the message is over discord’s length limit for a message (2000 characters) the query will not be made and the method will return GuildConfigError::MessageTooLong.

Change goodbye_message

Error

If the message is over discord’s length limit for a message (2000 characters) the query will not be made and the method will return GuildConfigError::MessageTooLong.

advertise

Change the advertisement policy

admin_chan

Events demanding the attention of guild admins are posted to the admin channel. This includes but is not limited to slap notices, upcoming updates, etc.

Change the admin_chan

Roles with the specified privilege

Gives a role a privilege

Strips a role from a privilege

If all roles have a privilege

If a role has a privilege

Id a role has all specified privileges

All privileges granted to a role

Trait Implementations

Formats the value using the given formatter. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more