import { apply as Apply } from '.'; import { Client, CmdContext, Command } from '../class'; export default class SSS_Password_Reset extends Command { public applyCommand: Apply; constructor(client: Client) { super(client); this.name = 'pw'; this.description = 'Sends a password reset link to your email address.'; this.usage = `${this.client.config.prefix}staff-self-serv pw`; this.permissions = 1; this.guildOnly = false; this.enabled = true; } public async run(ctx: CmdContext) { try { const staff = await this.client.db.mongo.Staff.findOne({ userID: ctx.message.author.id }).lean().exec(); if (!staff) return this.error(ctx.message.channel, 'Staff information not located.'); const passwordTicket = await this.client.util.authClient.createPasswordChangeTicket({ email: staff.emailAddress, connection_id: 'con_T3ELEx2reigKMSlP', }); const channel = await this.client.getDMChannel(ctx.message.author.id); channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n\nPlease click the link below to reset your password.\n\n${passwordTicket.ticket}`).catch(() => this.error(ctx.message.channel, 'Unable to send you a DM.')); return ctx.message.addReaction('modSuccess:578750988907970567'); } catch (err) { return this.client.util.handleError(err, ctx.message, this); } } }