community-relations/src/commands/profile_bio.ts

40 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-03-05 22:41:01 -05:00
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.';
2021-03-11 01:13:18 -05:00
this.usage = `${this.client.config.prefix}profile bio <new bio>`;
2021-03-05 22:41:01 -05:00
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 });
}
2021-03-05 23:20:42 -05:00
const member = await this.client.db.Member.findOne({ userID: message.author.id });
if (!args[0]) {
await member.updateOne({
additional: {
...member.additional,
bio: null,
},
});
return message.addReaction('modSuccess:578750988907970567');
}
2021-03-05 22:41:01 -05:00
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.');
await member.updateOne({
additional: {
...member.additional,
bio,
},
});
2021-03-05 23:20:42 -05:00
return message.addReaction('modSuccess:578750988907970567');
2021-03-05 22:41:01 -05:00
}
}