2021-11-07 21:57:09 +00:00
|
|
|
import Q from '../q-module';
|
|
|
|
import UI from '../ui';
|
2021-11-22 03:01:40 +00:00
|
|
|
import createGuildTitleContextMenu from './context-menu-guild-title';
|
2021-11-07 21:57:09 +00:00
|
|
|
import ElementsUtil from './require/elements-util';
|
2021-10-30 17:26:41 +00:00
|
|
|
|
2021-11-22 03:01:40 +00:00
|
|
|
export default function bindAddGuildTitleEvents(document: Document, q: Q, ui: UI) {
|
|
|
|
q.$('#guild-name-container').addEventListener('click', () => {
|
2021-11-07 16:50:30 +00:00
|
|
|
if (ui.activeConnection === null) return;
|
2021-11-21 18:29:42 +00:00
|
|
|
if (ui.activeGuild === null) return;
|
2021-11-22 02:47:29 +00:00
|
|
|
if (!ui.activeGuild.isSocketVerified()) return;
|
2021-10-30 17:26:41 +00:00
|
|
|
if (
|
|
|
|
!ui.activeConnection.privileges.includes('modify_profile') &&
|
|
|
|
!ui.activeConnection.privileges.includes('modify_members')
|
|
|
|
) return;
|
|
|
|
|
2021-11-22 03:01:40 +00:00
|
|
|
let contextMenu = createGuildTitleContextMenu(document, q, ui, ui.activeGuild);
|
2021-10-30 17:26:41 +00:00
|
|
|
document.body.appendChild(contextMenu);
|
2021-11-22 03:01:40 +00:00
|
|
|
ElementsUtil.alignContextElement(contextMenu, q.$('#guild-name-container'), { top: 'bottom', centerX: 'centerX' });
|
2021-10-30 17:26:41 +00:00
|
|
|
});
|
|
|
|
}
|