This repository was archived by the owner on Dec 13, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Add Bot #82
Closed
Closed
Add Bot #82
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
42468ca
Add bot
b445323
Update url + key on list edit
b3dcbbf
Different syntax
040a794
Make CI like ma syntax
b53691b
Merge branch 'node' into node
GavynStanley 3f470e2
Merge branch 'node' into node
GavynStanley 3248afc
Fix some spelling errors. Add slash commands toggle.
2d772d1
Hide `add_bot` & `add_bot_key` from edit log
jacobmitchell04 9bffb63
Change checkbox when toggling lists to add bot to from 'minus' to 'plus'
320bc00
Add 'maxlength' attribute to fields with a max length
e81fba4
Add authentication requirement for post version of '/add'
a39ec88
Fix eslint
jacobmitchell04 607bd48
Server side validation with joi
e3943c7
Fix schema. Remove unneeded else statement.
559bc2e
Eslint
f246850
I hate Eslint
df94d17
I hate Eslint
76e646d
Fix allowed library strings
cb35df5
Require auth for POST '/add/:id'
33351b6
Fix Website.js. Fix if logic in Bot.js
f805b7e
Add newline to list.pug.
1c969b5
Add newline to add.pug.
6230231
Fix id for slash commands input
4581cec
Fix logic for checking if a bot list has been toggled.
223f7b7
Fix logic for checking if a bot list has been toggled.
ffe3d32
Update logic for checking if nsfw and slash_commands checkbox. Eslint.
4dee710
Eslint
d782a04
joi now alerts user of error if data illicitly is added client side. …
6ec10ca
Remove accidental console.log.
af5d055
Eslint
b1d49a1
Remove add_bot and add_bot_key in api
27e6d61
Eslint
108f442
Fix 500
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| exports.up = async function (knex) { | ||
| await knex.schema.table('lists', function (t) { | ||
| t.text('add_bot'); | ||
| t.text('add_bot_key'); | ||
| }); | ||
| }; | ||
|
|
||
| exports.down = async function (knex) { | ||
| await knex.schema.table('lists', function (t) { | ||
| t.dropColumn('add_bot'); | ||
| t.dropColumn('add_bot_key'); | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| function isInt(value) { | ||
| return !isNaN(value) && | ||
| parseInt(Number(value)) == value && | ||
| !isNaN(parseInt(value, 10)); | ||
| } | ||
|
|
||
| function isSnowflake(value) { | ||
| return isInt(value) && value.length >= 16; | ||
| } | ||
|
|
||
| document.getElementById('add').addEventListener('submit', function (e) { | ||
| var value = document.getElementById('botid'); | ||
| if (!value) { | ||
| var inputs = document.querySelectorAll('input[type=checkbox]:checked'); | ||
| if (inputs.length == 0) { | ||
| document.getElementById('error').innerText = 'You must submit to at least one list!'; | ||
| return e.preventDefault(); | ||
| } else if (inputs.length == 1) { | ||
| if (inputs[0].id == 'nsfw') { | ||
| document.getElementById('error').innerText = 'You must submit to at least one list!'; | ||
| return e.preventDefault(); | ||
| } | ||
| } | ||
|
GavynStanley marked this conversation as resolved.
Outdated
|
||
| } | ||
| if (!value.value) { return e.preventDefault(); } | ||
| if (!isSnowflake(value.value)) { | ||
| document.getElementById('error').innerText = 'Please enter a valid snowflake ID to add'; | ||
| return e.preventDefault(); | ||
| } | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| const Joi = require('joi'); | ||
|
|
||
| const schema = Joi.object({ | ||
| name: Joi.string() | ||
| .min(1) | ||
| .max(25) | ||
| .required(), | ||
|
|
||
| prefix: Joi.string() | ||
| .min(1) | ||
| .max(25) | ||
| .required(), | ||
|
|
||
| library: Joi.string() | ||
| .valid('discljord', 'aegis.cpp', 'Crystal', 'discordcr', 'Discord.Net', 'DSharpPlus', 'dscord', 'DiscordGo', | ||
|
GavynStanley marked this conversation as resolved.
Outdated
|
||
| 'DisGord', 'catnip', 'Discord4J', 'Javacord', 'JDA', 'discord.js', 'eris', 'Discord.jl', 'Discordia', | ||
| 'Discordnim', 'RestCord', 'discord.py', 'disco', 'discordrb', 'discord-rs', 'Serenity', 'AckCord', 'Sword', 'disco') | ||
| .required(), | ||
|
|
||
| short_desc: Joi.string() | ||
| .min(1) | ||
| .max(100) | ||
| .required(), | ||
|
|
||
| long_desc_plain: Joi.string() | ||
| .min(1) | ||
| .max(5000) | ||
| .required(), | ||
|
|
||
| long_desc_rich: Joi.string() | ||
| .min(1) | ||
| .max(5000) | ||
| .required(), | ||
|
|
||
| invite_url: Joi.string() | ||
| .min(1) | ||
| .required(), | ||
|
|
||
| website_url: Joi.string() | ||
| .allow('') | ||
| .optional(), | ||
|
|
||
| support_url: Joi.string() | ||
| .allow('') | ||
| .optional(), | ||
|
|
||
| donate_url: Joi.string() | ||
| .allow('') | ||
| .optional(), | ||
|
|
||
| github_url: Joi.string() | ||
| .allow('') | ||
| .optional(), | ||
|
|
||
| nsfw: Joi.boolean(), | ||
|
|
||
| slash_commands: Joi.boolean() | ||
|
|
||
| }).options({ stripUnknown: true }); | ||
|
|
||
| exports.schema = schema; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| form#add(method='POST' action='/bot/add/' + bot.id) | ||
| .columns | ||
| .column.is-half-desktop.is-full-mobile | ||
| .card.is-box-shadow | ||
| .card-content | ||
| .field | ||
| div.media | ||
| div.media-left | ||
| img(class='image lazyload' src='https://cdn.discordapp.com/avatars/' + bot.id + '/' + bot.avatar + '.png', alt=bot.username + ' Icon') | ||
| div.media-content | ||
| label.label(for='name') Bot Name * | ||
| p (Max Length: 25) | ||
| .control | ||
| input.input(maxlength='25' type='text' id='name' name='name' value=bot.username, required) | ||
| label.label(for='id') Bot ID | ||
| .control | ||
| input.input(type='text' id='id' name='id' value=bot.id, disabled) | ||
| label.label(for='owner_id') Owner ID | ||
| .control | ||
| input.input(type='text' id='owner_id' name='owner_id' value=user.id, disabled) | ||
| label.label(for='nsfw') NSFW | ||
| p Please tick if the bot (or avatar) is NSFW | ||
| div(tabindex='0' role='button' class='checkbox always disallowed') | ||
| div(class='checkbox-inner') | ||
| input(type='checkbox' id='nsfw' name='nsfw' checked=false) | ||
| span | ||
| label.label(for='slash_commands') Slash Commands | ||
| p Please tick if the bot requires | ||
| code applications.commands | ||
| div(tabindex='0' role='button' class='checkbox always disallowed') | ||
| div(class='checkbox-inner') | ||
| input(type='checkbox' id='nsfw' name='nsfw' checked=false) | ||
|
GavynStanley marked this conversation as resolved.
Outdated
|
||
| span | ||
| label.label(for='prefix') Prefix * | ||
| p (Max Length: 25) | ||
| .control | ||
| input.input(maxlength='25' type='text' id='prefix' name='prefix' required) | ||
| label.label(for='library') Library * | ||
| .control | ||
| .select | ||
| select(name='library' id='library', required) | ||
| option(value='' selected disabled hidden) Select a library | ||
| option(value='' disabled) Clojure | ||
| option(value='discljord') discljord | ||
| option(value='' disabled) C++ | ||
| option(value='aegis.cpp') aegis.cpp | ||
| option(value='' disabled) Crystal | ||
| option(value='discordcr') discordcr | ||
| option(value='' disabled) C# | ||
| option(value='Discord.Net') Discord.Net | ||
| option(value='DSharpPlus') DSharpPlus | ||
| option(value='' disabled) D | ||
| option(value='dscord') dscord | ||
| option(value='' disabled) Go | ||
| option(value='DiscordGo') DiscordGo | ||
| option(value='DisGord') DisGord | ||
| option(value='' disabled) Java | ||
| option(value='catnip') catnip | ||
| option(value='Discord4J') Discord4J | ||
| option(value='Javacord') Javacord | ||
| option(value='JDA') JDA | ||
| option(value='' disabled) JavaScript | ||
| option(value='discord.js') discord.js | ||
| option(value='Eris') Eris | ||
| option(value='' disabled) Julia | ||
| option(value='Discord.jl') Discord.jl | ||
| option(value='' disabled) Lua | ||
| option(value='Discordia') Discordia | ||
| option(value='' disabled) Nim | ||
| option(value='discordnim') discordnim | ||
| option(value='' disabled) PHP | ||
| option(value='RestCord') RestCord | ||
| option(value='' disabled) Python | ||
| option(value='discord.py') discord.py | ||
| option(value='disco') disco | ||
| option(value='' disabled) Ruby | ||
| option(value='discordrb') discordrb | ||
| option(value='' disabled) Rust | ||
| option(value='discord-rs') discord-rs | ||
| option(value='Serenity') Serenity | ||
| option(value='' disabled) Scala | ||
| option(value='AckCord') AckCord | ||
| option(value='' disabled) Swift | ||
| option(value='Sword') Sword | ||
| option(value='' disabled) TypeScript | ||
| option(value='Discordeno') disco | ||
| label.label(for='short_desc') Short Description * | ||
| p (Max Length: 100) | ||
| .control | ||
| input.input(maxlength='100' type='text' id='short_desc' name='short_desc' required) | ||
| label.label(for='long_dec_plain') Long Description Plain * | ||
| p (Max Length: 5000) | ||
| p This long description field will be used on bot lists that do not support Markdown or HTML in their long descriptions. | ||
| .control | ||
| textarea.textarea#long_desc_plain(maxlength='5000' type='text' name='long_desc_plain' required) | ||
| label.label(for='long_desc_rich') Long Description Rich * | ||
| p (Max Length: 5000) | ||
| p This long description field will be used on bot lists that support Markdown or HTML in their long descriptions. | ||
| .control | ||
| textarea.textarea#long_desc_rich(maxlength='5000' type='text' name='long_desc_rich' required) | ||
| label.label(for='invite_url') Bot Invite URL * | ||
| .control | ||
| input.input(type='link' pattern='https?://.+' id='invite_url' name='invite_url' value="https://discord.com/oauth2/authorize?client_id=" + bot.id + "&scope=bot" required) | ||
| label.label(for='website_url') Website URL | ||
| .control | ||
| input.input(type='link' pattern='https?://.+' id='website_url' name='website_url') | ||
| label.label(for='support_url') Support (Server) URL | ||
| .control | ||
| input.input(type='link' pattern='https?://.+' id='support_url' name='support_url') | ||
| label.label(for='donate_url') Donate URL | ||
| .control | ||
| input.input(type='link' pattern='https?://.+' id='donate_url' name='donate_url') | ||
| label.label(for='github_url') GitHub URL | ||
| .control | ||
| input.input(type='link' pattern='https?://.+' id='github_url' name='github_url') | ||
|
|
||
| .column.is-half-desktop.is-full-mobile.top | ||
| .card.is-box-shadow | ||
| .card-content | ||
| .hero | ||
| .hero-body.hero-slim | ||
| .has-text-centered | ||
| h1.title.is-size-6#error | ||
| h1.title.is-size-4 Supported Lists | ||
| for list in supportedLists | ||
| .columns(class='has-margin-top') | ||
| .checkbox.always(tabindex='0' role='button' class='interactive plus') | ||
| div(class='checkbox-inner') | ||
| input(type='checkbox', id=list.name, name=list.name checked=true) | ||
| span | ||
| span #{list.name} | ||
| br | ||
| input.button.is-brand(type='submit' value='Add bot to all supported bot lists' disabled=supportedLists.length == 0) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| extends ../layout | ||
| block content | ||
| section.section | ||
| .container | ||
| - if(joi_error) | ||
| .card.is-box-shadow | ||
| .card-content | ||
| p#error | ||
| p Validation Error: #{details} | ||
| - else | ||
| - if(!error && bot) | ||
| include ../Includes/forms/addBot | ||
| - else | ||
| .hero | ||
| .hero-body.hero-slim | ||
| .has-text-centered | ||
| h1.title.is-size-4 Add a New Bot | ||
| h5.title.is-size-5 Add a new bot to all lists that support BotBlock | ||
| h6.title.is-size-6 Submit a bot to all lists that accept BotBlock with standard information for all listings. | ||
|
|
||
| - if(after) | ||
| .columns | ||
| .column.is-half-desktop.is-full-mobile | ||
| .card.is-box-shadow | ||
| .has-text-centered | ||
| .card-content | ||
| p.has-text-white | ||
| | Submission Status | ||
| br | ||
| for result in results | ||
| if !result.error | ||
| p.has-text-success #{result.name} | ||
| else | ||
| p.has-text-danger #{result.name} | ||
| if result.message | ||
| p Message: #{result.message} | ||
| else | ||
| p Message: No message | ||
| hr | ||
| - else | ||
| .columns | ||
| .column.is-half-desktop.is-full-mobile | ||
| form#add(method="POST") | ||
| .card.is-box-shadow | ||
| .card-content | ||
| p#error | ||
| - if(error) | ||
| p This bot was not found on Discord | ||
| .field | ||
| label.label(for='botid') Bot Client ID to add to bot lists | ||
| .control | ||
| input.input#botid(name='botid' type='text') | ||
| h1.is-brand Please make sure to join the bot list servers before adding your bot as many require bot owners to be in the server. | ||
| input.button.is-brand(type='submit' value='Begin adding your bot') | ||
|
|
||
|
|
||
| block footer | ||
| script(defer src='/assets/js/checkboxes/interactive.js') | ||
| script(src='/assets/js/bot/add.js') | ||
|
GavynStanley marked this conversation as resolved.
Outdated
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.