303 lines
10 KiB
Cheetah
303 lines
10 KiB
Cheetah
{{define "content"}}
|
|
<div class="content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Bot Token</h4>
|
|
</div>
|
|
<div class="card-body" id="card">
|
|
<form onsubmit="updateSettings(); return false;">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="form-group">
|
|
<label>Bot Token</label>
|
|
<input name="token" type="text" class="form-control"
|
|
placeholder="xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxx" id="token">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<p class="white">Note: You will not be able to view the token after submitting it</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<button class="btn btn-primary btn-fill" type="submit">
|
|
<i class="fas fa-paper-plane"></i>
|
|
Submit
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<button class="btn btn-primary btn-fill" id="invite" type="button">
|
|
<i class="fas fa-plus"></i>
|
|
Generate Invite Link
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Slash Commands</h4>
|
|
</div>
|
|
<div class="card-body" id="card">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<label for="interaction-url">Interactions Endpoint URL</label>
|
|
<input class="form-control" id="interaction-url" placeholder="Submit your bot token first!" disabled>
|
|
</div>
|
|
</div>
|
|
<div class="row" style="padding-top: 20px">
|
|
<div class="col-md-12">
|
|
<form onsubmit="updatePublicKey(); return false;">
|
|
<label for="public-key">Public Key</label>
|
|
<div class="row">
|
|
<div class="col-md-9">
|
|
<div class="form-group">
|
|
<input name="public-key" type="text" class="form-control" placeholder="Public Key" id="public-key">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<button class="btn btn-primary btn-fill" type="submit" style="width: 100%;">
|
|
<i class="fas fa-paper-plane"></i>
|
|
Submit
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<button class="btn btn-primary btn-fill" style="width: 100%" onclick="createSlashCommands()">
|
|
<i class="fas fa-paper-plane"></i>
|
|
Create Slash Commands
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Custom Status</h4>
|
|
</div>
|
|
<div class="card-body" id="card">
|
|
<form onsubmit="updateStatus(); return false;">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="form-group">
|
|
<label>Status</label>
|
|
<input name="status" type="text" class="form-control" placeholder="DM for help | t!help"
|
|
id="status">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<button class="btn btn-primary btn-fill" type="submit">
|
|
<i class="fas fa-paper-plane"></i>
|
|
Submit
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Error Logs</h4>
|
|
</div>
|
|
<div class="card-body" id="card">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col" span="2">Error</th>
|
|
<th scope="col">Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="error_body">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div aria-live="polite" aria-atomic="true" style="position: relative">
|
|
<div style="position: absolute; right: 10px" id="toast-container">
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// invite button
|
|
document.getElementById('invite').addEventListener('click', async () => {
|
|
// get bot ID
|
|
const res = await axios.get('/user/whitelabel');
|
|
if (res.status !== 200 || !res.data.success) {
|
|
notifyError(res.data.error);
|
|
return;
|
|
}
|
|
|
|
const inviteUrl = 'https://discord.com/oauth2/authorize?client_id=' + res.data.id + '&scope=bot+applications.commands&permissions=805825648';
|
|
|
|
window.open(inviteUrl, '_blank');
|
|
}, false);
|
|
</script>
|
|
|
|
<script>
|
|
async function updateSettings() {
|
|
const data = {
|
|
token: document.getElementById('token').value
|
|
};
|
|
|
|
const res = await axios.post('/user/whitelabel', data);
|
|
if (res.status !== 200 || !res.data.success) {
|
|
notifyError(res.data.error);
|
|
return;
|
|
}
|
|
|
|
await loadInteractionUrl();
|
|
notifySuccess(`Started tickets whitelabel on ${res.data.bot.username}#${res.data.bot.discriminator}`);
|
|
}
|
|
|
|
async function updatePublicKey() {
|
|
const data = {
|
|
public_key: document.getElementById('public-key').value,
|
|
};
|
|
|
|
const res = await axios.post('/user/whitelabel/public-key', data);
|
|
if (res.status !== 200 || !res.data.success) {
|
|
notifyError(res.data.error);
|
|
return;
|
|
}
|
|
|
|
notifySuccess('Updated slash command settings successfully')
|
|
}
|
|
|
|
async function updateStatus() {
|
|
const data = {
|
|
status: document.getElementById('status').value
|
|
};
|
|
|
|
const res = await axios.post('/user/whitelabel/status', data);
|
|
if (res.status !== 200 || !res.data.success) {
|
|
notifyError(res.data.error);
|
|
return;
|
|
}
|
|
|
|
notifySuccess('Updated status successfully')
|
|
}
|
|
|
|
async function loadStatus() {
|
|
const res = await axios.get('/user/whitelabel');
|
|
if (res.status !== 200 || !res.data.success) {
|
|
if (res.status !== 404) {
|
|
notifyError(res.data.error);
|
|
}
|
|
return;
|
|
}
|
|
|
|
// set status
|
|
document.getElementById('status').value = res.data.status;
|
|
}
|
|
|
|
async function loadErrors() {
|
|
const res = await axios.get('/user/whitelabel/errors');
|
|
if (res.status !== 200 || !res.data.success) {
|
|
notifyError(res.data.error);
|
|
return;
|
|
}
|
|
|
|
// append errors
|
|
if (res.data.errors !== null) {
|
|
for (error of res.data.errors) {
|
|
const message = error.Message;
|
|
const time = new Date(error.Time);
|
|
|
|
const tr = document.createElement('tr');
|
|
appendTd(tr, message);
|
|
appendTd(tr, time.toDateString());
|
|
document.getElementById('error_body').appendChild(tr);
|
|
}
|
|
}
|
|
}
|
|
|
|
async function loadPublicKey() {
|
|
const res = await axios.get('/user/whitelabel/public-key');
|
|
if (res.status === 404) {
|
|
return;
|
|
}
|
|
|
|
if ((res.status !== 200 || !res.data.success)) {
|
|
notifyError(res.data.error);
|
|
return;
|
|
}
|
|
|
|
const key = res.data.key;
|
|
document.getElementById('public-key').value = key;
|
|
}
|
|
|
|
async function loadInteractionUrl() {
|
|
const res = await axios.get('/user/whitelabel');
|
|
if (res.status === 404) {
|
|
return;
|
|
}
|
|
|
|
if (res.status !== 200 || !res.data.success) {
|
|
notifyError(res.data.error);
|
|
return;
|
|
}
|
|
|
|
document.getElementById('interaction-url').value = 'https://gateway.ticketsbot.net/handle/' + res.data.id;
|
|
}
|
|
|
|
async function createSlashCommands() {
|
|
const opts = {
|
|
timeout: 20 * 1000
|
|
};
|
|
|
|
const res = await axios.post('/user/whitelabel/create-interactions', {}, opts);
|
|
if (res.status !== 200 || !res.data.success) {
|
|
notifyError(res.data.error);
|
|
return;
|
|
}
|
|
|
|
notifySuccess('Slash commands have been created. Please note, Discord may take up to an hour to show them in your client');
|
|
}
|
|
|
|
withLoadingScreen(async () => {
|
|
await loadStatus();
|
|
await loadErrors();
|
|
await loadInteractionUrl();
|
|
await loadPublicKey();
|
|
});
|
|
</script>
|
|
{{end}} |