
Recherche avancée
Autres articles (93)
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Le plugin : Gestion de la mutualisation
2 mars 2010, parLe plugin de Gestion de mutualisation permet de gérer les différents canaux de mediaspip depuis un site maître. Il a pour but de fournir une solution pure SPIP afin de remplacer cette ancienne solution.
Installation basique
On installe les fichiers de SPIP sur le serveur.
On ajoute ensuite le plugin "mutualisation" à la racine du site comme décrit ici.
On customise le fichier mes_options.php central comme on le souhaite. Voilà pour l’exemple celui de la plateforme mediaspip.net :
< ?php (...) -
Gestion de la ferme
2 mars 2010, parLa ferme est gérée dans son ensemble par des "super admins".
Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
Dans un premier temps il utilise le plugin "Gestion de mutualisation"
Sur d’autres sites (10962)
-
Need help to create a queue system with a discord.py bot
19 août 2024, par Zamvim trying to create a bot with discord.py, i'll start saying that the bot is for personal use so please don't point out that i shouldn't use ydl in the comments, ty :
Also, im a beginner, so please tell me what I can improve and any errors there are, I will be happy to listen.
That said, i've been stuck on trying to create this queue system for songs for the past 3 days, the bot was working perfectly fine and played some urls before i implemented the play_next function, now it doesn't even play the first song, even if it sends confirmation messages both in the terminal that in the discord channel, i know that the code might be a little confusing, but please i really need to know how to make this work


i wrote two main functions : "play_next" to play the next song in the queue and "play", the main command.
Here is my play_next function :


async def play_next(self,ctx):
 if not ctx.voice_client.is_playing: #(don't know if this is correct as I also check if the bot isn't playing anything in the play function)
 
 if self.song.queue: 
 next_song = self.song_queue.pop(0) #deleting the first element of the queue, so if we have (song_0, song_1 and song_2) the bot should delete (song_0) making in fact song_1 the "next" song_0
 try:
 ctx.voice_client.play(discord.FFmpegPCMAudio(next_song), 
 after=lambda e: self.bot.loop.create_task(self.play_next(ctx))) #Not gonna lie here, i asked chat gpt for this line, it should make the bot automatically play the next song one after another, correct me if I am wrong

#this is not important
 embed = discord.Embed(
 title="Song",
 description=f"Now playing {next_song}",
 color = 0x1DB954
 )
 await ctx.send(embed=embed)
 except Exception as e:
 print(f"Error playing the next song: {e}")

 else:
 await ctx.voice_client.disconnect() # disconnecting from the voice channel if the queue is empty
 print("Disconnected from the voice channel as the queue is empty.")



I think that the main problem of my bot is the play_next function, but here it is my "play" function :


@commands.command(pass_context=True)
 async def play(self, ctx, url: str): 
 if ctx.author.voice: # first checking if the user is in a voice channel
 if not ctx.voice_client: #then checking if the bot is already connected to a voice channel
 channel = ctx.message.author.voice.channel 
 try:
 await channel.connect() #then joining
 print("I joined the voice channel!")
 except Exception as e:
 print(f"Failed to connect to the voice channel: {e}")
 return

 song_path = f"song_{self.song_index}.mp3" #note, im using cogs, i declared self.song_index with the value of 0 
 self.song_index += 1 #i thought that this was the easiest way of creating a new file for each song

 ydl_opts = {
 'format': 'bestaudio/best',
 'postprocesors': [{
 'key': 'FFmpegExtractAudio',
 'preferredcodec': 'mp3',
 'preferredquality': '192',
 }],
 'outtmpl': song_path
 }
 try:
 with youtube_dl.YoutubeDL(ydl_opts) as ydl:
 print("Starting download...")
 ydl.download([url]) #this is where it should download the song provided by the url
 print("Download finished.")
 except Exception as e:
 await ctx.send(f"Failed to download the song: {e}")
 return

#i think that the next two if statements are the main threats
 if os.path.exists(song_path): #if there is atleast 1 song in the queue
 self.song_queue.append(song_path) #append the next one
 embed = discord.Embed(
 title="Added to Queue!",
 description = f"{url} has been added to the queue.",
 color=0x33ff33
 )
 await ctx.send(embed=embed)


 if not ctx.voice_client.is_playing(): #checking if the bot is already playing something, don't know if i should put this if statement here
 print("Starting playback...")
 await self.play_next(ctx) #if nothing is playing, then the bot should play the next song



 else:
 await ctx.send("Failed to download or find the audio file.")

 else:
 embed = discord.Embed(
 title="❌You must be in a voice channel",
 color=0xff6666
 )
 await ctx.send(embed=embed)



thanks in advance, i will try to read and answer any questions as soon as possible


-
Issues with Discord JS Music Bot
5 décembre 2020, par ThresioI am in the process of creating a Discord bot with JS, giving it management, auto role, etc. I just got to the music section of it and I can't quite figure out whats wrong.



I believe I have installed FFmpeg correctly, as I have access to it from within the terminal. I have also used npm to bring ytdl-core and opusscript into my program.



What this should do is make the bot join the chat, then play the Youtube link. Currently, I am not error checking the second argument as I just wanted to get it working initially. I have implemented several different instances of .toString() and String() however it always gives the same error listed below.



. The program still throws this error :



TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object
TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object

