@ -21,10 +21,15 @@ const strikeM = require('../../models/strikes');
const isActive = await new Strikes ( this . client ) . getAreStrikesActive ( message . guildId ) ;
if ( ! isActive ) return new ErrorMessage ( this . client ) . send ( ErrorType . FeatureInnactive , message )
var confirm = await this . confirmArgs ( message , args ) ;
if ( confirm == 'Error' ) return new ErrorMessage ( this . client ) . send ( ErrorType . Arguments , message , [ 'Use the mention method to pass the user.' , 'Make sure you provide a reason.' ] )
if ( confirm == 'Error' ) return new ErrorMessage ( this . client ) . send ( ErrorType . Arguments , message , [ 'Use the mention method to pass the user.' , 'Make sure you provide a reason.' , 'Make sure to only mention one person per strike.' ] )
const Stroked = message . mentions . users . toJSON ( ) [ 0 ] ;
var strike = new strikeM ( ) ;
strike . strikerID = confirm . strikerID ;
strike . strokedID = confirm . strokedID ;
strike . strikerID = message . author . id ;
strike . strikerName = message . author . username ;
strike . strikerAvatar = message . author . avatar ? message . author . avatar : 'NOAVATAR' ;
strike . strokedID = Stroked . id ;
strike . strokedName = Stroked . username ;
strike . strokedAvatar = Stroked . avatar ? Stroked . avatar : 'NOAVATAR' ;
strike . guildName = message . guild . name ;
strike . guildID = message . guild . id
strike . reason = confirm . reason ;
@ -33,20 +38,19 @@ const strikeM = require('../../models/strikes');
strike . save ( err =>
{
if ( err ) console . log ( err ) ;
this . sendMessage ( confirm. strokedID , confirm . reason ) ;
this . sendMessage ( Stroked , confirm . reason ) ;
message . delete ( ) ;
} )
}
async sendMessage ( strokedID , reason )
async sendMessage ( Stroked , reason )
{
let name = this . client . guilds . cache . get ( this . message . guildId ) . members . cache . get ( strokedID ) ;
const embed = new EmbedBuilder ( )
embed . setFooter ( { text : 'Rem-chan on ' , iconURL : "https://i.imgur.com/g6FSNhL.png" } )
embed . setAuthor ( { name : "Rem-chan" , iconURL : "https://i.imgur.com/g6FSNhL.png" , url : 'https://rem.wordfights.com/addtodiscord' } ) ;
embed . setColor ( 0x110809 ) ;
embed . setTimestamp ( )
embed . setTitle ( ` Strike ` )
embed . setDescription ( ` ${ name} has been struck. ` )
embed . setDescription ( ` ${ Stroked. user name} has been struck. ` )
embed . addFields ( { name : 'Reason:' , value : reason } )
const row = new ActionRowBuilder ( )
@ -72,9 +76,9 @@ const strikeM = require('../../models/strikes');
async confirmArgs ( message , args )
{
if ( args . length < 2 ) return 'Error'
if ( ! args [ 0 ] . split ( '@' ) ) return 'Error'
let strikerID = message . author . id ;
let strokedID = args [ 0 ] . split ( '@' ) [ 1 ] . split ( '>' ) [ 0 ] ;
return { strikerID, strokedID , reason: args . splice ( - 1 , 1 ) . join ( ' ' ) }
if ( ! args [ 0 ] . include s( '@' ) ) return 'Error'
if ( args . join ( '' ) . split ( '@' ) . length > 2 ) return 'Error'
if ( isNaN ( args [ 0 ] . replaceAll ( /[<@>]/g , '' ) ) ) return 'Error'
return { reason: args . splice ( - 1 , 1 ) . join ( ' ' ) }
}
} module . exports = strike ;