Advertisement
Rashwan-

Untitled

Mar 23rd, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require('fs')
  2. let newsjson = JSON.parse(fs.readFileSync("./news.json", "utf8"))
  3. client.on('message', message => {
  4.     let news = message.content.split(" ").slice(1).join(" ")
  5.     if(message.content.startsWith(prefix + 'setnews')) {
  6.           if(!news) return message.channel.send(`❌ | Please Write The News For Example: ${prefix}setnews fix bugs`)
  7.            newsjson[client.user.id] = {
  8.             new: news,
  9.            }
  10.            message.channel.send(`✅ | Done The Bot News Has Been Updated !`)
  11.         }
  12.     if(message.content.startsWith( prefix + 'news')) {
  13.         if(!newsjson[client.user.id]) newsjson[client.user.id] = {
  14.             new: 'nothing'
  15.         }
  16.         let embed = new Discord.RichEmbed()
  17.         .setTitle(`📰 | ${client.user.username} Latest News :`)
  18.         .setDescription(`${newsjson[client.user.id].new}`)
  19.         .setTimestamp()
  20.         .setFooter(`Requested By ${message.author.username}`)
  21.            message.channel.sendEmbed(embed)
  22.         }
  23.         fs.writeFile("./news.json", JSON.stringify(newsjson), (err) => {
  24.         })
  25. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement