diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..ef0805e --- /dev/null +++ b/jest.config.js @@ -0,0 +1,188 @@ +// For a detailed explanation regarding each configuration property, visit: +// https://jestjs.io/docs/en/configuration.html + +module.exports = { + // All imported modules in your tests should be mocked automatically + // automock: false, + + // Stop running tests after `n` failures + // bail: 0, + + // The directory where Jest should store its cached dependency information + // cacheDirectory: "/private/var/folders/pw/0tfbblb52h175lvdtj01x_s40000gp/T/jest_dy", + + // Automatically clear mock calls and instances between every test + // clearMocks: false, + + // Indicates whether the coverage information should be collected while executing the test + // collectCoverage: false, + + // An array of glob patterns indicating a set of files for which coverage information should be collected + // collectCoverageFrom: undefined, + + // The directory where Jest should output its coverage files + coverageDirectory: "coverage", + + // An array of regexp pattern strings used to skip coverage collection + // coveragePathIgnorePatterns: [ + // "/node_modules/" + // ], + + // Indicates which provider should be used to instrument code for coverage + coverageProvider: "v8", + + // A list of reporter names that Jest uses when writing coverage reports + // coverageReporters: [ + // "json", + // "text", + // "lcov", + // "clover" + // ], + + // An object that configures minimum threshold enforcement for coverage results + // coverageThreshold: undefined, + + // A path to a custom dependency extractor + // dependencyExtractor: undefined, + + // Make calling deprecated APIs throw helpful error messages + // errorOnDeprecated: false, + + // Force coverage collection from ignored files using an array of glob patterns + // forceCoverageMatch: [], + + // A path to a module which exports an async function that is triggered once before all test suites + // globalSetup: undefined, + + // A path to a module which exports an async function that is triggered once after all test suites + // globalTeardown: undefined, + + // A set of global variables that need to be available in all test environments + // globals: {}, + + // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. + // maxWorkers: "50%", + + // An array of directory names to be searched recursively up from the requiring module's location + // moduleDirectories: [ + // "node_modules" + // ], + + // An array of file extensions your modules use + // moduleFileExtensions: [ + // "js", + // "json", + // "jsx", + // "ts", + // "tsx", + // "node" + // ], + + // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module + // moduleNameMapper: {}, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + // modulePathIgnorePatterns: [], + + // Activates notifications for test results + // notify: false, + + // An enum that specifies notification mode. Requires { notify: true } + // notifyMode: "failure-change", + + // A preset that is used as a base for Jest's configuration + // preset: undefined, + + // Run tests from one or more projects + // projects: undefined, + + // Use this configuration option to add custom reporters to Jest + // reporters: undefined, + + // Automatically reset mock state between every test + // resetMocks: false, + + // Reset the module registry before running each individual test + // resetModules: false, + + // A path to a custom resolver + // resolver: undefined, + + // Automatically restore mock state between every test + // restoreMocks: false, + + // The root directory that Jest should scan for tests and modules within + // rootDir: undefined, + + // A list of paths to directories that Jest should use to search for files in + // roots: [ + // "" + // ], + + // Allows you to use a custom runner instead of Jest's default test runner + // runner: "jest-runner", + + // The paths to modules that run some code to configure or set up the testing environment before each test + // setupFiles: [], + + // A list of paths to modules that run some code to configure or set up the testing framework before each test + // setupFilesAfterEnv: [], + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + // snapshotSerializers: [], + + // The test environment that will be used for testing + testEnvironment: "node", + + // Options that will be passed to the testEnvironment + // testEnvironmentOptions: {}, + + // Adds a location field to test results + // testLocationInResults: false, + + // The glob patterns Jest uses to detect test files + // testMatch: [ + // "**/__tests__/**/*.[jt]s?(x)", + // "**/?(*.)+(spec|test).[tj]s?(x)" + // ], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + // testPathIgnorePatterns: [ + // "/node_modules/" + // ], + + // The regexp pattern or array of patterns that Jest uses to detect test files + // testRegex: [], + + // This option allows the use of a custom results processor + // testResultsProcessor: undefined, + + // This option allows use of a custom test runner + // testRunner: "jasmine2", + + // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href + // testURL: "http://localhost", + + // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" + // timers: "real", + + // A map from regular expressions to paths to transformers + // transform: undefined, + + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + // transformIgnorePatterns: [ + // "/node_modules/" + // ], + + // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them + // unmockedModulePathPatterns: undefined, + + // Indicates whether each individual test should be reported during the run + // verbose: undefined, + + // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode + // watchPathIgnorePatterns: [], + + // Whether to use watchman for file crawling + // watchman: true, +}; diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index bf1cae5..4998347 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -3105,9 +3105,9 @@ "dev": true }, "n": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/n/-/n-6.5.1.tgz", - "integrity": "sha512-CSDShHuBlYHfS5PR4BxwkZYNrDnc3B7GCRdAhSvnzl681Pd4Y4qOOTWQqjB8Cp6gYOIQI9qJxLK0Q1YI4xO2Kg==" + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/n/-/n-6.6.0.tgz", + "integrity": "sha512-Yk2z0OQKDCmDyBHltJRg2RsxPsdc2DHcM8fFN21j1rzqior+FifdqhvcbZ+k00EgiSvR6p8+s9whWLwvzSeqcw==" }, "nanomatch": { "version": "1.2.13", diff --git a/package.json b/package.json index d49290e..8613225 100644 --- a/package.json +++ b/package.json @@ -1,38 +1,38 @@ { - "name": "@technicolor-creamsicle/osselbot", - "version": "2.1.2", - "description": "A discord bot on Discord.js", - "main": "index.js", - "dependencies": { - "discord.js": "^12.1.1", - "n": "^6.4.0", - "node-fetch": "^2.6.0", - "pretty-ms": "^6.0.1" - }, - "publishConfig": { - "registry": "https://npm.pkg.github.com/" - }, - "bin": { - "osselbot": "./src/index.js" - }, - "files": [ - "/src/" - ], - "devDependencies": { - "jest": "^26.1.0" - }, - "scripts": { - "test": "node ./src/index --TEST", - "start": "node ./src/index.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Technicolor-creamsicle/Osselbot.git" - }, - "author": "Alex Technicolor (http://technicolor.2a03.party)", - "license": "SEE LICENSE IN LICENCE", - "bugs": { - "url": "https://github.com/Technicolor-creamsicle/Osselbot/issues" - }, - "homepage": "https://technicolor.2a03.party/bot" + "name": "@technicolor-creamsicle/osselbot", + "version": "2.1.2", + "description": "A discord bot on Discord.js", + "main": "index.js", + "dependencies": { + "discord.js": "^12.1.1", + "n": "^6.6.0", + "node-fetch": "^2.6.0", + "pretty-ms": "^6.0.1" + }, + "publishConfig": { + "registry": "https://npm.pkg.github.com/" + }, + "bin": { + "osselbot": "./src/index.js" + }, + "files": [ + "/src/" + ], + "devDependencies": { + "jest": "^26.1.0" + }, + "scripts": { + "test": "jest", + "start": "node ./src/index.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Technicolor-creamsicle/Osselbot.git" + }, + "author": "Alex Technicolor (http://technicolor.2a03.party)", + "license": "SEE LICENSE IN LICENCE", + "bugs": { + "url": "https://github.com/Technicolor-creamsicle/Osselbot/issues" + }, + "homepage": "https://technicolor.2a03.party/bot" } diff --git a/src/config.json b/src/config.json index 4d332ff..6b27fbd 100644 --- a/src/config.json +++ b/src/config.json @@ -1,5 +1,9 @@ { - "token" : "Njc4MDkzNjY4NzcwNTEyOTE3.Xr7SNw.XS_D_dEJ7hX6N5Rmnfr_OQpfznU", - "prefix" : "?", - "abuse" : [""] + "token": "Njc4MDkzNjY4NzcwNTEyOTE3.Xr7SNw.XS_D_dEJ7hX6N5Rmnfr_OQpfznU", + "prefix": "?", + "abuse": [ + "May you never reproduce", + "I can eat a bowl of alphabet soup and shit out a more coherent sentence than you.", + "you are living proof darwinism is dead, hell, even reversing." + ] } diff --git a/src/index.js b/src/index.js index 58589ea..3be92b2 100755 --- a/src/index.js +++ b/src/index.js @@ -48,7 +48,7 @@ client.on("message", async message => { //Message processing // noinspection SpellCheckingInspection - if (message.content.toLowerCase().includes('nigg'||'negro'||'niglet'||'fag'||'f4g'||'n1gg'||'gg3r')) { + if (message.content.toLowerCase().includes('nigg' || 'negro' || 'niglet' || 'fag' || 'f4g' || 'n1gg' || 'gg3r')) { await message.delete(); return message.reply(`Listen here cum-sock we dont appreciate that here ${message.member}. If you gonna be like that you may just well end up in the JAR and we all know how that ends...`) } @@ -131,23 +131,8 @@ client.on("message", async message => { } if (command === "va") { - let msg = "" - let num = Math.floor(Math.random() * (5 - 1) + 1); //The maximum is exclusive and the minimum is inclusive - switch (num) { - case 1: - msg = "its simple, mind over matter. i dont mind, and you dont fucking matter"; - break; - case 2: - msg = "I can eat alphabet soup and shit out a more coherent sentence than you"; - break; - case 3: - msg = "you are living proof darwinism is dead, hell, even reversing."; - break; - case 4: - msg = "may you never reproduce" - break; - } - return message.reply(`${msg}`) + let num = Math.floor(Math.random() * (config.abuse.length + 1)); //The maximum is exclusive and the minimum is inclusive + return message.reply(`${config.abuse[num]}`) } //////////////////////////////////////////////////////////////////////////////// if (command === "say") { @@ -176,12 +161,11 @@ client.on("message", async message => { try { selector = args[0].toLowerCase(); } catch (err) { - let number = quotes.quotes.length + 1; - let quotesend = Math.floor(Math.random() * (number)); + let number = quotes.quotes.length; + let quotesend = Math.floor(Math.random() * (number + 1)); return message.channel.send(`${quotes.quotes[quotesend]}`); } if (selector === "add") { - if (!(message.member.roles.cache.some(r => ["Admin", "Mods", "Member of the Order", "Botmeister", "Ally of the Order", "say"].includes(r.name)))) return message.reply("Ask someone with a quote role to add that.") args.shift(); //This does logic to make it from an array to a nice string. quoteadd = args.join(' ');