<%- include("../../partials/header.ejs") %>
<link rel="stylesheet" data-name="vs/editor/editor.main" href="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs/editor/editor.main.min.css" integrity="sha512-XjO5XYWl8u7tYF3CItEHgoWh8rtQmDeSzPJq4+4PIrbak7TiqeKbWv/4ZwHZ1HAf5dIWHXoguA/jobn2psKZ7w==" crossorigin="anonymous">
<link href="/css/monaco.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous" async></script>
<script src="https://cdn.jsdelivr.net/gh/jitbit/HtmlSanitizer@master/HtmlSanitizer.js"></script>
<%- include("../../partials/nav.ejs") %>
<%
    let postURL = `${linkPrefix}/bots/${bot._id}/edit`;
    if (resubmit) postURL = `${linkPrefix}/bots/${bot._id}/resubmit`;
%>
<section class="hero is-primary">
    <div class="hero-body">
        <br>
        <div class="container has-text-centered">
            <h1 class="title">
                <% if (resubmit === false) { %>
                    <span class="icon is-medium iconalign">
                        <i aria-hidden="true" class="fad fa-pen has-text-default"></i>
                    </span>
                <% } else { %>
                    <span class="icon is-medium iconalign">
                        <i aria-hidden="true" class="fad fa-redo-alt has-text-default"></i>
                    </span>
                <% } %>
                <br>
                <span><%= title %></span>
            </h1>
            <h2 class="subtitle">
                <%= subtitle %>
            </h2>
        </div>
    </div>
