|
1 | 1 | # Fortnite Bot |
2 | | -A bot which pings selected targets whenever fortnite is mentioned. Use at your own risk. |
| 2 | + |
| 3 | + [](https://codecov.io/gh/aXises/fortniteBot) |
| 4 | +[](https://codeclimate.com/github/aXises/fortniteBot/maintainability) |
| 5 | +[](https://codeclimate.com/github/aXises/fortniteBot/test_coverage) |
| 6 | + |
| 7 | +A bot which pings selected targets whenever fortnite is mentioned. Use at your own risk. Despite its name, the main focus of the bot is to provide a flexible command system so that fun commands can be easily added to provide entertaining interactions between users and the bot. |
| 8 | + |
| 9 | +## Requirements |
| 10 | +- Node 6 or higher |
| 11 | +- TypeScript 2 |
| 12 | +- tslint is recommended for style consistency |
| 13 | + |
| 14 | +## Build |
| 15 | +Clone the repository `git clone https://github.com/aXises/fortniteBot` |
| 16 | + |
| 17 | +Install required packages `npm install` |
| 18 | + |
| 19 | +Install TypeScript `npm install -g typescript` |
| 20 | + |
| 21 | +Nodemon is recommended `npm install -g nodemon` |
| 22 | + |
| 23 | +Compile TypeScript `tsc` |
| 24 | + |
| 25 | +Configure API keys in fortniteBot.ts or with .env file |
| 26 | + |
| 27 | +Running the application `node fortniteBot.js` or `nodemon fortniteBot.js` |
| 28 | + |
| 29 | +## Creating commands |
| 30 | +It is recommended to place these in a seperate file. |
| 31 | +``` |
| 32 | +// MyCustomCommands.ts |
| 33 | +// Examples to demonstrate adding different types of commands. |
| 34 | +import * as Discord from "discord.js"; |
| 35 | +import { FortniteBotAction } from "../action/FortniteBotAction"; |
| 36 | +import { ExecutableCommand } from "../command/ExecutableCommand"; |
| 37 | +import { AutoTriggerCommand } from "../command/AutoTriggerCommand"; |
| 38 | +import { FortniteBotTrigger } from "../action/FortniteBotTrigger"; |
| 39 | +
|
| 40 | +// Example Executable Command. |
| 41 | +
|
| 42 | +// Example action. Takes 1 argument and sends it back to the channel. |
| 43 | +const testCommandAction = new FortniteBotAction(1, (state, args) => { |
| 44 | + const m: Discord.Message = state.getHandle(); |
| 45 | + if (args.length !== 1) { |
| 46 | + return false; // Command failed. |
| 47 | + } |
| 48 | + m.channel.send(args[0]); |
| 49 | + return true; // Command was successfully executed. |
| 50 | +}); |
| 51 | +
|
| 52 | +// To execute the command, call '!f testcommand'. Anyone with access level 0 can execute this command. |
| 53 | +const testCommand = new ExecutableCommand("testcommand", 0, testCommandAction); |
| 54 | +
|
| 55 | +// Example Auto Trigger Command |
| 56 | +
|
| 57 | +// Example Triggers. |
| 58 | +const trigger1 = new FortniteBotTrigger((state) => { |
| 59 | + return Math.random() > 0.5; // Action will be executed if true. (50%) |
| 60 | +}); |
| 61 | +
|
| 62 | +const trigger2 = new FortniteBotTrigger((state) => { |
| 63 | + const m: Discord.Message = state.getHandle(); |
| 64 | + return m.content === "egg"; // Action will be executed whenever the message is "egg". |
| 65 | +}); |
| 66 | +
|
| 67 | +// Example Action for auto trigger. |
| 68 | +const testAutoAction = new FortniteBotAction(1, (state) => { |
| 69 | + const m: Discord.Message = state.getHandle(); |
| 70 | + m.channel.send("This action was triggered"); |
| 71 | + return true; |
| 72 | +}); |
| 73 | +
|
| 74 | +// Set up the command with different triggers. |
| 75 | +const autoCommand1 = new AutoTriggerCommand(0, testAutoAction, trigger1); |
| 76 | +const autoCommand2 = new AutoTriggerCommand(0, testAutoAction, trigger2); |
| 77 | +
|
| 78 | +// Export all the commands. |
| 79 | +export const myCustomCommands = [testCommand, autoCommand1, autoCommand2]; |
| 80 | +
|
| 81 | +// Import in to the command manager with CommandManager.addBulkCommand() or CommandManager.addCommand(). |
| 82 | +// See FortniteBotEventCore.ts for example. |
| 83 | +``` |
| 84 | + |
3 | 85 |
|
4 | 86 | ## Commands |
5 | 87 | ``` |
6 | | -!fortnite - Asks your targets to play fortnite. |
7 | | -!fortnite tts - Asks your targets to play fortnite but more nicely. |
8 | | -!fortnite target {@target1} {@target2} ... {@targetn} - Set new targets/friends. |
9 | | -!fortnite auto {amount} {delay(ms)} - Ask your friends many times |
10 | | -!fortnite delete - Deletes all messages sent by the bot. |
| 88 | +Standard Commands |
| 89 | +!f - Asks your targets to play fortnite. |
| 90 | +!f ping - Check for response. |
| 91 | +!f help - Displays help message. |
| 92 | +!f target @target - Adds target to the targetlist. |
| 93 | +!f targetlist - Shows the current targets. |
| 94 | +!f removeself - Removes yourself from the targetlist. |
| 95 | +!f auto amount delay(s) - Automatically ping the targets a set amount of times with an delay. |
| 96 | +
|
| 97 | +User Commands |
| 98 | +!f register - Registers yourself. |
| 99 | +!f profile - Check your profile. |
| 100 | +!f daily - Grab daily rewards. |
| 101 | +
|
| 102 | +Shop Commands |
| 103 | +!f shoplist - Displays all available shops. |
| 104 | +!f viewshop shopname - View a shop. |
| 105 | +!f buy index/itemname from shopname - Buy an item from a shop. |
| 106 | +
|
| 107 | +...More coming soon. |
11 | 108 | ``` |
| 109 | + |
12 | 110 | ## Contributing |
13 | | -~~Don't.~~ |
| 111 | +All contribtions are welcome. Adhering to tslint style is recommeded. |
14 | 112 |
|
15 | 113 | ## Disclaimer |
16 | 114 | I do not play nor have any affiliation with Fortnite. This application is a simple tool to ~~spam~~ ask your friends/server members. |
0 commit comments