import { Member } from 'eris';
import { Client, Event } from '../class';

export default class GuildMemberAdd extends Event {
  public client: Client;

  constructor(client: Client) {
    super(client);
    this.event = 'guildMemberAdd';
  }

  public async run(_, member: Member) {
    try {
      const search = await this.client.db.local.muted.get<boolean>(`muted-${member.user.id}`);
      if (search === true) {
        member.addRole('478373942638149643', 'muted user left server and joined back');
      }
    } catch (err) {
      this.client.util.handleError(err);
    }
  }
}
