buddy

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 8a8a6b6881c0388e3ab68bc65a72d8fdcfbce9a3
parent 1c7809d8fb8dd5ce4b144b2d4d427cd1526a7b62
Author: underd0g1 <hide4@comcast.net>
Date:   Thu, 10 Sep 2020 21:42:32 -0400

added select case to commands

Diffstat:
Mbuddy1.js | 75+++++++++++++--------------------------------------------------------------
Mevents/message.js | 8++++----
Mevents/ready.js | 4+---
Mlib/processing.js | 47+++++++++++++++++++++++++++++------------------
4 files changed, 47 insertions(+), 87 deletions(-)

diff --git a/buddy1.js b/buddy1.js @@ -1,85 +1,36 @@ -// test bot -//todo: git init here + //add new youtube api feature -// add the internal.js + // button up 3party.js //add git stats to code function // create an object of words for built in foas. +//the Dev modules const discord = require('discord.js'); const client = new discord.Client(); const fetch = require('node-fetch'); - +// the self made modules const config = require('./config/config.js'); + const apiroute = require('./lib/3party.js'); +const processing = require('./lib/processing.js'); + const init = require('./events/ready.js'); const message = require('./events/message.js'); -const processing = require('./lib/processing.js'); const member = require('./events/member.js'); +//below are the events + +//event to turn the client on when node application is run init.startup(client); +//event that a message is sent into the chat message.internalResponse(client, processing); +//event that a new member joins member.newmember(client) - - -// client.on('guildMemberAdd', member => { -// // Send the message to a designated channel on a server: -// const channel = member.guild.channels.find(ch => ch.name === 'member-log'); -// // Do nothing if the channel wasn't found on this server -// if (!channel) return; -// // Send the message, mentioning the member -// channel.send(`Welcome to the server, ${member}`); -// }); - - - - - -// function multiplyCommand(arguements, receivedMessage){ -// if (arguements.length < 2){ -// receivedMessage.channel.send('not enough arguements, you need 2') -// }else{ -// let product = 1 -// arguements.forEach((value)=>{ -// product = product * parseFloat(value) -// }) -// receivedMessage.channel.send('the product of ' + arguements + 'is '+ product.toString()) -// } -// } -// -// -// function helpCommand(arguements, receivedMessage){ -// if (arguements.length == 0 ){ -// receivedMessage.channel.send(` -// Here are some commands you can throw at me (![command]): -// - multiply[x y] -// - iss -// - code -// - beer -// - joke -// `) -// } -// else{ -// receivedMessage.channel.send('looks like you need help with ' + arguements) -// } -// } -// -// -// function time(arguements, receivedMessage){ -// var date = new date() -// var hours = date.getHours() -// if (hours == 3){ -// receivedMessage.channel.send('Good morning Everyone!') -// }else if (hours == 12){ -// receivedMessage.channel.send("its Noon O'Clock") -// } else if(hours == 17){ -// receivedMessage.channel.send('Good Evening everyone!') -// } -// } - +//event to log the bot into its account client.login(config.discordkey.login) diff --git a/events/message.js b/events/message.js @@ -10,7 +10,7 @@ const internalResponse = async(client) => { await client.on('message', (message) => { const process = require("../lib/processing.js"); - console.log("received message was : " + message.content) + if (message.author == client.user){ return } @@ -19,11 +19,11 @@ const internalResponse = async(client) => { message.react("🤚") message.channel.send('whats good ' + message.author) }else if(message.content.includes('buddy')){ - channel.send('hi'); + message.channel.send('hi'); }else if(message.content.includes('buddy' && 'fuck')){ - channel.send('aahhhh my virgin ears!') + message.channel.send('aahhhh my virgin ears!') }else if (message.content.includes('hi')){ - channel.send('hi' + " " + message.author) + message.channel.send('hi' + " " + message.author) } if(message.content.startsWith("!")){ diff --git a/events/ready.js b/events/ready.js @@ -17,9 +17,7 @@ const startup = (client) => { //const attachment = new discord.Attachment("") genchannel.send(` ▒█▀▀█ █░░█ █▀▀▄ ▒█▀▀▄ █░░█ █░░█ - ▒█▄▄█ ░▀▀▀ ▀▀▀░ v1.0 - - `) + ▒█▄▄█ ░▀▀▀ ▀▀▀░ v1.0`) }) diff --git a/lib/processing.js b/lib/processing.js @@ -9,24 +9,35 @@ const tool = require("./tools.js"); let primaryCommand = splitCommand[0] let arguements = splitCommand.slice(1) - if (primaryCommand == "help"){ - tool.help(arguements, message) - }else if (primaryCommand == "multiply"){ - tool.multiply(arguements, message) - }else if(primaryCommand == "iss"){ - message.channel.send(await apiroute.iss()); - }else if(primaryCommand == "joke"){ - message.channel.send(await apiroute.joke()); - }else if(primaryCommand == "code"){ - message.channel.send(await apiroute.code()); - }else if(primaryCommand == "beer"){ - message.channel.send(await apiroute.beer()); - }else if(primaryCommand == "foas"){ - message.channel.send(await apiroute.foas1()); - }else{ - tool.help(arguements,message) - } - } + switch (primaryCommand) { + + case 'help': + tool.help(arguements, message) + break; + case 'multiply': + tool.multiply(arguements, message) + break; + case "iss": + message.channel.send(await apiroute.iss()); + break; + case "joke": + message.channel.send(await apiroute.joke()); + break; + case "code": + message.channel.send(await apiroute.code()); + break; + case "beer": + message.channel.send(await apiroute.beer()); + break; + case "foas": + message.channel.send(await apiroute.foas1()); + break; + default: + tool.help(arguements, message); + break; + } + +} module.exports = {processingCommand}