set nick function
This commit is contained in:
parent
ad68321e8b
commit
79d4af0a46
19
src/irc.ts
19
src/irc.ts
@ -251,6 +251,12 @@ export class IRCConnectionWrapper
|
||||
case '433': // ERR_NICKNAMEINUSE
|
||||
const newNick = this.options.nick + '_';
|
||||
this.write('NICK %s', newNick);
|
||||
|
||||
this.emit('nick', {
|
||||
oldNick: this.options.nick,
|
||||
newNick,
|
||||
});
|
||||
|
||||
this.options.nick = newNick;
|
||||
break;
|
||||
case '902': // ERR_NICKLOCKED
|
||||
@ -534,6 +540,19 @@ export class IRCConnectionWrapper
|
||||
return this.connection?.connected ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new nickname for self.
|
||||
* @param newNick New nickname
|
||||
*/
|
||||
public setNick(newNick: string): void {
|
||||
this.write('NICK %s', newNick);
|
||||
this.emit('nick', {
|
||||
oldNick: this.options.nick,
|
||||
newNick,
|
||||
});
|
||||
this.options.nick = newNick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously ping the server.
|
||||
* @returns Ping in milliseconds
|
||||
|
Loading…
Reference in New Issue
Block a user