mirror of
https://github.com/ION606/selmerBot.git
synced 2026-05-14 21:26:54 +00:00
Added button integration to the audio command and removed the YouTube.data file
This commit is contained in:
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"cookie": {
|
|
||||||
"GPS": "1",
|
|
||||||
"Domain": ".youtube.com",
|
|
||||||
"Expires": "Thu, 27-Oct-2022 17:51:25 GMT",
|
|
||||||
"Path": "/",
|
|
||||||
"YSC": "AlW2Krsd2Ek",
|
|
||||||
"SameSite": "none",
|
|
||||||
"VISITOR_INFO1_LIVE": "_eP8T2zceRQ"
|
|
||||||
},
|
|
||||||
"file": true
|
|
||||||
}
|
|
||||||
@@ -86,7 +86,7 @@ async function execute(bot, message, args, command, Discord, mongouri, items, xp
|
|||||||
if (args[1] == 'welcome') {
|
if (args[1] == 'welcome') {
|
||||||
temp = 'Use _!setup welcome\\_channel [channel name]_ to set the welcome channel and _!setup welcome\\_message [message]_ to set a welcome message!\n';
|
temp = 'Use _!setup welcome\\_channel [channel name]_ to set the welcome channel and _!setup welcome\\_message [message]_ to set a welcome message!\n';
|
||||||
} else if (args[1] == 'logs') {
|
} else if (args[1] == 'logs') {
|
||||||
temp = 'To enable logging, use the command _!setup keep\\_logs true_ and _!setup log\\_channel_ to set up the logging channel!\n';
|
temp = 'To enable logging, use the command _!setup keep\\_logs true_ and _!setup log\\_channel_ [channel name] to set the logging channel!\n';
|
||||||
temp += 'Use _!setup keep\\_logs false_ to disable logging and _!setup log\\_severity [none, low, medium, high]_ to set the threshold\n';
|
temp += 'Use _!setup keep\\_logs false_ to disable logging and _!setup log\\_severity [none, low, medium, high]_ to set the threshold\n';
|
||||||
temp += '__Severities:__\n*none* - unmute, unban\n*low* - mute\n*medium* - kick\n*high* - ban\nEvery tier also includes all notifs for ***higher*** tiers (AKA _!setup log\\_severity none_ will log everything from every severity)\n';
|
temp += '__Severities:__\n*none* - unmute, unban\n*low* - mute\n*medium* - kick\n*high* - ban\nEvery tier also includes all notifs for ***higher*** tiers (AKA _!setup log\\_severity none_ will log everything from every severity)\n';
|
||||||
} else { temp = 'Please use the following format: _!setup help [welcome, logs]_\nExample: _!setup help welcome_'; }
|
} else { temp = 'Please use the following format: _!setup help [welcome, logs]_\nExample: _!setup help welcome_'; }
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
const { MongoClient, ServerApiVersion } = require('mongodb');
|
const { MongoClient, ServerApiVersion } = require('mongodb');
|
||||||
const { createSubscriptionManual } = require('./API/stripe.js');
|
const { createSubscriptionManual } = require('./API/stripe.js');
|
||||||
|
const { pause_start_stop } = require('./misc/playAudio.js');
|
||||||
|
|
||||||
|
|
||||||
async function handle_interaction(interaction, mongouri, turnManager, bot, STATE, items, xp_collection) {
|
async function handle_interaction(interaction, mongouri, turnManager, bot, STATE, items, xp_collection) {
|
||||||
if (interaction.isButton()) {
|
if (interaction.isButton()) {
|
||||||
const battlecommandlist = ['ATTACK', 'HEAL', 'DEFEND', 'ITEMS', 'ULTIMATE'];
|
const battlecommandlist = ['ATTACK', 'HEAL', 'DEFEND', 'ITEMS', 'ULTIMATE'];
|
||||||
const singleCommandGames = ['ttt'];
|
const singleCommandGames = ['ttt']; // Use when you have more single-player games
|
||||||
|
const musicCommandList = ['PLAY', 'PAUSE', 'UNPAUSE', 'STOP'];
|
||||||
|
|
||||||
const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
|
const client = new MongoClient(mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
|
||||||
client.connect(async (err) => {
|
client.connect(async (err) => {
|
||||||
@@ -57,6 +59,8 @@ async function handle_interaction(interaction, mongouri, turnManager, bot, STATE
|
|||||||
console.log("It's not your turn!");
|
console.log("It's not your turn!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (musicCommandList.indexOf(interaction.customId) != -1) {
|
||||||
|
pause_start_stop(interaction, bot);
|
||||||
} //else ifs here
|
} //else ifs here
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+95
-36
@@ -1,7 +1,7 @@
|
|||||||
const pathToFfmpeg = require('ffmpeg-static');
|
const pathToFfmpeg = require('ffmpeg-static');
|
||||||
const { joinVoiceChannel, createAudioResource } = require('@discordjs/voice');
|
// const { joinVoiceChannel, createAudioResource } = require('@discordjs/voice');
|
||||||
const { generateDependencyReport } = require('@discordjs/voice');
|
const { VoiceConnectionStatus, AudioPlayerStatus, createAudioPlayer, StreamType, joinVoiceChannel, createAudioResource, getVoiceConnection } = require('@discordjs/voice');
|
||||||
const { VoiceConnectionStatus, AudioPlayerStatus, createAudioPlayer, StreamType } = require('@discordjs/voice');
|
const { MessageActionRow, MessageButton, MessageSelectMenu } = require('discord.js');
|
||||||
const play = require('play-dl');
|
const play = require('play-dl');
|
||||||
|
|
||||||
// Leave here to be initialized at the program's start
|
// Leave here to be initialized at the program's start
|
||||||
@@ -10,20 +10,64 @@ const player = createAudioPlayer();
|
|||||||
// Note: Unsure of what this does , but may be related to the play-dl lib (my notes are inconsistent)
|
// Note: Unsure of what this does , but may be related to the play-dl lib (my notes are inconsistent)
|
||||||
// play.authorization();
|
// play.authorization();
|
||||||
|
|
||||||
|
function pause_start_stop(interaction, bot) {
|
||||||
|
const command = interaction.customId.toLowerCase();
|
||||||
|
var em = interaction.message.embeds[0];
|
||||||
|
var rows = [new MessageActionRow()];
|
||||||
|
|
||||||
|
if (command == "pause") {
|
||||||
|
rows[0].addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId('UNPAUSE')
|
||||||
|
.setLabel('▶️')
|
||||||
|
.setStyle('SECONDARY'),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId('STOP')
|
||||||
|
.setLabel('⏹️')
|
||||||
|
.setStyle('SECONDARY')
|
||||||
|
);
|
||||||
|
|
||||||
|
em.description = 'IS NOW PAUSED';
|
||||||
|
player.pause();
|
||||||
|
|
||||||
|
} else if (command == "unpause") {
|
||||||
|
rows[0].addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId('PAUSE')
|
||||||
|
.setLabel('⏸️')
|
||||||
|
.setStyle('SECONDARY'),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId('STOP')
|
||||||
|
.setLabel('⏹️')
|
||||||
|
.setStyle('SECONDARY')
|
||||||
|
);
|
||||||
|
|
||||||
|
em.description = 'IS NOW PLAYING';
|
||||||
|
|
||||||
|
player.unpause();
|
||||||
|
} else if (command == "stop") {
|
||||||
|
rows = [];
|
||||||
|
em.description = 'IS NOW STOPPED';
|
||||||
|
|
||||||
|
const connection = getVoiceConnection(interaction.guild.id);
|
||||||
|
|
||||||
|
player.stop();
|
||||||
|
if (connection) { connection.destroy(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
interaction.update({embeds: [em], components: rows})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "audio",
|
name: "audio",
|
||||||
async execute(message, args, Discord, Client, bot) {
|
description: 'Play a song from YouTube, add free!',
|
||||||
|
async execute(message, args, Discord, Client, bot, interaction = null) {
|
||||||
// message.channel.send("This command has not been set up yet\nSorry!");
|
// message.channel.send("This command has not been set up yet\nSorry!");
|
||||||
// return;
|
// return;
|
||||||
if (args[0] == "play") {
|
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
message.reply("Please specify a function (play, pause, unpause or stop)");
|
message.reply("Please use the following format _!audio [song name or URL]_");
|
||||||
return;
|
return;
|
||||||
} else if (args.length < 2) {
|
|
||||||
message.reply("Please provide a song url");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -36,9 +80,10 @@ module.exports = {
|
|||||||
message.reply("Please join a voice channel before you try this!");
|
message.reply("Please join a voice channel before you try this!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Test 930148609406685227
|
|
||||||
const channel = bot.channels.cache.get(message.member.voice.channel.id);
|
const channel = bot.channels.cache.get(message.member.voice.channel.id);
|
||||||
console.log(message.member.voice.channel.id);
|
// console.log(message.member.voice.channel.id);
|
||||||
|
|
||||||
const connection = joinVoiceChannel({
|
const connection = joinVoiceChannel({
|
||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
guildId: channel.guild.id,
|
guildId: channel.guild.id,
|
||||||
@@ -46,26 +91,24 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
connection.on(VoiceConnectionStatus.Ready, () => {
|
connection.on(VoiceConnectionStatus.Ready, () => {
|
||||||
console.log('Connected to the voice channel!');
|
// console.log('Connected to the voice channel!');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (args[0] == "play") {
|
|
||||||
let stream;
|
let stream;
|
||||||
let info = "Playing __***";
|
|
||||||
let yt_info;
|
let yt_info;
|
||||||
if (args[1].startsWith("https://")) {
|
if (args[0].startsWith("https://")) {
|
||||||
if (!args[1].startsWith("https://www.youtube.com/") &&
|
if (!args[0].startsWith("https://www.youtube.com/") &&
|
||||||
!args[1].startsWith("https://music.youtube.com/")) {
|
!args[0].startsWith("https://music.youtube.com/")) {
|
||||||
message.reply("This is not a valid YouTube URL");
|
message.reply("This is not a valid YouTube URL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yt_info = await play.video_info(args[1]);
|
yt_info = await play.video_info(args[0]);
|
||||||
// let stream = await play.stream_from_info(yt_info)
|
// let stream = await play.stream_from_info(yt_info)
|
||||||
stream = await play.stream(args[1]);
|
stream = await play.stream(args[0]);
|
||||||
|
|
||||||
console.log("Playing from a URL!");
|
// console.log("Playing from a URL!");
|
||||||
} else {
|
} else {
|
||||||
yt_info = await play.search(args.slice(1).join(' '), {
|
yt_info = await play.search(args.join(' '), {
|
||||||
limit: 1
|
limit: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -73,9 +116,31 @@ module.exports = {
|
|||||||
yt_info = await play.video_info(yt_info[0].url);
|
yt_info = await play.video_info(yt_info[0].url);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add the video info to the return message
|
const author = {
|
||||||
info += yt_info.video_details.title + "***__\n";
|
name: "Selmer Bot",
|
||||||
info += "Check it out at " + yt_info.video_details.url + "\n";
|
url: "",
|
||||||
|
iconURL: bot.user.displayAvatarURL()
|
||||||
|
}
|
||||||
|
|
||||||
|
const newEmbed = new Discord.MessageEmbed()
|
||||||
|
.setColor(' #0F00F0')
|
||||||
|
.setTitle(`${yt_info.video_details.title}`)
|
||||||
|
.setAuthor(author)
|
||||||
|
.setDescription('IS NOW PLAYING')
|
||||||
|
.setURL(yt_info.video_details.url)
|
||||||
|
.setThumbnail(yt_info.video_details.thumbnails[0].url);
|
||||||
|
|
||||||
|
const row = new MessageActionRow()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId('PAUSE')
|
||||||
|
.setLabel('⏸️')
|
||||||
|
.setStyle('SECONDARY'),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId('STOP')
|
||||||
|
.setLabel('⏹️')
|
||||||
|
.setStyle('SECONDARY')
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
let resource = createAudioResource(stream.stream, {
|
let resource = createAudioResource(stream.stream, {
|
||||||
@@ -89,16 +154,10 @@ module.exports = {
|
|||||||
player.play(resource);
|
player.play(resource);
|
||||||
|
|
||||||
player.on(AudioPlayerStatus.Playing, () => {
|
player.on(AudioPlayerStatus.Playing, () => {
|
||||||
console.log('The audio player has started playing!');
|
// console.log('The audio player has started playing!');
|
||||||
});
|
});
|
||||||
message.reply(info);
|
|
||||||
} else if (args[0] == "pause") {
|
message.reply({ embeds: [newEmbed], components: [row] });
|
||||||
player.pause();
|
|
||||||
} else if (args[0] == "unpause") {
|
}, pause_start_stop
|
||||||
player.unpause();
|
|
||||||
} else if (args[0] == "stop") {
|
|
||||||
player.stop();
|
|
||||||
connection.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user