import { PermissionResolvable , Permissions } from "discord.js" ; import { Command , CommandContext , SlashCommandContext , } from "../../base/Command" ; import { sendReply } from "../../utils/functions" ; export default class DoodleCrew implements Command { name = "doodlecrew" ; category = "fun" ; description = "Starts a new Doodle Crew game for the current voice channel." ; usage = "doodlecrew" ; enabled = true ; slashCommandEnabled = true ; guildOnly = true ; botPermissions : PermissionResolvable [ ] = [ Permissions . FLAGS . CREATE_INSTANT_INVITE , Permissions . FLAGS . CONNECT , Permissions . FLAGS . SPEAK , ] ; memberPermissions = [ ] ; ownerOnly = false ; premiumOnly = false ; cooldown = 10000 ; slashDescription = "Start a new Doodle Crew game for the current voice channel" ; commandOptions = [ ] ; async execute ( ctx , args ) { const voice = ctx . member . voice . channel ; if ( ! voice ) { sendReply ( ctx . client , "You must be connected to a voice channel!" , ctx . msg ) ; return ; } const perms = voice . permissionsFor ( ctx . client . user ) ; if ( ! perms . has ( Permissions . FLAGS . VIEW_CHANNEL ) ) { sendReply ( ctx . client , "I need permission to view your voice channel!" , ctx . msg ) ; return ; } if ( ! perms . has ( Permissions . FLAGS . CONNECT ) ) { sendReply ( ctx . client , "I need permission to join your voice channel!" , ctx . msg ) ; return ; } ctx . client . discordTogether . createTogetherCode ( voice . id , "doodlecrew" ) . then ( async ( invite ) => { sendReply ( ctx . client , invite . code , ctx . msg ) ; return ; } ) ; } async slashCommandExecute ( ctx ) { const voice = ctx . member . voice . channel ; if ( ! voice ) { ctx . commandInteraction . reply ( { content : "You must be connected to a voice channel!" , ephemeral : true , } ) ; return ; } const perms = voice . permissionsFor ( ctx . client . user ) ; if ( ! perms . has ( Permissions . FLAGS . VIEW_CHANNEL ) ) { ctx . commandInteraction . reply ( { content : "I need permission to view your voice channel!" , ephemeral : true , } ) ; return ; } if ( ! perms . has ( Permissions . FLAGS . CONNECT ) ) { ctx . commandInteraction . reply ( { content : "I need permission to join your voice channel!" , ephemeral : true , } ) ; return ; } ctx . client . discordTogether . createTogetherCode ( voice . id , "doodlecrew" ) . then ( async ( invite ) => { ctx . commandInteraction . reply ( invite . code ) ; return ; } ) ; } }