</section>
<div class="container">
    <div class="section">
        <article id="errors" style="display: none;" class="message is-danger">
            <div class="message-body content has-background-primary">
                <ul id="errorList" style="margin-top: unset;">
                    
                </ul>
            </div>
        </article>

        <form id="form" method="POST">
            <h3 class="is-size-3 has-text-default"><%= __("page.form.category.generalInfo") %></h3>
            <br>
            <div class="field">
                <label class="label has-text-default"><span id="idText"><%= __("page.bots.generalInfo.clientID") %></span> <span class="has-text-danger">(<%= __("common.form.readOnly") %>)</span></label>
                <p class="control has-icons-left" required>
                    <input id="form_id" class="input is-rounded" type="text" name="id" value="<%= bot._id %>" placeholder="568254611354419211" readonly>
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-hashtag"></i>
                    </span>
                </p>
            </div>
            <br>
            <label class="label has-text-default"><%= __("page.bots.generalInfo.scopes") %> <span class="has-text-danger">*</span></label>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-default" type="checkbox" id="bot" name="bot" <% if (bot.scopes?.bot) { %> checked <% } %>>
                <label class="has-text-default" for="bot"><%= __("common.bot") %></label>
            </div>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-default" type="checkbox" id="slashcommands" name="slashcommands" <% if (bot.scopes?.slashCommands) { %> checked <% } %>>
                <label class="has-text-default" for="slashcommands"><%= __("common.applicationCommands") %></label>
            </div>
            <br>
            <div class="field" id="clientIDBlock" style="display: none">
                <label class="label has-text-default"><%= __("page.bots.generalInfo.clientID") %></label>
                <p style="padding-bottom: 10px;" class="is-size-7 has-text-default">
                    <%= __("page.bots.generalInfo.clientID.detailsEdit") %>
                </p>
                <p class="control has-icons-left" required>
                    <input id="form_clientID" class="input is-rounded" type="text" name="clientID" value="<%= bot.clientID || bot._id %>">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-hashtag"></i>
                    </span>
                </p>
                <br>
            </div>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.generalInfo.editors") %> <span class="has-text-default">(<%= __("common.form.spaceSeparated") %>)</span></label>
                <p style="padding-bottom: 10px;" class="is-size-7 has-text-default"><%= __("page.bots.generalInfo.editors.notice") %></p>
                <p class="control has-icons-left">
                    <input id="form_editors" class="input is-rounded" type="text" name="editors" value="<%= editors %>" placeholder="<%= __("page.bots.generalInfo.editors.placeholder") %>">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-user"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field" id="prefixBlock" <% if (bot.scopes && !bot.scopes.bot) { %> style="display: none" <% } %>>
                <label class="label has-text-default"><%= __("page.bots.generalInfo.prefix") %></label>
                <p class="control has-icons-left" required>
                    <input id="form_prefix" class="input is-rounded" type="text" value="<%= bot.prefix %>" name="prefix" placeholder="!" maxlength="32">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-paper-plane"></i>
                    </span>
                </p>
                <br>
            </div>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.generalInfo.library") %> <span class="has-text-danger">*</span></label>
                <div class="control has-icons-left">
                    <div class="select is-rounded">
                        <select id="form_library" name="library" required>
                            <option value="" disabled selected><%= __("common.select") %></option>
                            <option value="<%= bot.library %>" selected><%= bot.library %></option>
                            <% for (const lib of libraries) { %><option value="<%- lib._id %>"><%- lib._id %></option><% } %>
                        </select>
                    </div>
                    <div class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-book"></i>
                    </div>
                </div>
            </div>
            <br>
            <label class="label has-text-default"><%= __("common.tags") %></label>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-link" type="checkbox" id="fun" name="fun" <% if (bot.tags && bot.tags.includes("Fun")) { %>checked="checked"<% } %>>
                <label class="has-text-link" for="fun"><%= __("page.bots.tag.fun") %></label>
            </div>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-info" type="checkbox" id="social" name="social" <% if (bot.tags && bot.tags.includes("Social")) { %>checked="checked"<% } %>>
                <label class="has-text-info" for="social"><%= __("page.bots.tag.social") %></label>
            </div>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-success" type="checkbox" id="economy" name="economy" <% if (bot.tags && bot.tags.includes("Economy")) { %>checked="checked"<% } %>>
                <label class="has-text-success" for="economy"><%= __("page.bots.tag.economy") %></label>
            </div>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-orange" type="checkbox" id="utility" name="utility" <% if (bot.tags && bot.tags.includes("Utility")) { %>checked="checked"<% } %>>
                <label class="has-text-orange" for="utility"><%= __("page.bots.tag.utility") %></label>
            </div>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-danger" type="checkbox" id="moderation" name="moderation" <% if (bot.tags && bot.tags.includes("Moderation")) { %>checked="checked"<% } %>>
                <label class="has-text-danger" for="moderation"><%= __("page.bots.tag.moderation") %></label>
            </div>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-magenta" type="checkbox" id="multipurpose" name="multipurpose" <% if (bot.tags && bot.tags.includes("Multipurpose")) { %>checked="checked"<% } %>>
                <label class="has-text-magenta" for="multipurpose"><%= __("page.bots.tag.multipurpose") %></label>
            </div>
            <div class="field">
                <input class="is-checkradio is-circle has-background-color is-pink" type="checkbox" id="music" name="music" <% if (bot.tags && bot.tags.includes("Music")) { %>checked="checked"<% } %>>
                <label class="has-text-pink" for="music"><%= __("common.tags.music") %></label>
            </div>
            <br>
            <br>
            <h3 class="is-size-3 has-text-default"><%= __("page.form.category.links") %></h3>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.invite") %></label>
                <p class="control has-icons-left">
                    <input id="form_invite" class="input is-rounded" type="text" name="invite" value="<%= bot.links.invite %>" placeholder="<%= __("page.bots.invite.placeholder") %>">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-link"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.website") %></label>
                <p class="control has-icons-left">
                    <input id="form_website" class="input is-rounded" type="text" name="website" value="<%= bot.links.website %>" placeholder="https://watchanimeattheoffice.com">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-globe"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.donate") %></label>
                <p class="control has-icons-left">
                    <input id="form_donationUrl" class="input is-rounded" type="text" name="donationUrl" value="<%= bot.links.donation %>" placeholder="https://bigbeans.solutions">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-dollar-sign"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.supportServer") %></label>
                <p class="control has-icons-left">
                    <input  id="form_supportServer" class="input is-rounded" type="text" name="supportServer" value="<%= bot.links.support %>" placeholder="https://discord.gg/someawesumsupportservhor">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-heart"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.git") %></label>
                <p class="control has-icons-left">
                    <input id="form_repo" class="input is-rounded" type="text" name="repo" value="<%= bot.links.repo %>" placeholder="https://github.com/awsumpersunorpage/awsumrepo">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-code"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.privacyPolicy") %> <span class="has-text-danger">*</span></label>
                <p style="padding-bottom: 10px" class="is-size-7 has-text-default">
                    <%- __("page.bots.privacyPolicy.required", {
                        a: '<a class="has-text-info" target="blank" rel="noopener" href="https://gist.github.com/advaith1/58c61df8f4c7ba984fc72945f0aa5f9c">',
                        ea: "</a>"
                    }) %>
                </p>
                <p class="control has-icons-left">
                    <input id="form_privacyPolicy" class="input is-rounded" type="text" name="privacyPolicy" value="<%= bot.links.privacyPolicy %>" placeholder="!privacy or https://discord.bot/privacy">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-user-secret"></i>
                    </span>
                </p>
            </div>
            <br>
            <br>
            <h3 class="is-size-3 has-text-default"><%= __("common.social") %></h3>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("common.social.twitter") %></label>
                <p class="control has-icons-left">
                    <input id="form_twitter" class="input is-rounded" type="text" name="twitter" value="<%= bot.social && bot.social.twitter %>" placeholder="bestbot" maxlength="15">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="far fa-at"></i>
                    </span>
                </p>
            </div>
            <br>
            <br>
            <h3 class="is-size-3 has-text-default"><%= __("page.form.category.theme") %></h3>
            <br>
            <div class="field">
                <label for="customColourSwitch" class="label has-text-default"><%= __("page.bots.theme.useCustomColor") %></label>
                <p style="padding-bottom: 10px;" class="is-size-7 has-text-default">
                    <%= __("page.bots.theme.useCustomColor.details") %>
                </p>
                <input id="form_customColourSwitch" id="customColourSwitch" type="checkbox" name="useCustomColour" class="switch is-rounded is-info" <% if (bot.theme && bot.theme.useCustomColour) { %>checked<% } %>>
                <label for="form_customColourSwitch"></label>
            </div>
            <br>
            <div class="field" id="form_customColour" style="display: <% if (bot.theme && bot.theme.useCustomColour) { %>inherit<% } else { %>none<% } %>">
                <label class="label has-text-default"><%= __("page.bots.theme.color") %></label>
                <p style="padding-bottom: 10px;" class="is-size-7 has-text-default">
                    <%= __("page.bots.theme.color.details") %>
                </p>
                <p class="control">
                    <input id="form_colour" class="backdrop" name="colour" type="color" value="<%= bot.theme && bot.theme.colour || "#BA2EFF" %>" style="width:30%; background-color: transparent; border-color: transparent;">
                </p>
                <br>
            </div>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.theme.bannerURL") %></label>
                <p class="control has-icons-left">
                    <input id="form_banner" class="input is-rounded" type="text" name="banner" value="<%= bot.theme && bot.theme.banner %>" placeholder="https://discord.bot/files/banner.png">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-image"></i>
                    </span>
                </p>
            </div>
            <br>
            <br>
            <h3 class="is-size-3 has-text-default"><%= __("common.widgetbot") %></h3>
            <h4 class="is-size-6"><a class="has-text-info" rel="noopener" target="_blank" onclick="inviteWB(window, 350, 600);"><%= __("common.widgetbot.invite") %></a></h4>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("common.widgetbot.form.guildID") %> <span class="has-text-orange">* (<%= __("common.widgetbot.form.require") %>)</span></label>
                <p class="control has-icons-left">
                    <input id="form_widgetServer" class="input is-rounded" type="text" name="widgetServer" value="<%= bot.widgetbot.server %>" placeholder="568567800910839811">
                    <span class="icon is-small is-left">
                        <i class="fas fa-users"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("common.widgetbot.form.channelID") %> <span class="has-text-orange">* (<%= __("common.widgetbot.form.require") %>)</span></label>
                <p class="control has-icons-left">
                    <input id="form_widgetChannel" class="input is-rounded" type="text" name="widgetChannel" value="<%= bot.widgetbot.channel %>" placeholder="625554238596186112">
                    <span class="icon is-small is-left">
                        <i class="fas fa-comments-alt"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("common.widgetbot.form.moreOptions") %></label>
                <p style="cursor: pointer; padding-bottom: 10px;" onclick="window.open('https://docs.widgetbot.io/embed/crate/options/');" target="_blank" rel="noopener" class="is-size-7 has-text-default">
                    <%= __("common.widgetbot.form.docs") %>
                </p>
                <p class="control has-icons-left">
                    <input id="form_widgetOptions" class="input is-rounded" type="text" name="widgetOptions" value="<%= bot.widgetbot.options %>" placeholder="">
                    <span class="icon is-small is-left">
                        <i class="fas fa-cogs"></i>
                    </span>
                </p>
            </div>
            <br>
            <br>
            <h3 class="is-size-3 has-text-default"><%= __("page.form.category.descriptions") %></h3>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.shortDesc") %> <span class="has-text-danger">*</span></label>
                <p class="control has-icons-left">
                    <input id="form_shortDescription" class="input is-rounded" type="text" name="shortDescription" value="<%= bot.shortDesc %>" placeholder="<%= __("page.bots.shortDesc.placeholder") %>" required maxlength="200">
                    <span class="icon is-small is-left">
                        <i aria-hidden="true" class="fas fa-comment-dots"></i>
                    </span>
                </p>
            </div>
            <br>
            <div class="field">
                <label class="label has-text-default"><%= __("page.bots.longDesc") %> (<%= bot.status.verified ? __("common.form.jsHtmlMarkdown") : __("common.form.htmlMarkdown") %>) <span class="has-text-danger">*</span></label>
                <p style="padding-bottom: 10px;" class="is-size-7 has-text-default">
                    <%= __("page.bots.longDesc.charMin", "150") %>
                </p>
                <div onkeyup="monacoToField();" id="longDescEditor" class="editorBackdrop" style="width:99%;height:500px;"></div>
                <textarea hidden name="longDescription" id="longDesc" required><%- longDesc %></textarea>
            </div>
            <% if (resubmit) { %>
                <br>
                <div class="field">
                    <label class="label has-text-default"><%= __("page.bots.modNotes") %></label>
                    <p style="padding-bottom: 10px;" class="is-size-7 has-text-default">
                        <%= __("page.bots.modNotes.placeholder") %>
                    </p>
                    <div onkeyup="monacoToField();" id="modNotesEditor" class="editorBackdrop" style="width:99%;height:500px;"></div>
                    <textarea hidden name="modNotes" id="modNotes"></textarea>
                </div>
            <% } %>
            <% if (resubmit) { %>
                <div style="padding-bottom: 10px;">
                    <span style="font-size: 12px;" class="has-text-default">
                            <%- __("common.form.joinServer.full", {
                                a: "",
                                ea: ""
                            }) %>
                    </span>
                </div>
            <% } %>
            <div class="field is-grouped">
                <div class="buttons">
                    <a onclick="doSubmit();" id="submitButton" class="button is-success">
                        <span class="icon">
                            <i aria-hidden="true" class="fas fa-check-circle"></i>
                        </span>
                        <span><%= __("common.submit") %></span>
                    </a>
                    <a href="<%= resubmit ? `${linkPrefix}/bots/${bot._id}` : `${linkPrefix}/users/@me` %>" id="cancelButton" class="button is-danger">
                        <span class="icon">
                            <i aria-hidden="true" class="fas fa-times-circle"></i>
                        </span>
                        <span><%= __("common.cancel") %></span>
                    </a>
                </div>
            </div>
        </form>    
    </div>
