Add interactions url

This commit is contained in:
rxdn 2020-12-24 23:21:40 +00:00
parent 61621906c0
commit 9fb2eacc67
2 changed files with 27 additions and 2 deletions

View File

@ -12,6 +12,8 @@ import (
func WhitelabelCreateInteractions(ctx *gin.Context) { func WhitelabelCreateInteractions(ctx *gin.Context) {
userId := ctx.Keys["userid"].(uint64) userId := ctx.Keys["userid"].(uint64)
//TODO: COOLDOWN
// Get bot // Get bot
bot, err := database.Client.Whitelabel.GetByUserId(userId) bot, err := database.Client.Whitelabel.GetByUserId(userId)
if err != nil { if err != nil {

View File

@ -54,8 +54,15 @@
<div class="card-body" id="card"> <div class="card-body" id="card">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <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"> <div class="col-md-12">
<form onsubmit="updatePublicKey(); return false;"> <form onsubmit="updatePublicKey(); return false;">
<label for="public-key">Public Key</label>
<div class="row"> <div class="row">
<div class="col-md-9"> <div class="col-md-9">
<div class="form-group"> <div class="form-group">
@ -64,7 +71,7 @@
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="form-group"> <div class="form-group">
<button class="btn btn-primary btn-fill" type="submit"> <button class="btn btn-primary btn-fill" type="submit" style="width: 100%;">
<i class="fas fa-paper-plane"></i> <i class="fas fa-paper-plane"></i>
Submit Submit
</button> </button>
@ -159,7 +166,7 @@
return; return;
} }
const inviteUrl = 'https://discord.com/oauth2/authorize?client_id=' + res.data.id + '&scope=bot&permissions=805825648'; const inviteUrl = 'https://discord.com/oauth2/authorize?client_id=' + res.data.id + '&scope=bot+applications.commands&permissions=805825648';
window.open(inviteUrl, '_blank'); window.open(inviteUrl, '_blank');
}, false); }, false);
@ -177,6 +184,7 @@
return; return;
} }
await loadInteractionUrl();
notifySuccess(`Started tickets whitelabel on ${res.data.bot.username}#${res.data.bot.discriminator}`); notifySuccess(`Started tickets whitelabel on ${res.data.bot.username}#${res.data.bot.discriminator}`);
} }
@ -257,6 +265,20 @@
document.getElementById('public-key').value = 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() { async function createSlashCommands() {
notify('Slash Commands', 'Creating slash commands, please note this may take up to 120 seconds to complete'); notify('Slash Commands', 'Creating slash commands, please note this may take up to 120 seconds to complete');
@ -276,6 +298,7 @@
withLoadingScreen(async () => { withLoadingScreen(async () => {
await loadStatus(); await loadStatus();
await loadErrors(); await loadErrors();
await loadInteractionUrl();
await loadPublicKey(); await loadPublicKey();
}); });
</script> </script>