You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

community.tsx 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import type { SlashCommandHandler } from './types'
  2. import React from 'react'
  3. import { RiDiscordLine } from '@remixicon/react'
  4. import i18n from '@/i18n-config/i18next-config'
  5. import { registerCommands, unregisterCommands } from './command-bus'
  6. // Community command dependency types
  7. type CommunityDeps = Record<string, never>
  8. /**
  9. * Community command - Opens Discord community
  10. */
  11. export const communityCommand: SlashCommandHandler<CommunityDeps> = {
  12. name: 'community',
  13. description: 'Open community Discord',
  14. mode: 'direct',
  15. // Direct execution function
  16. execute: () => {
  17. const url = 'https://discord.gg/5AEfbxcd9k'
  18. window.open(url, '_blank', 'noopener,noreferrer')
  19. },
  20. async search(args: string, locale: string = 'en') {
  21. return [{
  22. id: 'community',
  23. title: i18n.t('common.userProfile.community', { lng: locale }),
  24. description: i18n.t('app.gotoAnything.actions.communityDesc', { lng: locale }) || 'Open Discord community',
  25. type: 'command' as const,
  26. icon: (
  27. <div className='flex h-6 w-6 items-center justify-center rounded-md border-[0.5px] border-divider-regular bg-components-panel-bg'>
  28. <RiDiscordLine className='h-4 w-4 text-text-tertiary' />
  29. </div>
  30. ),
  31. data: { command: 'navigation.community', args: { url: 'https://discord.gg/5AEfbxcd9k' } },
  32. }]
  33. },
  34. register(_deps: CommunityDeps) {
  35. registerCommands({
  36. 'navigation.community': async (args) => {
  37. const url = args?.url || 'https://discord.gg/5AEfbxcd9k'
  38. window.open(url, '_blank', 'noopener,noreferrer')
  39. },
  40. })
  41. },
  42. unregister() {
  43. unregisterCommands(['navigation.community'])
  44. },
  45. }