Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blinet/discord-inviter
Easy way to know member inviter & get member invite & guild top invites with simple step.
https://github.com/blinet/discord-inviter
bot discord discord-bot discord-invite discord-inviter discord-js discord-welcome
Last synced: 10 days ago
JSON representation
Easy way to know member inviter & get member invite & guild top invites with simple step.
- Host: GitHub
- URL: https://github.com/blinet/discord-inviter
- Owner: blinet
- License: mit
- Created: 2022-02-03T11:05:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-19T18:34:07.000Z (about 2 years ago)
- Last Synced: 2024-10-31T18:18:04.071Z (15 days ago)
- Topics: bot, discord, discord-bot, discord-invite, discord-inviter, discord-js, discord-welcome
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Discord-inviter
## Installation
### Install **[discord-inviter](https://npmjs.com/package/discord-inviter)**
```sh
$ npm install discord-inviter
```### Install **[discord.js](https://npmjs.com/package/discord.js)**
```sh
$ npm install discord.js
```# Features
- Simple & easy to use 🎗️
- Support vanity urls 🔗
- Returns full object with invite data 📡## Getting Started
At first install the [discord-inviter](https://npmjs.com/discord-inviter) package
```js
const { Client, Intents } = require("discord.js"); // npm i discord.js
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_INVITES,
],
});var { inviteTracker } = require("discord-inviter"), // npm i discord-inviter
tracker = new inviteTracker(client);client.on("ready", () => console.log("Bot Ready"));
// "guildMemberAdd" event to get full invite data
tracker.on("guildMemberAdd", async (member, inviter, invite, error) => {
// return when get error
if(error) return console.error(error);
// get the channel
let channel = member.guild.channels.cache.get("939210311276306455"),
Msg = `Welcome ${member.user}, invited by <@!${inviter.id}>, code ${invite.code}, invite count ${invite.count}`;
// change welcome message when the member is bot
if (member.user.bot)
Msg = `Welcome ${member.user}, invited by <@!${inviter.id}>`;
// send welcome message
channel.send(Msg);
});// "error" event to get any error
tracker.on("error", (guild, err) => {
console.error(guild?.name, err);
});client.on("messageCreate", async (message) => {
// get member invites count
if (message.content == "invites") {
var invite = await inviteTracker.getMemberInvites(message.member);
message.channel.send(
`${message.author.tag} has ${invite.count} invite(s).`
);
// get server top invites
} else if (message.content == "top-invites") {
var top = await inviteTracker.getTopInvites(message.guild);
message.channel.send(
top
.map((i, n) => `\`#${n + 1}\`- **${i.user.tag}** has __${i.count}__`)
.join("\n")
);
// get info of any invite code
} else if (message.content == "invite-info") {
var invite = await inviteTracker.getInfo(client, "VwTxJaqjsJ");
if (!invite) return;
message.channel.send(
`Guild: ${invite.guild.name},\nInviter: ${
invite?.inviter
? `${invite.inviter.tag}`
: "Owner"
},\nLink: ${invite.url}`
);
}
});
```
## Thanks.