Skip to content

Commit

Permalink
feat: v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SudhanPlayz committed Jul 5, 2021
1 parent 678278e commit b4e7ee1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 54 deletions.
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ require("discordjs-activity")(client)//Importing this package and initiating it

## ✍ | Examples
```js
require("discordjs-activity")//Import first
const { Client } = require("discord.js")
const client = new Client()
require("discordjs-activity")(client)

client.on("message", async (message) => {
if(message.author.bot)return
Expand Down Expand Up @@ -66,23 +66,8 @@ Client ID: `814288819477020702`
<br>
<br>

# Core Contributers
## SudhanPlayz
## 👥 | Support Server
<p align="center" style="text-align: center;">
<a href="https://youtube.com/CodingWithSudhan?sub_confirmation=1"><img src="https://raw.githubusercontent.com/MikeCodesDotNET/ColoredBadges/master/png/streaming/youtube%402x.png"></a>
<a href="https://discord.gg/a9SHDpD"><img src="https://discord.com/api/guilds/749254969537986640/widget.png?style=banner2"></a>
</p>

## Reyansh Khobragade

<p align="center" style="text-align: center;">
<a href="https://www.youtube.com/channel/UCeJOySzx_kPMlgIyW398tRA?sub_confirmation=1"><img src="https://raw.githubusercontent.com/MikeCodesDotNET/ColoredBadges/master/png/streaming/youtube%402x.png"></a>
<a href="https://discord.gg/nc9D2rjhAR"><img src="https://discord.com/api/guilds/769046129073324032/widget.png?style=banner2"></a>
</p>

<!-- ## 👥 | Support Server
<p align="center" style="text-align: center;">
<a href="https://youtube.com/CodingWithSudhan"><img src="https://raw.githubusercontent.com/MikeCodesDotNET/ColoredBadges/master/png/streaming/youtube%402x.png"></a>
<a href="https://discord.gg/a9SHDpD"><img src="https://discord.com/api/guilds/749254969537986640/widget.png?style=banner2"></a>
<a href="https://discord.gg/a9SHDpD"><img src="https://discord.com/api/guilds/769046129073324032/widget.png?style=banner2"></a>
</p> -->
</p>
8 changes: 4 additions & 4 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require("discordjs-activity")//Import first
const { Client } = require("discord.js")
const client = new Client()
require('discordjs-activity')

client.on("message", async (message) => {
if(message.author.bot)return
if(message.content === "youtube"){
let VoiceChannel = client.channels.cache.get("Voice Channel ID")//Voice Channel ID
let Invite = await VoiceChannel.activityInvite("755600276941176913")//Application ID
//For more application IDs you can check ReadMe
message.channel.send("https://discord.com/invite/"+Invite.code)
message.channel.send("https://discord.com/invite/"+Invite.code)// send's invite link in the channel
}
})

client.login("Super Secret Token")
client.login("Super secret token")
57 changes: 28 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
const { Structures, Invite, Client } = require('discord.js');
/**
* @param {Client} client
*/
module.exports = (client) => {
// if no client specified
if(!client || !client instanceof Client) throw new Error('INVALID_CLIENT: No Client/Invalid Client Provided.')
// extend voice channel to add activity invite function
Structures.extend('VoiceChannel', VoiceChannel => {

return class EpicVoiceChannel extends VoiceChannel {
//Single File package
const { Structures, Invite } = require('discord.js');
const fetch = require("node-fetch")

constructor(client, data) {
super(client, data);
}
Structures.extend('VoiceChannel', VoiceChannel => {
return class EpicVoiceChannel extends VoiceChannel {
constructor(client, data) {
super(client, data);
}

/**
* Creates Activity Invite in the voice channel
* @param {string} ApplicationID - Application ID
* @returns {Invite}
*/

activityInvite(ApplicationID){
return this.client.api.channels(this.id).invites.post({
data: {
/**
* Creates Activity Invite in the voice channel
* @param {string} ApplicationID - Application ID
* @returns {Invite}
*/
activityInvite(ApplicationID) {
return new Promise(res => {
let fetched = fetch(`https://discord.com/api/v8/channels/${this.id}/invites`, {
method: 'POST',
body: JSON.stringify({
max_age: 86400,
max_uses: 0,
target_application_id: ApplicationID,
target_type: 2,
temporary: false,
validate: null
},
}).then(invite => new Invite(this.client, invite))
}
}),
headers: {
"Authorization": `Bot ${this.client.token}`,
"Content-Type": "application/json"
}
}).then(response => response.json())
res(fetched)
})
}
});
}
// The End.
}
});
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discordjs-activity",
"version": "1.1.0",
"version": "1.2.0",
"description": "An simple package to create an Activity in Discord Voice Channel using Discord.js",
"main": "index.js",
"scripts": {
Expand All @@ -10,7 +10,12 @@
"type": "git",
"url": "git+https://github.com/SudhanPlayz/discordjs-activity.git"
},
"keywords": [],
"keywords": [
"discordjs",
"discord",
"discord-activity",
"discord.js-acitivity"
],
"author": "",
"license": "ISC",
"bugs": {
Expand Down

0 comments on commit b4e7ee1

Please sign in to comment.