<script setup lang="ts">
import { ref, provide, inject } from 'vue'
import { useRoute } from 'vue-router'
import type { Ref } from 'vue'
import type { APIGuild } from 'discord-api-types/v10'

// Récupérer le bot
defineProps({ guildId: String })
const route = useRoute()
const guilds = inject('guilds') as Ref<APIGuild[] | null>

const guild = ref({} as APIGuild | undefined)
guild.value = guilds.value?.find(guild => guild.id === route.params.guildId)
provide('guild', guild) // Fournit la guild aux composants enfants
</script>

<template>
    <div class="main">
        <div class="title">
            <h1>Infos de la guild {{ guild?.name }}</h1>
            <div v-if="guild">
                <p>ID : {{ guild.id }}.</p>
            </div>
            <p v-else>...</p>
        </div>
    </div>
</template>