Create getinvite.js

This commit is contained in:
Diwas Atreya
2021-04-25 12:59:24 +05:45
committed by GitHub
parent 22e1b40981
commit fcf909c790

View File

@@ -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;
}
}
}