2022-11-15 09:06:18 -05:00
import Discord , { ChannelType } from 'discord.js' ;
2023-01-27 21:33:55 -05:00
import TClient from '../client' ;
2022-11-13 08:46:50 -05:00
export default {
2023-01-02 04:45:05 -05:00
async run ( client :TClient , message :Discord.Message ) {
2023-02-13 02:37:23 -05:00
if ( message . author . bot || message . channel . type === ChannelType . DM ) return ;
2022-11-13 08:46:50 -05:00
const msgarr = message . content . toLowerCase ( ) . split ( ' ' ) ;
2022-11-19 05:17:04 -05:00
let automodded : boolean ;
2022-11-13 08:46:50 -05:00
function onTimeout ( ) {
delete client . repeatedMessages [ message . author . id ]
}
const Whitelist = [
// Arrary of channel ids for automod to be disabled in
]
2022-11-18 11:54:40 -05:00
if ( client . bannedWords . _content . some ( ( x ) = > msgarr . includes ( x ) ) && ! message . member . roles . cache . has ( client . config . mainServer . roles . dcmod ) && message . guildId == client . config . mainServer . id && ! Whitelist . includes ( message . channelId ) && client . config . botSwitches . automod ) {
2022-11-13 08:46:50 -05:00
automodded = true ;
2023-02-16 06:29:45 -05:00
const threshold = 30000 ;
2023-02-13 02:37:23 -05:00
message . delete ( ) . catch ( err = > console . log ( 'bannedWords automod; msg got possibly deleted by another bot.' ) )
2022-11-18 11:54:40 -05:00
message . channel . send ( 'That word is banned here.' ) . then ( ( x ) = > setTimeout ( ( ) = > x . delete ( ) , 5000 ) ) ;
2022-11-13 08:46:50 -05:00
if ( client . repeatedMessages [ message . author . id ] ) {
// add this message to the list
2023-02-16 03:48:24 -05:00
client . repeatedMessages [ message . author . id ] . data . set ( message . createdTimestamp , { cont : 0 , ch : message.channelId } ) ;
2022-11-13 08:46:50 -05:00
// reset timeout
2023-02-16 03:48:24 -05:00
clearTimeout ( client . repeatedMessages [ message . author . id ] . timeout ) ;
2023-02-16 06:29:45 -05:00
client . repeatedMessages [ message . author . id ] . timeout = setTimeout ( onTimeout , threshold ) ;
2022-11-13 08:46:50 -05:00
// message mustve been sent after (now - threshold), so purge those that were sent earlier
2023-02-16 03:48:24 -05:00
client . repeatedMessages [ message . author . id ] . data = client . repeatedMessages [ message . author . id ] . data . filter ( ( x , i ) = > i >= Date . now ( ) - threshold )
2022-11-13 08:46:50 -05:00
// a spammed message is one that has been sent atleast 4 times in the last threshold milliseconds
2023-02-16 03:48:24 -05:00
const spammedMessage = client . repeatedMessages [ message . author . id ] ? . data . find ( ( x ) = > {
return client . repeatedMessages [ message . author . id ] . data . size >= 4 ;
2022-11-13 08:46:50 -05:00
} ) ;
// if a spammed message exists;
if ( spammedMessage ) {
delete client . repeatedMessages [ message . author . id ] ;
2023-02-16 06:29:45 -05:00
await client . punishments . addPunishment ( 'mute' , { time : '30m' } , ( client . user as Discord . User ) . id , 'Automod; Banned words' , message . author , message . member as Discord . GuildMember ) ;
2022-11-13 08:46:50 -05:00
}
} else {
2023-02-16 06:29:45 -05:00
client . repeatedMessages [ message . author . id ] = { data : new client . collection ( ) , timeout : setTimeout ( onTimeout , threshold ) }
2023-02-16 03:48:24 -05:00
client . repeatedMessages [ message . author . id ] . data . set ( message . createdTimestamp , { cont : 0 , ch : message.channelId } ) ;
2022-11-13 08:46:50 -05:00
// autodelete after 30 secs
2023-02-16 06:29:45 -05:00
client . repeatedMessages [ message . author . id ] . timeout = setTimeout ( onTimeout , threshold ) ;
2022-11-13 08:46:50 -05:00
}
}
2022-12-07 07:02:50 -05:00
if ( message . content . toLowerCase ( ) . includes ( 'discord.gg/' ) && ! message . member . roles . cache . has ( client . config . mainServer . roles . dcmod ) && message . guildId == client . config . mainServer . id && ! Whitelist . includes ( message . channelId ) ) {
2022-11-13 08:46:50 -05:00
automodded = true ;
2023-02-16 06:29:45 -05:00
const threshold = 60000 ;
2023-02-13 02:37:23 -05:00
message . delete ( ) . catch ( err = > console . log ( 'advertisement automod; msg got possibly deleted by another bot.' ) )
2022-12-07 07:02:50 -05:00
message . channel . send ( 'Advertising other Discord servers is not allowed.' ) . then ( x = > setTimeout ( ( ) = > x . delete ( ) , 10000 ) )
if ( client . repeatedMessages [ message . author . id ] ) {
2023-02-16 03:48:24 -05:00
client . repeatedMessages [ message . author . id ] . data . set ( message . createdTimestamp , { cont :1 , ch :message.channelId } ) ;
2022-12-07 07:02:50 -05:00
2023-02-16 03:48:24 -05:00
clearTimeout ( client . repeatedMessages [ message . author . id ] . timeout ) ;
2023-02-16 06:29:45 -05:00
client . repeatedMessages [ message . author . id ] . timeout = setTimeout ( onTimeout , threshold ) ;
2023-02-16 03:48:24 -05:00
client . repeatedMessages [ message . author . id ] . data = client . repeatedMessages [ message . author . id ] . data . filter ( ( x , i ) = > i >= Date . now ( ) - threshold )
2023-02-16 06:29:45 -05:00
const spammedMessage = client . repeatedMessages [ message . author . id ] . data . find ( ( x ) = > {
2023-02-16 03:48:24 -05:00
return client . repeatedMessages [ message . author . id ] . data . filter ( ( y ) = > x . cont === y . cont ) . size >= 4 ;
2022-12-07 07:02:50 -05:00
} ) ;
if ( spammedMessage ) {
delete client . repeatedMessages [ message . author . id ] ;
2023-02-16 06:29:45 -05:00
await client . punishments . addPunishment ( 'mute' , { time : '1h' } , ( client . user as Discord . User ) . id , 'Automod; Discord advertisement' , message . author , message . member as Discord . GuildMember ) ;
2022-12-07 07:02:50 -05:00
}
} else {
client . repeatedMessages [ message . author . id ] = new client . collection ( ) ;
2023-02-16 03:48:24 -05:00
client . repeatedMessages [ message . author . id ] . data . set ( message . createdTimestamp , { cont : 1 , ch : message.channelId } ) ;
2023-02-16 06:29:45 -05:00
client . repeatedMessages [ message . author . id ] . timeout = setTimeout ( onTimeout , threshold ) ;
2022-12-07 07:02:50 -05:00
}
2022-11-13 08:46:50 -05:00
}
if ( message . guildId == client . config . mainServer . id && ! automodded ) {
client . userLevels . incrementUser ( message . author . id ) ; // Ranking incrementation
}
// Mop gifs from banned channels without Monster having to mop them.
const bannedChannels = [
'516344221452599306' , // #mp-moderators
'742324777934520350' , // #discord-moderators
]
2022-11-18 11:54:40 -05:00
const gifURL = [
'tenor.com/view' ,
'giphy.com/gifs' ,
'giphy.com/media'
]
if ( gifURL . some ( e = > message . content . toLowerCase ( ) . includes ( e ) ) && bannedChannels . includes ( message . channelId ) ) {
2022-11-15 09:06:18 -05:00
message . reply ( 'Gifs are not allowed in this channel.' ) . then ( ( msg : any ) = > message . delete ( ) )
2022-11-13 08:46:50 -05:00
}
// Autoresponse:tm:
2022-11-17 12:58:19 -05:00
if ( client . config . botSwitches . autores && ! automodded ) {
2023-01-22 04:15:45 -05:00
const MorningArray = [ 'good morning all' , 'good morning everyone' , 'morning all' , 'morning everyone' , 'morning lads' , 'morning guys' , 'good morning everybody' ]
2022-11-18 11:54:40 -05:00
const AfternoonArray = [ 'good afternoon' , 'afternoon all' ]
2023-01-22 00:36:57 -05:00
const EveningArray = [ 'good evening' , 'evening all' , 'evening everyone' ]
2022-11-18 11:54:40 -05:00
const NightArray = [ 'night all' , 'night everyone' ]
const PasswordArray = [ 'whats the password' , 'what\'s the password' , 'password pls' ]
const cantRead = [ 'i cant read' , 'i can\'t read' , 'cant read' , 'can\'t read' ]
const NawdicBrokeIt = [ 'break' , 'broke' , 'broken' ]
const deadChat = [ 'dead chat' , 'chat is dead' , 'dead server' ]
2023-01-22 00:34:45 -05:00
const PersonnyMcPerson = ` ** ${ message . member . displayName } ** ` ;
const MorningPhrases = [
` Morning ${ PersonnyMcPerson } , did you sleep great? ` , ` Good morning ${ PersonnyMcPerson } ! ` , ` Hope you enjoyed your breakfast, ${ PersonnyMcPerson } ! ` ,
` Gm ${ PersonnyMcPerson } ` , ` Uh.. What time is it? Oh yea, morning ${ PersonnyMcPerson } ` , ` Morning and hope you had a good dream last night, ${ PersonnyMcPerson } `
]
const AfternoonPhrases = [
` Afternoon ${ PersonnyMcPerson } ! ` , ` What a nice day outside, ${ PersonnyMcPerson } ` , ` Good afternoon ${ PersonnyMcPerson } ` ,
` Hope you had a good day so far. ` , ` Did you enjoy your day yet, ${ PersonnyMcPerson } ? ` , ` Weather doesn't look too bad outside right? ` ,
` How's the trip outside, ${ PersonnyMcPerson } ? `
]
const EveningPhrases = [
` I can't believe the time flies so quickly! ` , ` Evening ${ PersonnyMcPerson } ! ` , ` Hope you enjoyed the dinner, ${ PersonnyMcPerson } ! ` ,
` Good evening ${ PersonnyMcPerson } ! ` , ` You look tired, ready to go to sleep yet? ` , ` Being outside was an exhausting task isn't it? `
]
const NightPhrases = [
` Good night ${ PersonnyMcPerson } ! ` , ` Night ${ PersonnyMcPerson } ! ` , ` Sweet dreams, ${ PersonnyMcPerson } . ` , ` Don't fall out of sky in your dreamworld, ${ PersonnyMcPerson } ! ` ,
` Nighty night! ` , ` I hope tomorrow is a good day for you, ${ PersonnyMcPerson } ! `
]
2022-11-28 21:58:09 -05:00
if ( message . mentions . members . has ( '309373272594579456' ) && ! client . isStaff ( message . member ) ) {
2022-11-13 08:46:50 -05:00
message . reply ( 'Please don\'t tag Daggerwin, read rule 14 in <#468846117405196289>' )
}
if ( message . mentions . members . has ( '215497515934416896' ) && ! client . isStaff ( message . member ) && message . type != 19 ) {
message . reply ( 'Please don\'t tag Monster unless it\'s important!' )
}
2022-11-18 11:54:40 -05:00
if ( PasswordArray . some ( e = > message . content . toLowerCase ( ) . includes ( e ) ) ) {
2022-11-13 08:46:50 -05:00
message . reply ( 'Password and other details can be found in <#543494084363288637>' )
}
2022-11-18 11:54:40 -05:00
if ( cantRead . some ( e = > message . content . toLowerCase ( ) . includes ( e ) ) ) {
2022-11-13 08:46:50 -05:00
message . reply ( 'https://tenor.com/view/aristocats-george-pen-cap-meticulous-gif-5330931' )
}
if ( message . content . toLowerCase ( ) . includes ( 'is daggerbot working' ) ) {
message . reply ( 'https://tenor.com/view/i-still-feel-alive-living-existing-active-singing-gif-14630579' )
}
2022-11-18 11:54:40 -05:00
if ( deadChat . some ( e = > message . content . toLowerCase ( ) . includes ( e ) ) ) {
2022-11-13 08:46:50 -05:00
message . reply ( 'https://cdn.discordapp.com/attachments/925589318276382720/1011333656167579849/F57G5ZS.png' )
}
2023-02-08 14:28:46 -05:00
if ( message . content . toLowerCase ( ) . includes ( 'nawdic' ) && NawdicBrokeIt . some ( e = > message . content . toLowerCase ( ) . includes ( e ) ) && message . channelId !== '516344221452599306' ) {
2023-02-13 02:37:23 -05:00
message . reply ( { embeds : [ new client . embed ( ) . setTitle ( '*Nawdic has done an oopsie*' ) . setImage ( 'https://c.tenor.com/JSj9ie_MD9kAAAAC/kopfsch%C3%BCtteln-an-kopf-fassen-oh-no.gif' ) . setColor ( client . config . embedColor ) ] } )
2022-11-13 08:46:50 -05:00
}
2023-01-30 07:16:25 -05:00
if ( MorningArray . some ( e = > message . content . toLowerCase ( ) . startsWith ( e ) ) && message . channelId == '468835415093411863' ) {
2023-01-22 00:34:45 -05:00
message . reply ( ` ${ MorningPhrases [ Math . floor ( Math . random ( ) * MorningPhrases . length ) ] } ` )
2022-11-13 08:46:50 -05:00
}
2023-01-30 07:16:25 -05:00
if ( AfternoonArray . some ( e = > message . content . toLowerCase ( ) . startsWith ( e ) ) && message . channelId == '468835415093411863' ) {
2023-01-22 00:34:45 -05:00
message . reply ( ` ${ AfternoonPhrases [ Math . floor ( Math . random ( ) * AfternoonPhrases . length ) ] } ` )
2022-11-16 13:53:42 -05:00
}
2023-01-30 07:16:25 -05:00
if ( EveningArray . some ( e = > message . content . toLowerCase ( ) . startsWith ( e ) ) && message . channelId == '468835415093411863' ) {
2023-01-22 00:34:45 -05:00
message . reply ( ` ${ EveningPhrases [ Math . floor ( Math . random ( ) * EveningPhrases . length ) ] } ` )
2022-11-13 08:46:50 -05:00
}
2023-01-30 07:16:25 -05:00
if ( NightArray . some ( e = > message . content . toLowerCase ( ) . startsWith ( e ) ) && message . channelId == '468835415093411863' ) {
2023-01-22 00:34:45 -05:00
message . reply ( ` ${ NightPhrases [ Math . floor ( Math . random ( ) * NightPhrases . length ) ] } ` )
2022-11-13 08:46:50 -05:00
}
2023-01-01 20:09:03 -05:00
// Failsafe thingy (Toastproof maybe)
2023-01-02 04:45:05 -05:00
if ( message . content . startsWith ( '!!_wepanikfrfr' ) && client . config . eval . whitelist . includes ( message . author . id ) ) {
2023-01-01 20:09:03 -05:00
( client . guilds . cache . get ( message . guildId ) as Discord . Guild ) . commands . set ( client . registry ) . then ( ( ) = > message . reply ( 'How did you manage to lose the commands??? Anyways, it\'s re-registered now.' ) ) . catch ( ( e :Error ) = > message . reply ( ` Failed to deploy slash commands: \ n \` \` \` ${ e . message } \` \` \` ` ) ) ;
2022-12-29 16:24:15 -05:00
}
2022-11-15 09:06:18 -05:00
}
2022-11-13 08:46:50 -05:00
}
2022-11-23 03:04:14 -05:00
}