|
3 | 3 | import client from '.'; |
4 | 4 | import { ActionRowBuilder, ButtonBuilder, ButtonStyle, type CommandInteraction, ChannelType, type APIApplicationCommandOption, GuildMember, AttachmentBuilder, ComponentType } from 'discord.js'; |
5 | 5 | import { heapStats } from 'bun:jsc'; |
6 | | -import { getGuildLeaderboard, makeGETRequest, getRoles, removeRole, addRole, enableUpdates, disableUpdates, getCooldown, setCooldown, getUpdatesChannel, setUpdatesChannel, setXP, setLevel } from './utils/requestAPI'; |
| 6 | +import { getGuildLeaderboard, makeGETRequest, getRoles, removeRole, addRole, enableUpdates, disableUpdates, getCooldown, setCooldown, getUpdatesChannel, setUpdatesChannel, setXP, setLevel, syncFromPolaris } from './utils/requestAPI'; |
7 | 7 | import convertToLevels from './utils/convertToLevels'; |
8 | 8 | import quickEmbed from './utils/quickEmbed'; |
9 | 9 | import { Font, RankCardBuilder } from 'canvacord'; |
@@ -721,6 +721,55 @@ const commands: Record<string, Command> = { |
721 | 721 | return; |
722 | 722 | } |
723 | 723 | } |
| 724 | + }, |
| 725 | + sync: { |
| 726 | + data: { |
| 727 | + options: [{ |
| 728 | + name: 'bot', |
| 729 | + description: 'Select the bot to sync XP data from', |
| 730 | + type: 3, |
| 731 | + required: true, |
| 732 | + choices: [ |
| 733 | + { |
| 734 | + name: 'Polaris', |
| 735 | + value: 'polaris', |
| 736 | + }, |
| 737 | + ] |
| 738 | + }], |
| 739 | + name: 'sync', |
| 740 | + description: 'Sync XP data from another bot!', |
| 741 | + integration_types: [0], |
| 742 | + contexts: [0, 2], |
| 743 | + }, |
| 744 | + execute: async (interaction) => { |
| 745 | + if (!interaction.memberPermissions?.has('ManageGuild')) { |
| 746 | + const errorEmbed = quickEmbed({ |
| 747 | + color: 'Red', |
| 748 | + title: 'Error!', |
| 749 | + description: 'Missing permissions: `Manage Server`' |
| 750 | + }, interaction); |
| 751 | + await interaction.reply({ |
| 752 | + ephemeral: true, |
| 753 | + embeds: [errorEmbed] |
| 754 | + }) |
| 755 | + .catch(console.error); |
| 756 | + return; |
| 757 | + } |
| 758 | + |
| 759 | + const bot = interaction.options.get('bot')?.value; |
| 760 | + |
| 761 | + let apiSuccess; |
| 762 | + switch (bot) { |
| 763 | + case 'polaris': |
| 764 | + apiSuccess = await syncFromPolaris(interaction.guildId as string); |
| 765 | + if (!apiSuccess) { |
| 766 | + await interaction.reply({ ephemeral: true, content: 'Error syncing data! This might mean that Polaris is not set up for this server, or the leaderboard for this server is not public.' }); |
| 767 | + return; |
| 768 | + } |
| 769 | + await interaction.reply({ ephemeral: true, content: 'Data synced!' }); |
| 770 | + return; |
| 771 | + } |
| 772 | + } |
724 | 773 | } |
725 | 774 | }; |
726 | 775 |
|
|
0 commit comments