├── .gitignore ├── collectors.json ├── .prettierrc.js ├── .eslintrc.js ├── .github └── workflows │ └── codeFormat.yml ├── config.json ├── package.json ├── events ├── messageCreate.js └── messageReactionAdd.js ├── commands └── startapps.js ├── README.md ├── main.js └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /collectors.json: -------------------------------------------------------------------------------- 1 | { "collector": [], "tickets": [] } 2 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | tabWidth: 2, 3 | singleQuote: true, 4 | printWidth: 150, 5 | semi: true, 6 | bracketSpacing: true, 7 | bracketSameLine: true, 8 | trailingComma: 'es5', 9 | }; 10 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | commonjs: true, 4 | es2021: true, 5 | node: true, 6 | }, 7 | extends: ['eslint:recommended', 'prettier'], 8 | parserOptions: { 9 | ecmaVersion: 'latest', 10 | }, 11 | rules: { 12 | 'no-unused-vars': ['warn'], 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /.github/workflows/codeFormat.yml: -------------------------------------------------------------------------------- 1 | name: Code Format 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | codeFormat: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Install Dependencies 18 | run: npm ci 19 | 20 | - name: Run ESLint 21 | run: npx eslint . 22 | 23 | - name: Run Prettier 24 | run: npx prettier --check . 25 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "(Enter Token here)", 3 | "prefix": "(Enter Prefix Here)", 4 | "owner": "(Enter id of Bot Owner)", 5 | "Channelrole": ["(Enter id of Viewing Role)", "(You can add more if you want)"], 6 | "signup_color": "(Enter Hex Code for signup Embed Here)", 7 | "signup_title": "(Enter Title for signup Embed Here)", 8 | "answer_title": "(Enter Title for Answer Embed Here)", 9 | "answer_color": "(Enter Hex Code for Answer Embed Here)", 10 | "answer_description": "(Enter Answer Embed Description) (Use \n for breaking lines!)", 11 | "answer_category": "(Enter id of Category for Tickets)", 12 | "allow_user_delete": false, 13 | "allow_user_lock": false, 14 | "allow_user_unlock": false, 15 | "one_app": true 16 | } 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "discord-ticket-bot", 3 | "version": "1.0.0", 4 | "description": "A simple Ticket Bot for discord coded in Discord.js", 5 | "main": "main.js", 6 | "scripts": { 7 | "start": "node main.js", 8 | "dev": "nodemon main.js", 9 | "lint": "eslint .", 10 | "lint:fix": "eslint . --fix" 11 | }, 12 | "nodemonConfig": { 13 | "ignore": [ 14 | "*.json" 15 | ] 16 | }, 17 | "keywords": [], 18 | "author": "arisamiga", 19 | "license": "Apache-2.0", 20 | "dependencies": { 21 | "discord.js": "^13.6.0" 22 | }, 23 | "devDependencies": { 24 | "eslint": "^8.45.0", 25 | "eslint-config-prettier": "^8.8.0", 26 | "nodemon": "^3.0.1", 27 | "prettier": "^3.0.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /events/messageCreate.js: -------------------------------------------------------------------------------- 1 | const config = require(`../config.json`); 2 | module.exports = (client, message) => { 3 | //Ignore all bots 4 | if (message.author.bot) return; 5 | 6 | //Prefix 7 | let prefix = config.prefix; 8 | 9 | //Ignore messages not starting with the prefix (in config.json) 10 | 11 | if (!message.content.startsWith(prefix)) return; 12 | 13 | //Our standard argument/command name definition. 14 | const args = message.content.slice(prefix.length).trim().split(/ +/g); 15 | const command = args.shift().toLowerCase(); 16 | 17 | //Grab the command data from the client.commands (Discord collection) 18 | const cmd = client.commands.get(command); 19 | //If that command doesn't exist, silently exit and do nothing 20 | if (!cmd) return; 21 | 22 | //Run the command 23 | cmd.run(client, message, args); 24 | }; 25 | -------------------------------------------------------------------------------- /commands/startapps.js: -------------------------------------------------------------------------------- 1 | const Jsonfile = require('../config.json'); 2 | const fs = require('fs'); 3 | exports.run = async (client, message) => { 4 | if (message.author.id !== Jsonfile.owner) 5 | return message.channel.send('Sorry but you cant use this command D:').then((msg) => { 6 | setTimeout(() => msg.delete(), 7000); 7 | }); 8 | 9 | function addToCollectors(messageID, channelID) { 10 | fs.readFile('./collectors.json', 'utf8', function readFileCallback(err, data) { 11 | if (err) return console.error(err); 12 | const obj = JSON.parse(data); 13 | obj.collector.push({ id: messageID, channelId: channelID }); 14 | const json = JSON.stringify(obj); 15 | fs.writeFile('./collectors.json', json, 'utf8', function (err) { 16 | if (err) throw err; 17 | }); 18 | }); 19 | } 20 | const signupEmbed = { 21 | color: Jsonfile.signup_color, 22 | fields: [ 23 | { 24 | name: Jsonfile.signup_title, 25 | value: 'To create a ticket react with 📩', 26 | }, 27 | ], 28 | footer: { 29 | icon_url: client.user.avatarURL(), 30 | }, 31 | }; 32 | const signup = await message.channel.send({ 33 | embeds: [signupEmbed], 34 | }); 35 | await signup.react('📩'); 36 | addToCollectors(signup.id, message.channel.id); 37 | }; 38 | 39 | const contining = async (client, message, user) => { 40 | function addToTickets(messageID, channelID) { 41 | fs.readFile('./collectors.json', 'utf8', function readFileCallback(err, data) { 42 | if (err) console.error(err); 43 | const obj = JSON.parse(data); 44 | obj.tickets.push({ id: messageID, channelId: channelID, owner: user.id }); 45 | const json = JSON.stringify(obj); 46 | fs.writeFile('./collectors.json', json, 'utf8', (err) => { 47 | if (err) throw err; 48 | }); 49 | }); 50 | } 51 | 52 | let channel = await message.guild.channels.create(`ticket: ${user.username}`, { 53 | parent: Jsonfile.answer_category, 54 | }); 55 | 56 | channel.permissionOverwrites.edit(message.guild.id, { 57 | SEND_MESSAGES: false, 58 | VIEW_CHANNEL: false, 59 | }); 60 | channel.permissionOverwrites.edit(user.id, { 61 | SEND_MESSAGES: true, 62 | VIEW_CHANNEL: true, 63 | }); 64 | Jsonfile.Channelrole.forEach((role) => { 65 | channel.permissionOverwrites.edit(role, { 66 | SEND_MESSAGES: true, 67 | VIEW_CHANNEL: true, 68 | }); 69 | }); 70 | 71 | const reactionMessageEmbed = { 72 | color: Jsonfile.answer_color, 73 | fields: [ 74 | { 75 | name: Jsonfile.answer_title, 76 | value: Jsonfile.answer_description, 77 | }, 78 | ], 79 | footer: { 80 | icon_url: client.user.avatarURL(), 81 | }, 82 | }; 83 | const reactionMessage = await channel.send({ 84 | embeds: [reactionMessageEmbed], 85 | }); 86 | await reactionMessage.react('🔒'); 87 | await reactionMessage.react('🔓'); 88 | await reactionMessage.react('⛔'); 89 | 90 | addToTickets(reactionMessage.id, channel.id); 91 | }; 92 | 93 | module.exports.contining = contining; 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Discord-Ticket-Bot 2 | 3 | ### A Simple useful ticket bot for discord coded in Discord.js 4 | 5 | 6 | Issues 7 | 8 | 9 | [![CodeFactor](https://www.codefactor.io/repository/github/arisamiga/discord-ticket-bot/badge?s=ce8618765d3ec8b05264bac256588a4411f7712b)](https://www.codefactor.io/repository/github/arisamiga/discord-ticket-bot) 10 | 11 | 12 | 13 | ## Installation 14 | 15 | ``` 16 | You have to install NodeJS and Git. 17 | Create a folder. 18 | Open Command Promt. 19 | Type in: cd The path to your new folder. (Example: C:\Users\User\Desktop\New folder) 20 | Press enter. 21 | After that type in: git clone https://github.com/Arisamiga/Discord-Ticket-Bot.git . 22 | Press enter. 23 | After that, you'll have to install external modules, just type: "npm install" 24 | When you see all Github files in your folder you installed the bot files succesfully. 25 | After that you would want to edit the config.json. 26 | ``` 27 | 28 | Change the following 29 | 30 | ``` 31 | { 32 | "token": "(Enter Token here)", 33 | "prefix": "(Enter Prefix Here)", 34 | "owner": "(Enter id of Bot Owner)", 35 | "Channelrole": ["(Enter id of Viewing Role)","(You can add more if you want)"], 36 | "signup_color": "(Enter Hex Code for signup Embed Here)", 37 | "signup_title": "(Enter Title for signup Embed Here)", 38 | "answer_title": "(Enter Title for Answer Embed Here)", 39 | "answer_color": "(Enter Hex Code for Answer Embed Here)", 40 | "answer_description": "(Enter Answer Embed Description) (Use \n for breaking lines!)", 41 | "answer_category": "(Enter id of Category for Tickets)", 42 | "allow_user_delete": false, (Allow users to delete their own tickets) 43 | "allow_user_lock": false, (Allow users to lock their own tickets) 44 | "allow_user_unlock": false, (Allow users to unlock their own tickets) 45 | "one_app": true (Pick either True = To allow only 1 ticket to exist at a time / False = To allow multiple ticket to exist at a time) 46 | } 47 | 48 | ``` 49 | 50 | Get your discord token from https://discord.com/developers/applications 51 | 52 | And you should be ready to start the bot! 53 | 54 | Use either use `npm start` or `node main.js` to start the bot in your command prompt! 55 | 56 | ## Nodemon Usage 57 | 58 | If you wish to use nodemon instead of node, you can use `npm run dev` to start the bot with nodemon! 59 | 60 | ## Setting the Reaction Embed! 61 | 62 | To start the Reaction Embed you should have the bot enabled. 63 | Next you should enter the command showed bellow 64 | 65 | ``` 66 | (your Prefix)startapps 67 | ``` 68 | 69 | And after that you should have made a Reaction Embed! Congrats! 70 | So when someone reacts to the message a channel will be created and the Answer Embed will be sent. 71 | 72 | ## Features! 73 | 74 | 97 | 98 | ### If you are having troubles with the bot i recommend opening a issue. 99 | 100 | **_Made By Arisamiga_** 101 | -------------------------------------------------------------------------------- /events/messageReactionAdd.js: -------------------------------------------------------------------------------- 1 | const config = require(`../config.json`); 2 | const fs = require('fs'); 3 | const { contining } = require('../commands/startapps.js'); 4 | module.exports = (client, messageReaction, user) => { 5 | if (user.bot) return; // Ignore bot's reactions 6 | 7 | // Readfile collectors.json and save it in a variable 8 | let collectors = JSON.parse(fs.readFileSync('./collectors.json', 'utf8')); 9 | 10 | // Handle collectors 11 | if (collectors.collector.filter((e) => e.id === messageReaction.message.id).length > 0) { 12 | if (messageReaction.emoji.name === '📩') { 13 | let channelname = `ticket-${user.username}`; 14 | channelname = channelname.replace(/\s/g, '-').toLowerCase(); 15 | if (messageReaction.message.guild.channels.cache.find((channel) => channel.name === channelname) && config.one_app) { 16 | user.send(`You already have an ongoing ticket.`).catch(console.error); 17 | return messageReaction.users.remove(user.id); 18 | } 19 | contining(client, messageReaction.message, user); 20 | messageReaction.users.remove(user.id); 21 | } 22 | } 23 | 24 | // Handle tickets 25 | if (collectors.tickets.filter((e) => e.id === messageReaction.message.id).length > 0) { 26 | let channel = messageReaction.message.guild.channels.cache.find((channel) => channel.id === messageReaction.message.channel.id); 27 | const ownerID = collectors.tickets.filter((e) => e.id === messageReaction.message.id)[0].owner; 28 | // Get owner of the ticket 29 | client.users.fetch(ownerID).then((owner) => { 30 | switch (messageReaction.emoji.name) { 31 | case '🔒': 32 | if (!checkUser(messageReaction.message, user) && !config.allow_user_lock) { 33 | user.send('Only Staff can lock the channels'); 34 | return messageReaction.users.remove(user.id); 35 | } 36 | if (channel.permissionOverwrites.cache.get(ownerID)?.deny.has('SEND_MESSAGES')) { 37 | user.send('This channel is already locked'); 38 | return messageReaction.users.remove(user.id); 39 | } 40 | channel.permissionOverwrites.edit(owner, { 41 | SEND_MESSAGES: false, 42 | }); 43 | return messageReaction.message.channel.send('Channel Locked 🔒'); 44 | case '🔓': 45 | if (!checkUser(messageReaction.message, user) && !config.allow_user_unlock) { 46 | user.send('Only Staff can unlock the channels'); 47 | return messageReaction.users.remove(user.id); 48 | } 49 | if (channel.permissionOverwrites.cache.get(ownerID)?.allow.has('SEND_MESSAGES')) { 50 | user.send('This channel is already unlocked'); 51 | return messageReaction.users.remove(user.id); 52 | } 53 | channel.permissionOverwrites.edit(owner, { 54 | SEND_MESSAGES: true, 55 | }); 56 | return messageReaction.message.channel.send('Channel Unlocked 🔓'); 57 | case '⛔': 58 | if (!messageReaction.message.guild.channels.cache.find((c) => c.name.toLowerCase() === channel.name)) return; 59 | if (!checkUser(messageReaction.message, user) && !config.allow_user_delete) { 60 | user.send('Only Staff can delete the channels').catch(console.error); 61 | return messageReaction.users.remove(user.id); 62 | } 63 | 64 | setTimeout(() => { 65 | if (messageReaction.message.guild.channels.cache.find((c) => c.name.toLowerCase() === channel.name)) channel.delete(); 66 | removeTicketfromCollectors(messageReaction.message.id); 67 | }, 5000); 68 | 69 | return messageReaction.message.channel.send('Deleting this channel in 5 seconds!'); 70 | } 71 | }); 72 | } 73 | }; 74 | 75 | const checkUser = (message, user) => { 76 | if (message.guild.members.cache.find((member) => member.id === user.id).permissions.has('ADMINISTRATOR')) return true; 77 | 78 | const roles = config.Channelrole.some((role) => { 79 | if (message.guild.members.cache.find((member) => member.id === user.id).roles.cache.find((r) => r.id === role)) return true; 80 | }); 81 | if (roles) return true; 82 | 83 | return false; 84 | }; 85 | const removeTicketfromCollectors = (MessageID) => { 86 | let collectors = JSON.parse(fs.readFileSync('./collectors.json', 'utf8')); 87 | collectors.tickets = collectors.tickets.filter((e) => e.id !== MessageID); 88 | const json = JSON.stringify(collectors); 89 | fs.writeFile('./collectors.json', json, 'utf8', (err) => { 90 | if (err) throw err; 91 | }); 92 | }; 93 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | const { Collection, Intents, Client } = require('discord.js'); 2 | const client = new Client({ 3 | intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS], 4 | partials: ['CHANNEL', 'GUILD_MEMBER', 'MESSAGE', 'REACTION', 'USER'], 5 | }); 6 | const fs = require('fs'); 7 | const token = require('./config.json'); 8 | 9 | client.on('ready', async () => { 10 | console.log(`Logged in as user: ${client.user.tag}, ID: ${client.user.id}`); 11 | client.user.setStatus('online'); 12 | 13 | console.log('Checking collectors.json'); 14 | if (!fs.existsSync('./collectors.json')) { 15 | console.log('collectors.json not found, creating file...'); 16 | fs.writeFile('./collectors.json', '{"collector": [], "tickets": []}', function (err) { 17 | if (err) throw err; 18 | }); 19 | } 20 | // Check if messageid's in collectors.json are still valid 21 | fs.readFile('./collectors.json', 'utf8', function readFileCallback(err, data) { 22 | if (err) { 23 | console.log(err); 24 | } else { 25 | // Read collectors.json and check if the messageid's are still valid 26 | const obj = JSON.parse(data); 27 | var collectorToDeleteid = []; 28 | var ticketToDeleteid = []; 29 | var collectorCheck = false; 30 | var ticketCheck = false; 31 | 32 | if (obj.collector.length == 0) { 33 | collectorCheck = true; 34 | } 35 | if (obj.tickets.length == 0) { 36 | ticketCheck = true; 37 | } 38 | 39 | for (let i = 0; i < obj.collector.length; i++) { 40 | checkMessage(obj.collector[i].id, obj.collector[i].channelId).then((result) => { 41 | // Reread collectors.json and remove the invalid messageid 42 | if (!result) { 43 | console.log(`Cleaning up inactive collector: messageid: ${obj.collector[i].id} in channelid: ${obj.collector[i].channelId}`); 44 | collectorToDeleteid.push(obj.collector[i].id); 45 | } 46 | }); 47 | if (i == obj.collector.length - 1) collectorCheck = true; 48 | } 49 | for (let i = 0; i < obj.tickets.length; i++) { 50 | checkMessage(obj.tickets[i].id, obj.tickets[i].channelId).then((result) => { 51 | // Reread collectors.json and remove the invalid messageid 52 | if (!result) { 53 | console.log(`Cleaning up inactive ticket: messageid: ${obj.tickets[i].id} in channelid: ${obj.tickets[i].channelId}`); 54 | ticketToDeleteid.push(obj.tickets[i].id); 55 | } 56 | }); 57 | if (i == obj.tickets.length - 1) ticketCheck = true; 58 | } 59 | 60 | // Wait for the promises to finish 61 | var interval = setInterval(function () { 62 | if (collectorCheck && ticketCheck) { 63 | clearInterval(interval); 64 | // Remove invalid messageid's 65 | for (let i = 0; i < collectorToDeleteid.length; i++) { 66 | for (let j = 0; j < obj.collector.length; j++) { 67 | if (obj.collector[j].id == collectorToDeleteid[i]) { 68 | obj.collector.splice(j, 1); 69 | } 70 | } 71 | } 72 | for (let i = 0; i < ticketToDeleteid.length; i++) { 73 | for (let j = 0; j < obj.tickets.length; j++) { 74 | if (obj.tickets[j].id == ticketToDeleteid[i]) { 75 | obj.tickets.splice(j, 1); 76 | } 77 | } 78 | } 79 | // Write the new collectors.json 80 | const json = JSON.stringify(obj); 81 | fs.writeFile('./collectors.json', json, 'utf8', (err) => { 82 | if (err) throw err; 83 | console.log('collectors.json Updated'); 84 | }); 85 | } 86 | }, 1000); 87 | } 88 | }); 89 | }); 90 | 91 | fs.readdir('./events/', (err, files) => { 92 | if (err) return console.error(err); 93 | files.forEach((file) => { 94 | const event = require(`./events/${file}`); 95 | let eventName = file.split('.')[0]; 96 | console.log(`Loading event ${eventName}`); 97 | client.on(eventName, event.bind(null, client)); 98 | }); 99 | }); 100 | 101 | client.commands = new Collection(); 102 | 103 | fs.readdir('./commands/', (err, files) => { 104 | if (err) return console.error(err); 105 | files.forEach((file) => { 106 | if (!file.endsWith('.js')) return; 107 | let props = require(`./commands/${file}`); 108 | let commandName = file.split('.')[0]; 109 | console.log(`Loaded ${commandName}`); 110 | client.commands.set(commandName, props); 111 | }); 112 | }); 113 | 114 | client.login(token.token); 115 | 116 | const checkMessage = async (id, channelid) => { 117 | const channel = await client.channels.cache.get(channelid); 118 | if (!channel) return; 119 | const channelMessage = await channel?.messages.fetch(id).catch((err) => console.error(`Error ${err.httpStatus}: ${err.message}`)); 120 | return channelMessage; 121 | }; 122 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------