C:\Users\Thresio's PC\Desktop\Discord Bot\node_modules\opusscript\build\opusscript_native_wasm.js:8
var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var
key;for(key in Module){if(Module.hasOwnProperty(key))
{moduleOverrides[key]=Module[key]}}Module["arguments"]=
[];Module["thisProgram"]="./this.program";Module["quit"]=function(status,toThrow) {throw
toThrow};Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var 
ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var 
ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof 
importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof 
process.versions==="object"&&typeof 
process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONM
ENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var
scriptDirectory="";function locateFile(path){i
abort(TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type 
string. Received type object). Build with -s ASSERTIONS=1 for more info. 




Here is my code for calling play :



case 'play':

 function play(connection, message){
 var server = servers[message.guild.id];

 server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: 'audioonly'}));

 server.queue.shift();

 server.dispatcher.on('end', function(){
 if(server.queue[0]){
 play(connection, message);
 }else {
 connection.disconnect();
 }
 })
 }

 if(!args[1]){
 message.channel.send('You need to provide a link!');
 return;
 }

 if(!message.member.voiceChannel){
 message.channel.send('You must be in a voice channel to play music!');
 return;
 }

 if(!servers[message.guild.id]) servers[message.guild.id] = {
 queue: []
 }

 var server = servers[message.guild.id];

 server.queue.push(args[1]);

 if(!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection){
 play(connection, message);
 })
 break;




If anyone could assist with this, I would be very grateful.



EDIT : I unfortunately never figured out my main issue, but I have now found code that works (unlike mine :/).
For anyone else having this issue, I suggest using the code found here.
Works like a charm !


-
Flutter : Failed assertion : 'file.absolute.existsSync()' : is not true
11 août 2022, par whatwhatwhatIn my app, a user can send a file to others in a group chat. First, the user records some audio using their mic. The file is then touched up using FFMPEG. Then, the file is uploaded to Firebase Cloud Storage and if this is successful, a record is written in Firebase Realtime Database.


I'm getting the error below when the user records a long audio file and then presses submit. It almost seems as though FFMPEG hasn't finished processing the file...but I thought I used my async/await correctly to make sure that this processing is finished before moving on ?




##MyAppFile## saveMyAppFileToCloudStorage Error : 'package:firebase_storage/src/reference.dart' : Failed assertion : line 127 pos 12 : 'file.absolute.existsSync()' : is not true.




Psuedo-code :


- 

- User records audio
- Audio file is processed using FFMPEG and the new processed file is created on the user's phone
- User hits submit, uploading the file to Cloud Storage and, if successful, writing a record to Realtime Database








Order of Functions After User Hits Submit :


- 

- msgInput.dart -> sendMyAppFile()
- msgInput.dart -> prepareMyAppFileForSending()
- msgInput.dart -> runFFMPEGHighLow()
- message_dao.dart -> sendMyAppFile()
- message_dao.dart -> saveMyAppFileToCloudStorage() //ERROR COMES FROM THIS FUNCTION












The Code :


//msgInput.dart
Future<void> sendMyAppFile() async {
 if (sendableMyAppFileExists == 1) {
 final MyAppFileReadyToBeSent = await prepareMyAppFileForSending();

 if (MyAppFileReadyToBeSent == '1') {
 messageDao.sendMyAppFile(MyAppFile, filepath, filename); 
 } else {
 
 }
 }

 setState(() {
 sendableMyAppFileExists = 0;
 });
 }
 
 Future<string> prepareMyAppFileForSending() async {
 if (sendableMyAppFileExists == 1) {
 if (recordedMyAppFileFilterID == '1') {

 await runFFMPEGHighLow('1'); 

 return '1';
 }

 if (recordedMyAppFileFilterID == '2') {

 await runFFMPEGHighLow('2'); 

 return '1';
 }
 }

 return '0';
 }
 
 Future<void> runFFMPEGHighLow(String filterID) async { 
 if (filterID != '1' && filterID != '2') {
 return;
 }

 if (sendableMyAppFileExists == 1) {
 if (filterID == '1') {

 await FFmpegKit.executeAsync(/*...parms...*/);
 setState(() {
 currentMyAppFileFilename = currentMyAppFileFilename + '1.mp3'; 
 });

 }

 if (filterID == '2') {

 await FFmpegKit.executeAsync(/*...parms...*/);
 setState(() {
 currentMyAppFileFilename = currentMyAppFileFilename + '2.mp3';
 });

 }
 }
 }
 
//message_dao.dart
void sendMyAppFile(ChatData MyAppFile, String filepath, String filename) {
 saveMyAppFileToCloudStorage(filepath, filename).then((value) {
 if (value == true) {
 saveMyAppFileToRTDB(MyAppFile);
 }
 });
 }
 
Future<bool> saveMyAppFileToCloudStorage(String filepath, String filename) async {
 //filepath: /data/user/0/com.example.MyApp/app_flutter/MyApp/MyAppAudioFiles/MyAppFiles/2d7af6ae-6361-4be5-8209-8498dd17d77d1.mp3
 //filename: 2d7af6ae-6361-4be5-8209-8498dd17d77d1.mp3

 _firebaseStoragePath = MyAppFileStorageDir + filename;
 
 File file = File(filepath);

 try {
 await _firebaseStorage
 .ref(_firebaseStoragePath)
 .putFile(file);
 return true;
 } catch (e) {
 print('##MyAppFile## saveMyAppFileToCloudStorage Error: ' + e.toString()); //ERROR COMES FROM THIS LINE
 return false;
 }
 return true;
 }
</bool></void></string></void>