getinvite.js (1369B)
1 module.exports = { 2 name: "getinvite", 3 category: "Owner", 4 usage: "(Guild)", 5 description: "Generates an invitation to the server", 6 Owner: true, 7 options: [ 8 { 9 type: 3, 10 name: "guild", 11 description: "The guild you want to get invite (Server ID/Name)", 12 required: true, 13 }, 14 ], 15 run: async (client, interaction, args) => { 16 let guild = null; 17 const fetched = 18 client.guilds.cache.find(g => g.name === args.join(" ")) || 19 client.guilds.cache.get(args[0]); 20 guild = fetched; 21 if (guild) { 22 const tChannel = guild.channels.cache.find( 23 ch => 24 ch.type == "GUILD_TEXT" && 25 ch.permissionsFor(ch.guild.me).has("CREATE_INSTANT_INVITE") 26 ); 27 if (!tChannel) { 28 interaction.followUp({ 29 content: `\`${args.join( 30 " " 31 )}\` - Bot can't get invite since it doesn't get enough permission`, 32 }); 33 } 34 const invite = await tChannel 35 .createInvite({ temporary: false, maxAge: 0 }) 36 .catch(e => { 37 console.log(e); 38 interaction.followUp({ content: e.stack }); 39 }); 40 interaction.followUp({ content: invite.url }); 41 } else { 42 interaction.followUp({ 43 content: `\`${args.join(" ")}\` - Bot isn't in that server`, 44 }); 45 } 46 }, 47 };