diff --git a/bot/roundbot.mjs b/bot/awesomescibo.mjs old mode 100644 new mode 100755 similarity index 90% rename from bot/roundbot.mjs rename to bot/awesomescibo.mjs index 4bb6ddf..4d48576 --- a/bot/roundbot.mjs +++ b/bot/awesomescibo.mjs @@ -1,15 +1,26 @@ +#!/usr/bin/env node + import * as Discord from 'discord.js'; import { execSync } from 'child_process'; const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] }); import fetch from 'node-fetch'; import * as fs from 'fs'; + +/*const Discord = require('discord.js'); +const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] }); +const fetch = require('node-fetch'); +const fs = require('fs');*/ var hits = 0; -fs.readFile('numhits.txt', 'utf8', function(error, data){ - hits = data; - if (error) { - console.log(error); - } -}); + +if (fs.existsSync('numhits.txt')) { + fs.readFile('numhits.txt', 'utf8', function(err, data){ + hits = data; + if (err) { + console.log(err); + } + }); + +} client.once('ready', () => { @@ -18,7 +29,7 @@ client.once('ready', () => { }); client.on('guildCreate', guild => { - guild.channels.cache.find(channel => channel.name === 'general').send("what is up peeps I am roundbutt"); + guild.channels.cache.find(channel => channel.name === 'general').send("What is up peeps I am the AwesomeSciBo Bot!"); }); client.on('message', async message => { @@ -27,7 +38,7 @@ client.on('message', async message => { fs.writeFile('numhits.txt', hits, (error) => { if (error) { console.log(error); } }); } if (message.content.toLowerCase() === ("do be helping")) { - message.channel.send(new Discord.MessageEmbed().setTitle("Help").setDescription("`do be helping`: display this help message\n`do be roundgen html`: send a round to the channel\n`do be roundgen html dm`: dm a round to you\n`do be roundgen pdf`: send a pdf round to the channel\n`do be roundgen pdf dm`: dm a pdf round to you\n`do be scoring`: start a scoring session\n - `do be scoring (a/b)(4/10)`: add points to Team A or Team B\n - `do be scoring stop`: end scoring session and post final points\n`do be hits`: send the number of round requests")); + message.channel.send(new Discord.MessageEmbed().setTitle("Help").setDescription("`do be helping`: display this help message\n`do be roundgen html`: send a round to the channel\n`do be roundgen html dm`: dm a round to you\n`do be roundgen pdf`: send a pdf round to the channel\n`do be roundgen pdf dm`: dm a pdf round to you\n`do be scoring`: start a scoring session\n > `do be scoring (a/b)(4/10)`: add points to Team A or Team B\n > `do be scoring stop`: end scoring session and post final points\n`do be hits`: send the number of rounds generated\n`do be servers`: send the number of servers this bot is a part of\nSource Code: https://github.com/ADawesomeguy/AwesomeSciBo")); } if (message.content.toLowerCase() === ("do be roundgen html dm")) { @@ -210,22 +221,6 @@ client.on('message', async message => { if (message.content.toLowerCase() === "do be servers") { message.channel.send(client.guilds.cache.size); } - - if (message.content.toLowerCase() === "do be pog") { - message.channel.send(new Discord.MessageEmbed().setTitle("POG POG POG").setURL("https://media.giphy.com/media/c5skRQb3BXp8RwKGKW/giphy.gif").setImage("https://media.giphy.com/media/c5skRQb3BXp8RwKGKW/giphy.gif")); - } - -/* if (message.content.toLowerCase() === "do be user channel create") { - const userChannel = await message.guild.channels.create('Users: ' + message.guild.memberCount, { - reason: 'Create channel to track number of users', - type: 'voice' - }) - //.then(console.log) - .catch(console.error); - - console.log(userChannel.id); - setInterval(async () => { await message.guild.channels.cache.get(userChannel.id).setName('Members: ' + message.guild.memberCount).catch(console.error); }, 10000); - }*/ }); -client.login("BOT TOKEN HERE"); +client.login(process.argv[2]); diff --git a/bot/package-lock.json b/bot/package-lock.json index 358aaa8..2520a61 100644 --- a/bot/package-lock.json +++ b/bot/package-lock.json @@ -1,8 +1,189 @@ { - "name": "roundbot2", - "version": "1.0.0", - "lockfileVersion": 1, + "name": "awscibo", + "version": "0.0.2", + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "awscibo", + "version": "0.0.2", + "license": "Apache 2.0", + "dependencies": { + "discord.js": "^12.5.1", + "fs": "^0.0.1-security", + "node-fetch": "^2.6.1" + }, + "bin": { + "awscibo": "awesomescibo.mjs" + } + }, + "node_modules/@discordjs/collection": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz", + "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==" + }, + "node_modules/@discordjs/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/discord.js": { + "version": "12.5.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz", + "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==", + "dependencies": { + "@discordjs/collection": "^0.1.6", + "@discordjs/form-data": "^3.0.1", + "abort-controller": "^3.0.0", + "node-fetch": "^2.6.1", + "prism-media": "^1.2.2", + "setimmediate": "^1.0.5", + "tweetnacl": "^1.0.3", + "ws": "^7.3.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + }, + "node_modules/mime-db": { + "version": "1.46.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.46.0.tgz", + "integrity": "sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.29", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.29.tgz", + "integrity": "sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==", + "dependencies": { + "mime-db": "1.46.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "engines": { + "node": "4.x || >=6.0.0" + } + }, + "node_modules/prism-media": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.7.tgz", + "integrity": "sha512-thS1z3L6BDmf724sqLC73bHGjSYArFTYHa7cqInyS3EdDNTHKgDCXy7l+IhRvlnX7aFNiUb8jJcC+R8ezxwgMA==", + "peerDependencies": { + "@discordjs/opus": "^0.4.0", + "ffmpeg-static": "^4.2.7 || ^3.0.0 || ^2.4.0", + "node-opus": "^0.3.3", + "opusscript": "^0.0.7" + }, + "peerDependenciesMeta": { + "@discordjs/opus": { + "optional": true + }, + "ffmpeg-static": { + "optional": true + }, + "node-opus": { + "optional": true + }, + "opusscript": { + "optional": true + } + } + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" + }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + }, + "node_modules/ws": { + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.3.tgz", + "integrity": "sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + }, "dependencies": { "@discordjs/collection": { "version": "0.1.6", @@ -91,7 +272,8 @@ "prism-media": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.7.tgz", - "integrity": "sha512-thS1z3L6BDmf724sqLC73bHGjSYArFTYHa7cqInyS3EdDNTHKgDCXy7l+IhRvlnX7aFNiUb8jJcC+R8ezxwgMA==" + "integrity": "sha512-thS1z3L6BDmf724sqLC73bHGjSYArFTYHa7cqInyS3EdDNTHKgDCXy7l+IhRvlnX7aFNiUb8jJcC+R8ezxwgMA==", + "requires": {} }, "setimmediate": { "version": "1.0.5", @@ -106,7 +288,8 @@ "ws": { "version": "7.4.3", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.3.tgz", - "integrity": "sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==" + "integrity": "sha512-hr6vCR76GsossIRsr8OLR9acVVm1jyfEWvhbNjtgPOrfvAlKzvyeg/P6r8RuDjRyrcQoPQT7K0DGEPc7Ae6jzA==", + "requires": {} } } } diff --git a/bot/package.json b/bot/package.json index fb0cd34..13349dd 100644 --- a/bot/package.json +++ b/bot/package.json @@ -4,15 +4,17 @@ "fs": "^0.0.1-security", "node-fetch": "^2.6.1" }, - "name": "roundbot2", - "version": "1.0.0", - "main": "index.js", - "devDependencies": {}, + "name": "awscibo", + "version": "0.0.2", + "main": "awesomescibo.mjs", + "bin": { + "awscibo": "./awesomescibo.mjs" + }, "scripts": { - "test": "node roundbot.mjs" + "test": "node awesomescibo.mjs" }, "keywords": [], - "author": "", - "license": "ISC", - "description": "" + "author": "Abheek Dhawan", + "license": "Apache 2.0", + "description": "A simple Discord bot that automatically generates Science Bowl rounds using the ScibowlDB API!" }