Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js')
- const client = new Discord.Client()
- client.on('ready', () => {
- console.log("Connected as " + client.user.tag)
- client.user.setActivity("Micheal Reeves", {type: "watching"}) // Status for the bot (Watching, playing, streaming)
- clients.guilds.forEach((guild) => { // Logs the servers its connected to
- console.log(guild.name)
- guild.channels.forEach((channel) => {
- console.log(` - ${channel.name} ${channel.type} ${channel.id}`)
- })
- // General channel id: 420363942745997322
- })
- let generalChannel = client.channels.get("420363942745997322")
- const attachment = new Discord.attachment ("https://www.devdungeon.com/sites/default/static/discord/GetBotToken.PNG")
- generalChannel.send(attachment)
- })
- client.on('message', (recievedMessage) => {
- if (recievedMessage.author == client.user) {
- return
- }
- recievedMessage.channel.send("Message Recieved," + recievedMessage.author.toString() + recievedMessage.content)
- //recievedMessage.react("👍")
- //To find emojis use these three lines | recievedMessage.guild.emojis.forEach(customEmjoji => {
- //console.log(`${customEmoji.name} ${customEmoji.id}`)
- //recievedMessage.react(customEmoji)|
- if (recievedMessage.content.startsWith(",,")) {
- processCommand(receivedMessage)
- }
- })
- function processCommand(recievedMessage){ //Command processing fuction
- let fullCommand = recievedMessage.content.substr(1)
- let splitCommand = fullCommand.split(" ")
- let primaryCommand = splitCommand[0]
- let arguments = splitCommand.slice(1)
- if (primaryCommand == "help"){ //sets ,,help as the primary command
- helpCommand(arguments, recievedMessage)
- } else if (primaryCommand == "multiply") {
- multiplyCommand(arguments, receivedMessage)
- } else {
- recievedMessage.channel.send("Unknown command. Try `,,help`")
- }
- }
- function multiplyCommand(arguments, recievedMessage){ //adds the multiplication command
- if (arguments.length < 2){
- recievedMessage.channel.send("not enough arguments. Try `,,multiply 2 10`")
- return
- }
- let product = 1
- arguments.forEach((value) => {
- product = product * parseFloat(value)
- })
- recievedMessage.channel.send("The product of" + arguments, "is" + product.toString())
- }
- function helpCommand(arguments, recievedMessage){ //adds the help command
- if (arguments.length == 0) {
- receivedMessage.channel.send("```Please enter what you need help with (,,help [topic])```")
- } else {
- recievedMessage.channel.send("```It looks like you need help with```" + arguments)
- }
- }
- //function processCommand(recievedMessage){
- bot_secret_token = "NTc3MjQ2NjczOTExMTUyNjUw.XNikjg.gC90UkCqyCUa4hV8J5ojcboVSk4"
- client.login("NTc3MjQ2NjczOTExMTUyNjUw.XNikjg.gC90UkCqyCUa4hV8J5ojcboVSk4")
Advertisement
Add Comment
Please, Sign In to add comment