@ -15,34 +15,92 @@ class char extends Command{
}
async run ( message , args )
{
if ( ! args [ 0 ] ) return new ErrorMessage ( this . client ) . send ( ErrorType . Arguments , message )
const data = await new aniList ( ) . searchChar ( args . join ( ' ' ) ) ;
if ( data == 'Error' ) return new ErrorMessage ( this . client ) . send ( ErrorType . Arguments , message , [ ` Couldn't find any character with the search argument you provided. ` ] )
const embed = new EmbedBuilder ( )
. setTitle ( ` ${ data . name . full } ( ${ data . name . native } ) ` )
. setTitle ( 'First 4 results of search:' )
. setAuthor ( { name : "Rem-chan" , iconURL : "https://i.imgur.com/g6FSNhL.png" , url : 'https://rem.wordfights.com/addtodiscord' } )
. setColor ( 0x003284 )
. set Description( data . description ) //.split('~! ')[1].replaceAll('<br>', ' ').substring(0, 1500) + "...")
. set URL( 'https://www.rem.wordfights.com' )
. setFooter ( { text : 'Rem-Chan on' , iconURL : 'https://i.imgur.com/g6FSNhL.png' } )
. setImage ( data . image )
. setThumbnail ( data . image )
. setImage ( data [ 0 ] . image )
. setTimestamp ( )
. addFields (
{ name : 'Gender:' , value : data . gender , inline : true } ) ;
const randomID = Random ( ) ;
const row = new ActionRowBuilder ( )
. addComponents (
new ButtonBuilder ( )
. setCustomId ( randomID )
. setLabel ( 'Remove this.' )
. setStyle ( ButtonStyle . Primary ) ,
) ;
const filter = i => i . customId === randomID ;
await message . channel . send ( { ephemeral : true , embeds : [ embed ] , components : [ row ] } ) ;
const collector = message . channel . createMessageComponentCollector ( { filter , time : 60000 } ) ;
collector . on ( 'collect' , async m =>
{
message . delete ( ) ;
m . message . delete ( ) ;
} ) ;
{ name : data [ 0 ] . name . full + ' [' + data [ 0 ] . name . native + ']' , value : '1' } ,
{ name : data [ 1 ] . name . full + ' [' + data [ 0 ] . name . native + ']' , value : '2' } ,
{ name : data [ 2 ] . name . full + ' [' + data [ 0 ] . name . native + ']' , value : '3' } ,
{ name : data [ 3 ] . name . full + ' [' + data [ 0 ] . name . native + ']' , value : '4' } ,
) ;
var embeds = [ embed ]
embeds . push ( new EmbedBuilder ( ) . setImage ( data [ 1 ] . image ) . setURL ( 'https://www.rem.wordfights.com' ) ) ;
embeds . push ( new EmbedBuilder ( ) . setImage ( data [ 2 ] . image ) . setURL ( 'https://www.rem.wordfights.com' ) ) ;
embeds . push ( new EmbedBuilder ( ) . setImage ( data [ 3 ] . image ) . setURL ( 'https://www.rem.wordfights.com' ) ) ;
//${data.title.romaji} (${data.title.native} / ${data.title.english})
const randomID = Random ( ) ;
const row = new ActionRowBuilder ( )
. addComponents (
new ButtonBuilder ( )
. setCustomId ( randomID + 1 )
. setLabel ( '1' )
. setStyle ( ButtonStyle . Success ) ,
new ButtonBuilder ( )
. setCustomId ( randomID + 2 )
. setLabel ( '2' )
. setStyle ( ButtonStyle . Success ) ,
new ButtonBuilder ( )
. setCustomId ( randomID + 3 )
. setLabel ( '3' )
. setStyle ( ButtonStyle . Success ) ,
new ButtonBuilder ( )
. setCustomId ( randomID + 4 )
. setLabel ( '4' )
. setStyle ( ButtonStyle . Success ) ,
) ;
const filter = i => i . customId . slice ( 0 , - 1 ) === randomID ;
await message . channel . send ( { ephemeral : true , embeds , components : [ row ] } ) ;
const collector = message . channel . createMessageComponentCollector ( { filter , time : 60000 } ) ;
collector . on ( 'collect' , async m =>
{
message . delete ( ) ;
m . message . delete ( ) ;
sendMessage ( data [ m . customId [ m . customId . length - 1 ] - 1 ] . id ) ;
} ) ;
/ * *
* @ param { Number } id
* /
async function sendMessage ( id )
{
const data = await new aniList ( ) . getCharInfo ( id ) ;
const embed = new EmbedBuilder ( )
. setTitle ( ` ${ data . name . full } ( ${ data . name . native } ) ` )
. setAuthor ( { name : "Rem-chan" , iconURL : "https://i.imgur.com/g6FSNhL.png" , url : 'https://rem.wordfights.com/addtodiscord' } )
. setColor ( 0x003284 )
. setDescription ( data . description ) //.split('~! ')[1].replaceAll('<br>', ' ').substring(0, 1500) + "...")
. setFooter ( { text : 'Rem-Chan on' , iconURL : 'https://i.imgur.com/g6FSNhL.png' } )
. setImage ( data . image )
. setThumbnail ( data . image )
. setTimestamp ( )
. addFields (
{ name : 'Gender:' , value : data . gender , inline : true } ) ;
const randomID = Random ( ) ;
const row = new ActionRowBuilder ( )
. addComponents (
new ButtonBuilder ( )
. setCustomId ( randomID )
. setLabel ( 'Remove this.' )
. setStyle ( ButtonStyle . Primary ) ,
) ;
const filter = i => i . customId === randomID ;
await message . channel . send ( { ephemeral : true , embeds : [ embed ] , components : [ row ] } ) ;
const collector = message . channel . createMessageComponentCollector ( { filter , time : 60000 } ) ;
collector . on ( 'collect' , async m =>
{
m . message . delete ( ) ;
} ) ;
}
}