import type ColumnTypes from '../../typings/ColumnTypes' ; import type { GuildMessage } from '../../Constants' ; import type { HelpObj } from '../../structures/commandhandler' ; import { MessageEmbed } from 'discord.js' ; import type { PermissionString } from 'discord.js' ; import type ReknownClient from '../../structures/client' ; import { errors , tables } from '../../Constants' ; const allowedFields = [ 'email' , 'summary' , 'twitter' ] ; export async function run ( client , message , args ) { if ( args [ 1 ] && args [ 1 ] . toLowerCase ( ) === 'set' ) { if ( ! args [ 2 ] ) return client . functions . noArg ( message , 2 , `a field to fill. It can be: ${ allowedFields . join ( ', ' ) }.` ) ; const field = args [ 2 ] . toLowerCase ( ) ; if ( ! allowedFields . includes ( field ) ) return client . functions . badArg ( message , 2 , `The field provided is not available. Usable fields are: ${ allowedFields . join ( ', ' ) }` ) ; if ( ! args [ 3 ] ) return client . functions . noArg ( message , 3 , 'a value for the field.' ) ; const value = args . slice ( 3 ) . join ( ' ' ) ; const columns = { [ field ] : value , userid : message . author . id } ; client . sql `
      INSERT INTO ${ client . sql ( tables . BIOGRAPHY ) } ${ client . sql ( columns ) }
        ON CONFLICT (userid) DO UPDATE
          SET ${ client . sql ( columns ) }
    ` ; message . channel . send ( `Successfully updated your \`${ field }\` to \`\`${ client . escInline ( value ) }\`\`.` ) ; } else { const member = args [ 1 ] ? await client . functions . parseMention ( args [ 1 ] , { guild : message . guild , type : 'member' } ) : message . member ; if ( ! member ) return client . functions . badArg ( message , 1 , errors . UNKNOWN_MEMBER ) ; const [ row ] = await client . sql < ColumnTypes [ 'BIOGRAPHY' ] > `
      SELECT * FROM ${ client . sql ( tables . BIOGRAPHY ) }
        WHERE userid = ${ member . id }
    ` ; if ( ! row ) return client . functions . badArg ( message , 1 , 'The member provided did not provide any information about themselves.' ) ; const embed = new MessageEmbed ( ) . setColor ( client . config . embedColor ) . setFooter ( `Requested by ${ message . author . tag }` , message . author . displayAvatarURL ( ) ) . setThumbnail ( member . user . displayAvatarURL ( { size : 512 } ) ) . setTimestamp ( ) . setTitle ( `${ member . user . tag }'s Biography` ) ; if ( row . email ) embed . addField ( 'Email' , row . email , true ) ; if ( row . summary ) embed . setDescription ( row . summary ) ; if ( row . twitter ) embed . addField ( 'Twitter' , row . twitter , true ) ; message . channel . send ( embed ) ; } } export const help = { aliases : [ 'bio' ] , category : 'Miscellaneous' , desc : 'Checks a member\'s biography. Please note that any information set in this command is public to everyone that shares a server with you.' , togglable : true , usage : 'biography [Member]\nbiography set <Field> <Value>' } ; export const memberPerms = [ ] ; export const permissions = [ 'EMBED_LINKS' ] ;