
Recherche avancée
Autres articles (50)
-
Qu’est ce qu’un masque de formulaire
13 juin 2013, parUn masque de formulaire consiste en la personnalisation du formulaire de mise en ligne des médias, rubriques, actualités, éditoriaux et liens vers des sites.
Chaque formulaire de publication d’objet peut donc être personnalisé.
Pour accéder à la personnalisation des champs de formulaires, il est nécessaire d’aller dans l’administration de votre MediaSPIP puis de sélectionner "Configuration des masques de formulaires".
Sélectionnez ensuite le formulaire à modifier en cliquant sur sont type d’objet. (...) -
Contribute to documentation
13 avril 2011Documentation is vital to the development of improved technical capabilities.
MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
To contribute, register to the project users’ mailing (...) -
Selection of projects using MediaSPIP
2 mai 2011, parThe examples below are representative elements of MediaSPIP specific uses for specific projects.
MediaSPIP farm @ Infini
The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)
Sur d’autres sites (4618)
-
Discord music bot doesn't play songs
9 octobre 2023, par Gam3rsCZI have made myself a discord bot that also plays music(it's only for my server so strings with messages are in Czech, but code is in English).
Bot worked a while ago but now it stopped, and I don't know where the problem is


I'm getting these errors : HTTP error 403 Forbidden Server returned 403 Forbidden (access denied) and
C :\Users\Me\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\player.py:711 : RuntimeWarning : coroutine 'music_cog.play_next' was never awaited
self.after(error)
RuntimeWarning : Enable tracemalloc to get the object allocation traceback
[2023-10-09 16:23:47] [INFO ] discord.player : ffmpeg process 17496 successfully terminated with return code of 1.
INFO : ffmpeg process 17496 successfully terminated with return code of 1.


My code is :


import discord
from discord.ext import commands
from yt_dlp import YoutubeDL

class music_cog(commands.Cog):
 def __init__(self, bot):
 self.bot = bot

 self.is_playing = False
 self.is_paused = False
 self.current = ""

 self.music_queue = []
 self.YDL_OPTIONS = {"format": "m4a/bestaudio/best", "noplaylist": "True"}
 self.FFMPEG_OPTIONS = {"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5", "options": "-vn"}

 self.vc = None

 def search_yt(self, item):
 with YoutubeDL(self.YDL_OPTIONS) as ydl:
 try:
 info = ydl.extract_info("ytsearch:%s" % item, download=False)["entries"][0]
 except Exception:
 return False
 info = ydl.sanitize_info(info)
 url = info['url']
 title = info['title']
 return {'title': title, 'source': url}

 async def play_next(self):
 if len(self.music_queue) > 0:
 self.is_playing = True
 self.current = self.music_queue[0][0]["title"]
 m_url = self.music_queue[0][0]["source"]

 self.music_queue.pop(0)

 await self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
 else:
 self.is_playing = False

 async def play_music(self, ctx):
 try:
 if len(self.music_queue) > 0:
 self.is_playing = True
 m_url = self.music_queue[0][0]["source"]

 if self.vc == None or not self.vc.is_connected():
 self.vc = await self.music_queue[0][1].connect()

 if self.vc == None:
 await ctx.send("Nepodařilo se připojit do hlasového kanálu.")
 return
 else:
 await self.vc.move_to(self.music_queue[0][1])

 self.current = self.music_queue[0][0]["title"]
 self.music_queue.pop(0)

 self.vc.play(discord.FFmpegPCMAudio(m_url, **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
 else:
 self.is_playing = False

 except:
 print("Something went wrong")
 await ctx.send(content="Něco se pokazilo")

 @commands.command(name="play", help="Plays selected song from YouTube")
 async def play(self, ctx, *args):
 query = " ".join(args)

 voice_channel = ctx.author.voice.channel
 if voice_channel is None:
 await ctx.send("Připojte se do hlasového kanálu!")
 elif self.is_paused:
 self.vc.resume()
 else:
 song = self.search_yt(query)
 if type(song) == type(True):
 await ctx.send("Písničku se nepodařilo stáhnout. Špatný formát, možná jste se pokusili zadat playlist nebo livestream.")
 else:
 await ctx.send("Písnička přidána do řady.")
 self.music_queue.append([song, voice_channel])

 if self.is_playing == False:
 await self.play_music(ctx)
 self.is_playing = True

 @commands.command(name="pause", aliases=["p"], help="Pauses the BOT")
 async def pause(self, ctx, *args):
 if self.is_playing:
 self.is_playing = False
 self.is_paused = True
 self.vc.pause()
 await ctx.send(content="Písnička byla pozastavena.")
 
 elif self.is_paused:
 self.is_playing = True
 self.is_paused = False
 self.vc.resume()
 await ctx.send(content="Písnička byla obnovena.")

 @commands.command(name="resume", aliases=["r"], help="Resumes playing")
 async def resume(self, ctx, *args):
 if self.is_paused:
 self.is_paused = False
 self.is_playing = True
 self.vc.resume()
 await ctx.send(content="Písnička byla obnovena.")

 @commands.command(name="skip", aliases=["s"], help="Skips current song")
 async def skip(self, ctx, *args):
 if self.vc != None and self.vc:
 self.vc.stop()
 await self.play_next()
 await ctx.send(content="Písnička byla přeskočena.")

 @commands.command(name="queue", aliases=["q"], help="Displays song queue")
 async def queue(self, ctx, songs=5):
 retval = ""

 for i in range(0, len(self.music_queue)):
 if i > songs: break
 retval += " " + self.music_queue[i][0]["title"] + "\n"

 if retval != "":
 retval += "```"
 await ctx.send(content=("```Aktuální fronta:\n" + retval))
 else:
 await ctx.send("Řada je prázdná.")

 @commands.command(name="clear", help="Clears the queue")
 async def clear(self, ctx):
 if self.vc != None and self.is_playing:
 self.vc.stop()
 self.music_queue = []
 await ctx.send("Řada byla vymazána.")

 @commands.command(name="leave", aliases=["dc", "disconnect"], help="Disconnects the BOT")
 async def leave(self, ctx):
 self.is_playing = False
 self.is_paused = False

 if self.vc != None:
 return await self.vc.disconnect(), await ctx.send(content="BOT byl odpojen.")

 else:
 return await ctx.send("BOT není nikde připojen.")
 
 @commands.command(name="current", help="Displays the current song")
 async def current(self, ctx):
 current = self.current
 retval = f"```Právě hraje:\n {current}```"
 if current != "":
 await ctx.send(retval)
 else:
 await ctx.send("Aktuálně nic nehraje.")



I already tried everything I can think of(which isn't a lot because I suck at programming), and also tried searching for some solution on the internet, but nothing worked.


-
Problem settingup a play command for my discord bot (music) ['Error : FFmpeg/avconv not found !']
28 août 2023, par TitanFrexIm new to programing a discord bot, im more to the web developing enviroment, im trying to create by myself a play command song (only with one link) to try if the first join is working and actually play the song.


(Discord.js v14)


Unfortunately i was having a problem with FFMPEG.
This my actual module for the play.js command, where all the problem is happening.


const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice');
const ytdl = require('ytdl-core');

module.exports = {
 devOnly: true,
 name: 'play',
 description: 'Start to play a song!',
 // options: Object[],

 /**
 *
 * @param {Client} client
 * @param {Interaction} interaction
 */
 callback: async (client, interaction) => {
 const voiceChannel = interaction.member.voice.channel;

 if (!voiceChannel) {
 return interaction.reply('You must be in a voice channel to use this command.');
 }

 const connection = joinVoiceChannel({
 channelId: voiceChannel.id,
 guildId: interaction.guild.id,
 adapterCreator: interaction.guild.voiceAdapterCreator,
 });

 const stream = ytdl('URL_HERE', { filter: 'audioonly' });
 const resource = createAudioResource(stream);

 const player = createAudioPlayer();
 connection.subscribe(player);
 player.play(resource);

 interaction.reply({
 content: `Playing Song`,
 // ephemeral: true,
 });
 }
}



The first error i was receving was 'Error : FFmpeg/avconv not found !', i tried to install it with some guides online. after couple of tries i get it right and the command 'ffmpeg -version' returns.


After that i tought it was workikng, but when i started my project, i receved the same error,. I tried to look up for a solution and i tried to get the process.env.PATH to see but i dont understand if its right or not.


After i removed the console.log(process.env.PATH), i get no errors in the terminal, but it will stil not play the song.


-
Discord slash command music bot stops playing unexpectedly
29 juillet 2023, par ShelbyThis is a bot I am using to play music and it worked just fine for a while until it didn't. Simply loaded the bot and played for about a minute and quits. From what I see it destroys the entire queue of songs, no matter how many are there. And after that it won't respond to any command and it needs to be reloaded. I don't get any error in the terminal and all the other commands seem to work just fine. Also, this happens to whatever query I use, whether it's 'search', 'url' or 'playlist'.


const { SlashCommandBuilder } = require("@discordjs/builders")
const { EmbedBuilder } = require("discord.js")
const { QueryType } = require("discord-player")

module.exports = {
 data: new SlashCommandBuilder()
 .setName("play")
 .setDescription("Asculta muzica")
 .addSubcommand((subcommand)=>
 subcommand
 .setName("song")
 .setDescription("Incarca o singura melodie printr-un url")
 .addStringOption((option) => option.setName("url").setDescription("url-ul melodiei").setRequired(true)))
 .addSubcommand((subcommand) =>
 subcommand
 .setName("playlist")
 .setDescription("Incarca un playlist printr-un url")
 .addStringOption((option) => option.setName("url").setDescription("url-ul playlist-ului").setRequired(true)))
 .addSubcommand((subcommand) =>
 subcommand
 .setName("search")
 .setDescription("Cauta o melodie pe baza cuvintelor-cheie")
 .addStringOption((option) => 
 option.setName("cautare").setDescription("cauta dupa titlu si autor").setRequired(true))),
 
 run: async ({ client, interaction }) => {
 if (!interaction.member.voice.channel)
 return interaction.editReply("Trebuie sa fii pe un voice channel pentru a folosi aceasta comanda!")

 const queue = await client.player.createQueue(interaction.guild)
 if (!queue.connection) await queue.connect(interaction.member.voice.channel)

 let embed = new EmbedBuilder()

 if (interaction.options.getSubcommand() === "song"){
 let url = interaction.options.getString("url")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.YOUTUBE_VIDEO
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const song = result.tracks[0]
 await queue.addTrack(song)
 embed
 .setColor(0xF07459)
 .setDescription(`**[${song.title}](${song.url})** a fost adaugata`)
 .setThumbnail(song.thumbnail)
 .setFooter({ text: `Durata: ${song.duration}`})

 } else if (interaction.options.getSubcommand() === "playlist"){
 let url = interaction.options.getString("url")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.YOUTUBE_PLAYLIST
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const playlist = result.playlist
 await queue.addTracks(result.tracks)
 embed
 .setColor(0xF07459)
 .setDescription(`**${result.tracks.length} melodii din [${playlist.title}](${playlist.url})** au fost adaugate`)

 } else if (interaction.options.getSubcommand() === "search"){
 let url = interaction.options.getString("cautare")
 const result = await client.player.search(url, {
 requestedBy: interaction.user,
 searchEngine: QueryType.AUTO
 })

 if (result.tracks.length === 0)
 return interaction.editReply("Niciun rezultat")

 const song = result.tracks[0]
 await queue.addTrack(song)
 embed
 .setColor(0xF07459)
 .setDescription(`**[${song.title}](${song.url})** a fost adaugata`)
 .setThumbnail(song.thumbnail)
 .setFooter({ text: `Durata: ${song.duration}`})
 }
 if (!queue.playing) await queue.play()
 await interaction.editReply({
 embeds: [embed]
 })
 
 }
}



This is the code for the [play] command. No change was done since it worked perfectly.


After some research I found out that there might be a problem with the ffmpeg or the ytdl. I tried updating or reinstalling them, but the problem still remains. I would like to know if I'll need to rework the bot to find an alternative to these two.