</div>
<script>
    const bot = document.querySelector('#bot')
    const slashcommands = document.querySelector('#slashcommands')
    const prefixBlock = document.querySelector('#prefixBlock')
    const clientIDBlock = document.querySelector('#clientIDBlock')
    const id = document.querySelector('#form_id')
    const idText = document.querySelector('#idText')

    const onScopeChange = () => {
        clientIDDisplayCheck()
        if (!bot.checked && slashcommands.checked) {
            prefixBlock.style.display = 'none'
        } else {
            prefixBlock.style.display = 'inherit'
        }
    }

    const clientIDDisplayCheck = () => {
        if (bot.checked && id.value > 0 && BigInt(id.value) < 234395307759108106n) {
            clientIDBlock.style.display = 'inherit'
            idText.innerText = '<%= __("page.bots.generalInfo.id") %>'
        } else {
            clientIDBlock.style.display = 'none'
            idText.innerText = '<%= __("page.bots.generalInfo.clientID") %>'
        }
    }

    clientIDDisplayCheck()

    bot.addEventListener('change', onScopeChange)
    slashcommands.addEventListener('change', onScopeChange)
    
    const useCustomColor = document.querySelector('#form_customColourSwitch')
    const customColor = document.querySelector('#form_customColour')
    useCustomColor.addEventListener('change', () => {
        if (useCustomColor.checked) {
            customColor.style.display = 'inherit'
        } else customColor.style.display = 'none'
    })
    const warn = event => {
        event.preventDefault()
        event.returnValue=''
    }
    addEventListener('beforeunload', warn)
    MonacoEnvironment = {getWorkerUrl: () => '/js/monaco.js'}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs/loader.min.js" integrity="sha512-gWqaPfGsZiCkYB6e5mNN4SMRpEvLGItLBqgOAoyLSKtDxWS2O1YPcOeGTy8d8l00gqc8rVue9ae/ncZqhmfj4g==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs/editor/editor.main.nls.min.js" integrity="sha512-4XY3/LL6Plkq2tXMnatY+se07ZhwFMkZehD5Z68HrKoSL3BTyLDjwFomhUWixKu8VUw6jWe/8RXT1WtH95lLFg==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min/vs/editor/editor.main.min.js" integrity="sha512-CK3czr9gLG2z/ygdSM+gNenkN9AShfpW4gMjVyY06VgFHLoc4OCoO92Z8UkcBwVX0ufoYbJw3IVs1mHfXQeI3g==" crossorigin="anonymous"></script>
