Class UserMethods

Methods for interacting with users

Hierarchy

  • UserMethods

Constructors

  • Create a new User Method handler

    Usually SnowTransfer creates a method handler for you, this is here for completion

    You can access the methods listed via client.user.method, where client is an initialized SnowTransfer instance

    Parameters

    • requestHandler: RequestHandler

    Returns UserMethods

Methods

  • Create a direct message channel with another user

    You can not create a dm with another bot

    Returns

    A DM channel

    Example

    // Create a dm channel and send "hi" to it
    const client = new SnowTransfer("TOKEN")
    const channel = await client.user.createDirectMessageChannel("other user id")
    client.channel.createMessage(channel.id, "hi")

    Parameters

    • userId: string

      Id of the user to create the direct message channel with

    Returns Promise<DMChannel>

  • Get guilds of the current user

    Returns

    Array of partial guild objects

    Example

    const client = new SnowTransfer("TOKEN")
    const guilds = await client.user.getGuilds()

    Parameters

    • Optional query: {
          after?: string;
          before?: string;
          limit?: number;
      }
      • Optional after?: string
      • Optional before?: string
      • Optional limit?: number

    Returns Promise<Guild[]>

  • Get information about the CurrentUser

    Returns

    A user object

    OAUTH2 Scopes Condition
    identify Without email
    email With email

    Example

    const client = new SnowTransfer("TOKEN")
    const self = await client.user.getSelf()

    Returns Promise<User>

  • Get information about a user via Id

    Returns

    user object

    Example

    const client = new SnowTransfer("TOKEN")
    const user = await client.user.getUser("userId")

    Parameters

    • userId: string

      Id of the user

    Returns Promise<User>

  • Leaves a guild

    Returns

    Resolves the Promise on successful execution

    Example

    const client = new SnowTransfer("TOKEN")
    client.user.leaveGuild("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<void>

  • Update the current user

    Returns

    user object

    Example

    // update the avatar of the user const client = new SnowTransfer("TOKEN") const fileData = fs.readFileSync("new_avatar.png") // You should probably use fs.readFile, since it is asynchronous, synchronous methods may lag your bot. const updateData = { avatar: data:image/png;base64,${fileData.toString("base64")} // base64 data url: data:mimetype;base64,base64String } client.user.updateSelf(updateData)

    Parameters

    • data: {
          avatar?: null | string;
          username?: string;
      }

      The new data of the CurrentUser

      • Optional avatar?: null | string
      • Optional username?: string

    Returns Promise<User>

Properties

requestHandler: RequestHandler

Generated using TypeDoc