MCPcopy
hub / github.com/codebymitch/TitanBot / execute

Function execute

src/commands/Community/modules/app_dashboard.js:141–195  ·  view source on GitHub ↗
(interaction, config, client, selectedAppName = null)

Source from the content-addressed store, hash-verified

139export default {
140 prefixOnly: false,
141 async execute(interaction, config, client, selectedAppName = null) {
142 try {
143 const guildId = interaction.guild.id;
144
145 await InteractionHelper.safeDefer(interaction, { flags: ['Ephemeral'] });
146
147 const [settings, roles] = await Promise.all([
148 getApplicationSettings(client, guildId),
149 getApplicationRoles(client, guildId),
150 ]);
151
152 const guildConfig = await getGuildConfig(client, guildId);
153 const applicationsChannel = resolveLogChannel(guildConfig, 'applications') || settings.logChannelId;
154
155 const isCompletelyUnconfigured =
156 !applicationsChannel &&
157 !settings.enabled &&
158 (settings.managerRoles?.length ?? 0) === 0 &&
159 roles.length === 0;
160
161 if (isCompletelyUnconfigured) {
162 throw new TitanBotError(
163 'Applications system not set up',
164 ErrorTypes.CONFIGURATION,
165 'The applications system has not been configured yet. Please run `/app-admin setup` to create your first application.',
166 );
167 }
168
169 if (roles.length === 0) {
170 await showGlobalDashboard(interaction, settings, roles, guildId, client);
171 return;
172 }
173
174 if (selectedAppName) {
175 const selectedRole = roles.find(r => r.name.toLowerCase() === selectedAppName.toLowerCase());
176 if (selectedRole) {
177 await showApplicationDashboard(interaction, selectedRole, settings, roles, guildId, client);
178 return;
179 }
180
181 }
182
183 const defaultRole = roles[0];
184 await showApplicationDashboard(interaction, defaultRole, settings, roles, guildId, client);
185
186 } catch (error) {
187 if (error instanceof TitanBotError) throw error;
188 logger.error('Unexpected error in app_dashboard:', error);
189 throw new TitanBotError(
190 `Applications dashboard failed: ${error.message}`,
191 ErrorTypes.UNKNOWN,
192 'Failed to open the applications dashboard.',
193 );
194 }
195 },
196};
197
198async function showApplicationSelector(interaction, roles, settings, guildId, client) {

Callers

nothing calls this directly

Calls 7

getApplicationSettingsFunction · 0.90
getApplicationRolesFunction · 0.90
getGuildConfigFunction · 0.90
resolveLogChannelFunction · 0.90
showGlobalDashboardFunction · 0.85
showApplicationDashboardFunction · 0.85
safeDeferMethod · 0.80

Tested by

no test coverage detected