mirror of
https://github.com/SrIzan10/Recluse-Bot.git
synced 2026-05-01 10:55:24 +00:00
Create getinvite.js
This commit is contained in:
46
commands/owner/getinvite.js
Normal file
46
commands/owner/getinvite.js
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user