31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
|
import { Message } from 'eris';
|
||
|
import { Client, Command } from '../class';
|
||
|
|
||
|
export default class Profile_Bio extends Command {
|
||
|
constructor(client: Client) {
|
||
|
super(client);
|
||
|
this.name = 'bio';
|
||
|
this.description = 'Updates your bio on your profile.';
|
||
|
this.usage = `${this.client.config.prefix}bio <new bio>`;
|
||
|
this.permissions = 0;
|
||
|
this.enabled = true;
|
||
|
}
|
||
|
|
||
|
public async run(message: Message, args: string[]) {
|
||
|
if (!await this.client.db.Member.exists({ userID: message.author.id })) {
|
||
|
await this.client.db.Member.create({ userID: message.author.id });
|
||
|
}
|
||
|
if (!args[0]) return this.error(message.channel, 'No new bio content was provided.');
|
||
|
const bio = args.join(' ');
|
||
|
if (bio.length >= 256) return this.error(message.channel, 'Bio too long. It must be less than or equal to 256 characters.');
|
||
|
|
||
|
const member = await this.client.db.Member.findOne({ userID: message.author.id });
|
||
|
await member.updateOne({
|
||
|
additional: {
|
||
|
...member.additional,
|
||
|
bio,
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
}
|