Lingo.Api.Invite (Lingo v0.4.2)

Copy Markdown View Source

Invites, including restricting them to target users.

Every function returns {:ok, result}, :ok when Discord sends no body, or {:error, %Lingo.Error{}}. Calls go to the current bot (see Lingo.with_bot/2).

Summary

Types

The progress of processing an invite's target users file. status is :unspecified, :processing, :completed or :failed (see error_message).

Functions

Adds a user to an invite's allowed users.

Adds up to 1000 users to an invite's allowed users.

Removes up to 1000 users from an invite's allowed users.

Creates an invite to a channel. :target_users_file limits who can use it: a list of user ids, a CSV string, or {filename, csv}.

Deletes an invite.

Fetches an invite by code.

Fetches the progress of processing an invite's target users file.

Lists a channel's invites.

Lists a guild's invites.

Fetches the users an invite is restricted to.

Removes a user from an invite's allowed users.

Restricts an invite to the given users.

Types

target_users_job()

@type target_users_job() :: %{
  status: :unspecified | :processing | :completed | :failed | integer(),
  total_users: non_neg_integer(),
  processed_users: non_neg_integer(),
  created_at: DateTime.t() | nil,
  completed_at: DateTime.t() | nil,
  error_message: String.t() | nil
}

The progress of processing an invite's target users file. status is :unspecified, :processing, :completed or :failed (see error_message).

Functions

add_target_user(invite_code, user_id)

@spec add_target_user(String.t(), Lingo.Api.id()) :: Lingo.Api.result()

Adds a user to an invite's allowed users.

bulk_add_target_users(invite_code, user_ids)

@spec bulk_add_target_users(String.t(), [Lingo.Api.id()]) :: Lingo.Api.result()

Adds up to 1000 users to an invite's allowed users.

bulk_delete_target_users(invite_code, user_ids)

@spec bulk_delete_target_users(String.t(), [Lingo.Api.id()]) :: Lingo.Api.result()

Removes up to 1000 users from an invite's allowed users.

create(channel_id, params \\ %{}, opts \\ [])

Creates an invite to a channel. :target_users_file limits who can use it: a list of user ids, a CSV string, or {filename, csv}.

delete(invite_code, opts \\ [])

Deletes an invite.

get(invite_code, opts \\ [])

Fetches an invite by code.

get_target_users_status(invite_code)

@spec get_target_users_status(String.t()) :: Lingo.Api.result(target_users_job())

Fetches the progress of processing an invite's target users file.

list_channel(channel_id)

@spec list_channel(Lingo.Api.id()) :: Lingo.Api.result([Lingo.Type.Invite.t()])

Lists a channel's invites.

list_guild(guild_id)

@spec list_guild(Lingo.Api.id()) :: Lingo.Api.result([Lingo.Type.Invite.t()])

Lists a guild's invites.

list_target_users(invite_code)

@spec list_target_users(String.t()) :: Lingo.Api.result([Lingo.Api.id()])

Fetches the users an invite is restricted to.

remove_target_user(invite_code, user_id)

@spec remove_target_user(String.t(), Lingo.Api.id()) :: Lingo.Api.result()

Removes a user from an invite's allowed users.

set_target_users(invite_code, user_ids)

@spec set_target_users(String.t(), [Lingo.Api.id()]) :: Lingo.Api.result()

Restricts an invite to the given users.