setOwner method

Future<void> setOwner(
  1. GuildMember guildMember
)

Update the owner of this

Warning : This method only works if the server was created via a discord bot and the bot is the current owner

See documentation

Example :

final member = guild.members.cache.get('240561194958716924');

if (member != null) {
  await guild.setOwner(member);
}

Implementation

Future<void> setOwner (GuildMember guildMember) async {
  MineralClient client = ioc.singleton(Service.client);
  Http http = ioc.singleton(Service.http);

  if (owner.id != client.user.id) {
    Console.error(message: "You cannot change the owner of the server because it does not belong to the ${client.user.username} client.");
    return;
  }

  Response response = await http.patch(url: "/guilds/$id", payload: { 'owner_id': guildMember.user.id });

  if (response.statusCode == 200) {
    _ownerId = guildMember.id;
  }
}