<script>function inviteWB(win,w,h){const y=win.top.outerHeight/2+win.top.screenY-(h/2);const x=win.top.outerWidth/2+win.top.screenX-(w/2);return win.open("https://add.widgetbot.io/","Invite WidgetBot",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${ w }, height=${ h }, top=${ y }, left=${ x }`)}
function htmlDecode(input){
    var e = document.createElement('textarea');
    e.innerHTML = input;
    return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
}
var longDescEditor=monaco.editor.create(document.getElementById("longDescEditor"),{theme:"<%= monacoTheme %>",value:htmlDecode(document.getElementById("longDesc").value),language:"markdown"});
<% if (resubmit) { %>var modNotesEditor=monaco.editor.create(document.getElementById("modNotesEditor"), {theme:"<%= monacoTheme %>"});<% } %>
function monacoToField(){var o=window.longDescEditor.getValue();$("#longDesc").val(o);<% if (resubmit) { %>var y=window.modNotesEditor.getValue();$("#modNotes").val(y);<% } %>}monaco.editor.setTheme("<%= monacoTheme %>");
function inviteWB(win,w,h){const y=win.top.outerHeight/2+win.top.screenY-(h/2);const x=win.top.outerWidth/2+win.top.screenX-(w/2);return win.open("https://add.widgetbot.io/","Invite WidgetBot",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${ w }, height=${ h }, top=${ y }, left=${ x }`)}
function doSubmit() {
    monacoToField();
    document.getElementById("errors").style.display = "none";
    document.getElementById("submitButton").classList.add("is-loading");
    document.getElementById("cancelButton").setAttribute("disabled", true);
    document.getElementById("cancelButton").removeAttribute("href");

    async function fetchPOST(url = '', data = {}) {
            const response = await fetch(url, {
                method: "POST",
                mode: "cors", 
                cache: "no-cache", 
                credentials: "same-origin",
                headers: {
                    "Content-Type": "application/json"
                },
                redirect: "follow",
                referrerPolicy: "no-referrer",
                body: JSON.stringify(data)
            });

            return response.json();
        }
        
        let modNotes = "";
        <% if (resubmit) { %>
            modNotes = document.getElementById("modNotes").value
        <% } %> 

        fetchPOST("<%= postURL %>", {
            bot: document.getElementById("bot").checked,
            slashCommands: document.getElementById("slashcommands").checked,

            clientID: document.getElementById("form_clientID").value,
            prefix: document.getElementById("form_prefix").value,
            library: document.getElementById("form_library").value,
            editors: document.getElementById("form_editors").value,

            fun: document.getElementById("fun").checked,
            social: document.getElementById("social").checked,
            economy: document.getElementById("economy").checked,
            utility: document.getElementById("utility").checked,
            moderation: document.getElementById("moderation").checked,
            multipurpose: document.getElementById("multipurpose").checked,
            music: document.getElementById("music").checked,
            
            shortDescription: document.getElementById("form_shortDescription").value,
            longDescription: document.getElementById("longDesc").value,

            modNotes: modNotes,

            supportServer: document.getElementById("form_supportServer").value,
            website: document.getElementById("form_website").value,
            donationUrl: document.getElementById("form_donationUrl").value,
            repo: document.getElementById("form_repo").value,
            invite: document.getElementById("form_invite").value,

            twitter: document.getElementById("form_twitter").value,
            privacyPolicy: document.getElementById("form_privacyPolicy").value,
            
            useCustomColour: document.getElementById("form_customColourSwitch").checked,
            colour: document.getElementById("form_colour").value,
            banner: document.getElementById("form_banner").value,

            widgetChannel: document.getElementById("form_widgetChannel").value,
            widgetOptions: document.getElementById("form_widgetOptions").value,
            widgetServer: document.getElementById("form_widgetServer").value
        })
        .then(data => {
            if (!data || data.error === true) {
                document.getElementById("errors").style.display = "block";
                document.getElementById("errorList").innerHTML = data.errors.map(err => `<li>${HtmlSanitizer.SanitizeHtml(err)}</li>`).join('');
                scroll(0, 0);
                document.getElementById("submitButton").classList.remove("is-loading");
                document.getElementById("cancelButton").removeAttribute("disabled");
                document.getElementById("cancelButton").setAttribute("href", "<%= linkPrefix %>/bots/<%= bot._id %>");
            } else {
                removeEventListener("beforeunload", warn);
                window.location = "/bots/<%= bot._id %>";
            }
        });
}
</script>
<%- include("../../partials/footer.ejs") %>
