From b4e7ee1fb508842bd1606c1c781b2ab1983cc3c4 Mon Sep 17 00:00:00 2001 From: Sudhan Date: Mon, 5 Jul 2021 10:09:13 +0000 Subject: [PATCH] feat: v1.2.0 --- README.md | 21 +++-------------- example.js | 8 +++---- index.js | 57 +++++++++++++++++++++++------------------------ package-lock.json | 2 +- package.json | 9 ++++++-- 5 files changed, 43 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index d29e492..89909df 100644 --- a/README.md +++ b/README.md @@ -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 @@ -66,23 +66,8 @@ Client ID: `814288819477020702`

-# Core Contributers -## SudhanPlayz +## 👥 | Support Server

-

- -## Reyansh Khobragade - -

- - -

- - +

\ No newline at end of file diff --git a/example.js b/example.js index 5ca14bd..239658b 100644 --- a/example.js +++ b/example.js @@ -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") \ No newline at end of file diff --git a/index.js b/index.js index e151a1b..fd71772 100644 --- a/index.js +++ b/index.js @@ -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. \ No newline at end of file + } +}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index fdfabce..f2c8ead 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "discordjs-activity", - "version": "1.0.0", + "version": "1.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 10b765c..727ff72 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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": {