111 lines
4.4 KiB
Cheetah
111 lines
4.4 KiB
Cheetah
{{define "content"}}
|
|
<div class="content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Servers</h4>
|
|
</div>
|
|
<div class="card-body" id="card">
|
|
<div class="card-body table-responsive">
|
|
<p class="center-align white" style="padding-top: 50px; font-size: 16px; display: none" id="no-guilds">
|
|
You are not the admin of any guilds that the bot is in. Click below to invite the bot:
|
|
<br/>
|
|
<a href="https://invite.ticketsbot.net"><button class="btn btn-primary btn-fill"><i class="fas fa-plus"></i> Invite</button></a>
|
|
</p>
|
|
<div class="container-fluid">
|
|
<div class="row" id="guild-container">
|
|
<div class="col-md-4">
|
|
<div class="guild align-items-center" onclick="invite();">
|
|
<i class="fas fa-plus fa-2x guild-icon-fa"></i>
|
|
<div class="align-items-center">
|
|
<span class="guild-name">Invite to your server</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function getPermissionLevel(guildId) {
|
|
const res = await axios.get('/user/permissionlevel?guilds=' + guildId);
|
|
if (res.status !== 200 || !res.data.success) {
|
|
showToast('Error', res.data.error);
|
|
return;
|
|
}
|
|
|
|
return res.data.levels;
|
|
}
|
|
|
|
async function goto(guildId) {
|
|
const permissionLevels = await getPermissionLevel(guildId);
|
|
if (permissionLevels[guildId] === 2) {
|
|
window.location.href = `/manage/${guildId}/settings`;
|
|
} else {
|
|
window.location.href = `/manage/${guildId}/logs`;
|
|
}
|
|
}
|
|
|
|
function invite() {
|
|
window.location.href = 'https:\/\/invite.ticketsbot.net';
|
|
}
|
|
|
|
async function loadData() {
|
|
const res = await axios.get('/user/guilds');
|
|
|
|
if (res.data.length > 0) {
|
|
const container = document.getElementById('guild-container');
|
|
|
|
for (guild of res.data) {
|
|
const col = document.createElement('div');
|
|
col.classList.add('col-md-4');
|
|
|
|
const guildContainer = document.createElement('div');
|
|
guildContainer.classList.add('guild', 'align-items-center');
|
|
|
|
if (guild.icon === undefined || guild.icon === null || guild.icon === "") {
|
|
const icon = document.createElement('i');
|
|
icon.classList.add('fas', 'fa-question', 'guild-icon-fa');
|
|
guildContainer.appendChild(icon);
|
|
} else {
|
|
const icon = document.createElement('img');
|
|
icon.classList.add('guild-icon');
|
|
icon.src = `https:\/\/cdn.discordapp.com/icons/${guild.id}/${guild.icon}.webp?size=256`;
|
|
guildContainer.appendChild(icon);
|
|
}
|
|
|
|
const nameContainer = document.createElement('div');
|
|
nameContainer.classList.add('align-items-center');
|
|
|
|
const name = document.createElement('span');
|
|
name.classList.add('guild-name');
|
|
name.appendChild(document.createTextNode(guild.name));
|
|
nameContainer.appendChild(name);
|
|
|
|
guildContainer.appendChild(nameContainer);
|
|
|
|
const guildId = guild.id
|
|
guildContainer.onclick = async () => { await goto(guildId) };
|
|
|
|
col.appendChild(guildContainer);
|
|
container.appendChild(col);
|
|
}
|
|
} else {
|
|
document.getElementById('no-guilds').style.display = 'block';
|
|
}
|
|
}
|
|
|
|
withLoadingScreen(async () => {
|
|
await setDefaultHeader(); // on first load, this isnt set yet because its run async in auth.js
|
|
await loadData();
|
|
});
|
|
</script>
|
|
{{end}} |