import { Guild } from "discord.js"
import { Types } from "mongoose"
import dbGuild from "@/schemas/guild"
import { logConsole } from "@/utils/console"

export default async (guild: Guild) => {
	logConsole('mongoose', 'guild_init', { name: guild.name, id: guild.id })

	const guildProfile = new dbGuild({
		_id: new Types.ObjectId(),
		guildId: guild.id,
		guildName: guild.name,
		guildIcon: guild.iconURL() ?? "None",
		guildLocale: 'fr',
		guildPlayer: {
			disco: { enabled: false }
		},
		guildAmp: { enabled: false },
		guildFbx: { enabled: false,
			lcd: { enabled: false }
		},
		guildTwitch: { enabled: false }
	})
	
	await guildProfile.save().catch(console.error)
	return guildProfile
}
