-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
678278e
commit b4e7ee1
Showing
5 changed files
with
43 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters