@ -18,46 +18,34 @@ class manga extends Command{
if ( ! args [ 0 ] ) return new ErrorMessage ( this . client ) . send ( ErrorType . Arguments , message )
const data = await new aniList ( ) . searchManga ( 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 ( 'First 4 results of search:' )
. setAuthor ( { name : "Rem-chan" , iconURL : "https://i.imgur.com/g6FSNhL.png" , url : 'https://rem.wordfights.com/addtodiscord' } )
. setColor ( 0x003284 )
. setURL ( 'https://www.rem.wordfights.com' )
. setFooter ( { text : 'Rem-Chan on' , iconURL : 'https://i.imgur.com/g6FSNhL.png' } )
. setImage ( data [ 0 ] . image )
. setTimestamp ( )
. addFields (
{ name : data [ 0 ] . title . romaji + ( data [ 0 ] . title . english ? "(" + data . title . english + ")" : '' ) , value : '1' } ,
{ name : data [ 1 ] . title . romaji + ( data [ 1 ] . title . english ? "(" + data . title . english + ")" : '' ) , value : '2' } ,
{ name : data [ 2 ] . title . romaji + ( data [ 2 ] . title . english ? "(" + data . title . english + ")" : '' ) , value : '3' } ,
{ name : data [ 3 ] . title . romaji + ( data [ 3 ] . title . english ? "(" + data . title . english + ")" : '' ) , value : '4' } ,
// console.log('SearchManga: Data:', data)
const embed = new EmbedBuilder ( ) ;
const randomID = Random ( ) ;
const row = new ActionRowBuilder ( ) ;
var fieldPayload = [ ] ;
var embeds = [ ] ;
for ( var i = 0 ; i < data . length ; i ++ )
{
fieldPayload . push ( { name : data [ i ] . title . romaji + ( data [ i ] . title . english ? "(" + data [ i ] . title . english + ")" : '' ) , value : i . toString ( ) } ) ;
embeds . push ( new EmbedBuilder ( ) . setImage ( data [ i ] . image ) . setURL ( 'https://www.rem.wordfights.com' ) ) ;
row . addComponents (
new ButtonBuilder ( )
. setCustomId ( randomID + i )
. setLabel ( i . toString ( ) )
. setStyle ( ButtonStyle . Success )
) ;
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' ) ) ;
}
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 ) ,
embed . setTitle ( ` First ${ data . length >= 4 ? '4' : data . length } results of search: ` )
. setAuthor ( { name : "Rem-chan" , iconURL : "https://i.imgur.com/g6FSNhL.png" , url : 'https://rem.wordfights.com/addtodiscord' } )
. setColor ( 0x003284 )
. setURL ( 'https://www.rem.wordfights.com' )
. setFooter ( { text : 'Rem-Chan on' , iconURL : 'https://i.imgur.com/g6FSNhL.png' } )
. setTimestamp ( )
. addFields ( fieldPayload ) ;
embeds . unshift ( embed ) ;
) ;
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 } ) ;