function logMessage(message){
const d = new Date()
const cont = `${d.getMonth()}/${d.getDay()}/${d.getFullYear()}::${d.getHours()}:${d.getMinutes()}:${d.getSeconds()} <${message.author.username}#${message.author.discriminator}> ${message.content}`
console.log(cont)
}
(edited)const discord = require('discord.js')
const fs = require('fs')
const bot_token = require('./token.json')
const config = require('./settings.json')
const client = new discord.Client({intents: ["GUILDS","GUILD_EMOJIS_AND_STICKERS","GUILD_MEMBERS", "GUILD_PRESENCES", "GUILD_MESSAGES"]})
const commchannel = client.channels.cache.get(config.command_channel)
client.on("ready",(user)=>{
client.user.setActivity('your messages', { type: 'WATCHING'})
console.log(`Bot initialized at ${new(Date)}, ctrl+c to exit`)
})
client.on('messageCreate',(message)=>{
logMessage(message)
if(message.author.bot) return
if(message.content.startsWith(config.prefix)){
var args = message.content.trim().split(' ').filter((val)=>{return val !== ""})
const command = args.shift().slice(1,message.content.length)
if (command == "info" | command == "help"){
message.reply(`Use commands with the following Prefix: ${config.prefix}`)
message.channel.send(`Current commands include iq, nuke, and a few secret ones ;)`)
}
else if (command == "newbase"){
const admins = config.admins
var i = 0
while (i < admins.length) {
if(message.author.id == admins[i]){
const basenum = args[1]
const base = args[0]
message.reply(`Created new base ${base} number ${basenum}`)
message.guild.channels.create(`${base}-${basenum}`, {parent:config.base_category, reason:'New base command initiated'})
}
i++
}
}
else if (command == "iq"){
var target = message.mentions.users.first()
if (!target) target = message.author
const iq=Math.floor((Math.random()*(150-50))+50)
message.reply(`${target} has an approximate IQ of **${iq}** \n *disclaimer: this figure is randomly generated*`)
}
else if (command == "nuke"){
const nukelib = ["https://tenor.com/view/nuke-gif-8044239","https://tenor.com/view/explosion-explode-clouds-of-smoke-gif-17216934","https://tenor.com/view/nuclear-catastrophic-disastrous-melt-down-gif-13918708"]
var rnd = Math.floor(Math.random()*(nukelib.length - 1))
var target = '!'
if (args.length > 0){
target=' on'
for (i=0;i<args.length;i++){
target+=(" "+args[i])
}
target+="!"
}
message.channel.send(`${message.author.username} called a tactical nuke strike${target} ${nukelib[rnd]}`)
}
}
})
client.on('channelCreate',(ch)=>{
ch.send('first :stuck_out_tongue_winking_eye:')
})
client.login(bot_token.token)
// var [command, ...args] = message.content.trim().slice(config.prefix).split(' ');
// https://github.com/mat-1/mineflayer-baritone
function logMessage(message){
var extras = ``
if(message.reference != null){ //reply
extras += ` (Reply to Message ID: ${message.reference.messageId})`
}
const abb = `username:${message.author.username}#${message.author.discriminator}${extras.replace("\n","\\n")} ${message.content.replace("\n","\\n")}`
fs.appendFile(`./${message.guild.name}/${message.channel.name}.txt`,`${new(Date)} Author = id:${message.author.id} ${abb}\n`,(err)=>{
if (err) console.log(err)
else console.log(`>> ${abb}`)})
}
else if (command == "stop"){
const admins = config.admins
var i = 0
while (i < admins.length) {
if(message.author.id == admins[i]){
message.reply(`Bot shutting down...`)
.then(setTimeout(()=>{process.exit(0)},3000))
}
i++
}
}
const discord = require('discord.js')
const fs = require('fs')
const bot_token = require('./token.json')
const config = require('./settings.json')
const client = new discord.Client({intents: ["GUILDS","GUILD_EMOJIS_AND_STICKERS","GUILD_MEMBERS", "GUILD_PRESENCES", "GUILD_MESSAGES"]})
const commchannel = client.channels.cache.get(config.command_channel)
client.on("ready",(user)=>{
client.user.setActivity('your messages', { type: 'WATCHING'})
console.log(`Bot initialized at ${new(Date)}, ctrl+c to exit`)
})
client.on('messageCreate',(message)=>{
logMessage(message)
if(message.author.bot) return
if(message.content.startsWith(config.prefix)){
var args = message.content.trim().split(' ').filter((val)=>{return val !== ""})
const command = args.shift().slice(1,message.content.length)
if (command == "info" | command == "help"){
message.reply(`Use commands with the following Prefix: ${config.prefix}`)
message.channel.send(`Current commands include iq, nuke, and a few secret ones ;)`)
}
else if (command == "newbase"){
const admins = config.admins
var i = 0
while (i < admins.length) {
if(message.author.id == admins[i]){
const basenum = args[1]
const base = args[0]
message.reply(`Created new base ${base} number ${basenum}`)
message.guild.channels.create(`${base}-${basenum}`, {parent:config.base_category, reason:'New base command initiated'})
}
i++
}
}
else if (command == "iq"){
var target = message.mentions.users.first()
if (!target) target = message.author
const iq=Math.floor((Math.random()*(150-50))+50)
message.reply(`${target} has an approximate IQ of **${iq}** \n *disclaimer: this figure is randomly generated*`)
}
else if (command == "nuke"){
const nukelib = ["https://tenor.com/view/nuke-gif-8044239","https://tenor.com/view/explosion-explode-clouds-of-smoke-gif-17216934","https://tenor.com/view/nuclear-catastrophic-disastrous-melt-down-gif-13918708"]
var rnd = Math.floor(Math.random()*(nukelib.length - 1))
var target = '!'
if (args.length > 0){
target=' on'
for (i=0;i<args.length;i++){
target+=(" "+args[i])
}
target+="!"
}
message.channel.send(`${message.author.username} called a tactical nuke strike${target} ${nukelib[rnd]}`)
}
}
})
client.on('channelCreate',(ch)=>{
ch.send('first :stuck_out_tongue_winking_eye:')
})
client.login(bot_token.token)
// var [command, ...args] = message.content.trim().slice(config.prefix).split(' ');
// https://github.com/mat-1/mineflayer-baritone
function logMessage(message){
var extras = ``
if(message.reference != null){ //reply
extras += ` (Reply to Message ID: ${message.reference.messageId})`
}
const abb = `username:${message.author.username}#${message.author.discriminator}${extras.replace("\n","\\n")} ${message.content.replace("\n","\\n")}`
fs.appendFile(`./${message.guild.name}/${message.channel.name}.txt`,`${new(Date)} Author = id:${message.author.id} ${abb}\n`,(err)=>{
if (err) console.log(err)
else console.log(`>> ${abb}`)})
}