diff --git a/commands/owner/getinvite.js b/commands/owner/getinvite.js new file mode 100644 index 0000000..2e716f0 --- /dev/null +++ b/commands/owner/getinvite.js @@ -0,0 +1,46 @@ +const ownerid = "519666024220721152"; + +module.exports = { + name: "getinvite", + aliases: ['getinv', 'gi'], + category: "premium", + description: "Generates an invitation to server in question.", + usage: "[ID | name]", + + run: async(bot, message, args) => { + if (message.author.id === ownerid) { + let guild = null; + + if (!args[0]) return message.channel.send("Enter Guild Name or Guild ID of where you want Invite Link.") + + if(args[0]){ + let fetched = bot.guilds.cache.find(g => g.name === args.join(" ")); + let found = bot.guilds.cache.get(args[0]); + if(!found) { + if(fetched) { + guild = fetched; + } + } else { + guild = found + } + } else { + return message.channel.send("That's the Invalid Guild Name"); + } + if(guild){ + let tChannel = guild.channels.cache.find(ch => ch.type == "text" && ch.permissionsFor(ch.guild.me).has("CREATE_INSTANT_INVITE")); + if(!tChannel) { + return message.channel.send("Sorry, I doesn't have CREATE_INSTANT_INVITE Permission There!"); + } + let invite = await tChannel.createInvite({ temporary: false, maxAge: 0 }).catch(err => { + return message.channel.send(`${err} has occured!`); + }); + message.channel.send(invite.url); + } else { + return message.channel.send(`\`${args.join(' ')}\` - I'm not in that Server.`); + } + } else { + return; + } + } + +}