Recherche avancée

Médias (0)

Mot : - Tags -/interaction

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (40)

  • ANNEXE : Les extensions, plugins SPIP des canaux

    11 février 2010, par

    Un plugin est un ajout fonctionnel au noyau principal de SPIP. MediaSPIP consiste en un choix délibéré de plugins existant ou pas auparavant dans la communauté SPIP, qui ont pour certains nécessité soit leur création de A à Z, soit des ajouts de fonctionnalités.
    Les extensions que MediaSPIP nécessite pour fonctionner
    Depuis la version 2.1.0, SPIP permet d’ajouter des plugins dans le répertoire extensions/.
    Les "extensions" ne sont ni plus ni moins que des plugins dont la particularité est qu’ils se (...)

  • Changer son thème graphique

    22 février 2011, par

    Le thème graphique ne touche pas à la disposition à proprement dite des éléments dans la page. Il ne fait que modifier l’apparence des éléments.
    Le placement peut être modifié effectivement, mais cette modification n’est que visuelle et non pas au niveau de la représentation sémantique de la page.
    Modifier le thème graphique utilisé
    Pour modifier le thème graphique utilisé, il est nécessaire que le plugin zen-garden soit activé sur le site.
    Il suffit ensuite de se rendre dans l’espace de configuration du (...)

  • Contribute to documentation

    13 avril 2011

    Documentation 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 (...)

Sur d’autres sites (4943)

  • How do I add a queue to my music bot using Discrod.py FFmpeg and youtube_dl ?

    28 septembre 2022, par Виктор Лисичкин

    I'm writing my bot for discord, I can't figure out how to track the end of a song to lose the next one. I sort of figured out the piece of music, but I don't fully understand what to do next. Here is my code for main.py

    


    from discord.ext import commands, tasks
from config import settings
from music_cog import music_cog
bot = commands.Bot(command_prefix='!',intents = discord.Intents.all())

@bot.event
async def on_ready():
    print(f'We have logged in as {bot.user}')
    await bot.add_cog(music_cog(bot))

bot.run(settings['token'])


    


    and And this is for cog with music

    


    from discord.ext import commands
from youtube_dl import YoutubeDL
YDL_OPTIONS = {'format': 'worstaudio/best', 'noplaylist': 'False', 'simulate': 'True',
               'preferredquality': '192', 'preferredcodec': 'mp3', 'key': 'FFmpegExtractAudio'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
queue = []
class music_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    @commands.command(pass_context=True)
    async def play(self,ctx, *, arg):
        global queue
        queue.append(arg)
        def playing():
            for song in queue:
                with YoutubeDL(YDL_OPTIONS) as ydl:
                    if 'https://' in song:
                        info = ydl.extract_info(song, download=False)
                    else:
                        info = ydl.extract_info(f"ytsearch:{song}", download=False)['entries'][0]

                    url = info['formats'][0]['url']
                    queue.pop(0)
                    vc.play(discord.FFmpegPCMAudio(executable="ffmpeg", source=url, **FFMPEG_OPTIONS))
        voice_client = discord.utils.get(self.bot.voice_clients, guild=ctx.guild)
        if not ctx.message.author.voice:
            await ctx.send("You are not connected to voice chanel")
        elif voice_client:
            queue.append(arg)
        else:
            vc = await ctx.message.author.voice.channel.connect()
            playing()
    @commands.command(pass_context = True)
    async def disconect(self, ctx):
        server = ctx.message.guild.voice_client
        if ctx.message.guild.voice_client:
            await server.disconnect()
        else:
            await ctx.send("I am not connected")

    @commands.command(pass_context=True)
    async def stop(self, ctx):
        server = ctx.message.guild
        voice_channel = server.voice_client
        voice_channel.pause()

    @commands.command(pass_context=True)
    async def resumue(self, ctx):
        server = ctx.message.guild
        voice_channel = server.voice_client
        voice_channel.resume()


    


  • My discord music bot works locally, but not on a server [closed]

    8 décembre 2022, par Asmondya

    I have an issue with my discord music bot that I made with discord.js v14.

    


    When I run it locally, it works fine and plays music as it should. But when I put in on a server (here I use Vultr), it doesn't work.

    


    I am not sure but it might come from FFmpeg. I am kinda desperate and cant really figure where the issue is from. I think it is FFmpeg because it is what converts the music.

    


    What happens :

    


    Me: !play a music
Bot: Now playing a music
*and right after, without playing the music*
Bot: Music finished


    


    What should normally happen is that same thing but the "music finished" should be sent when the queue is finished.

    


    The thing is that the bot works perfectly locally, but does this when it is hosted on a server. Also I don't have any error messages or else. It just doesn't play the music like if the music was 0 seconds length.

    


    I tried making sure everything is installed on the server, same as making sure ffmpeg was installed globally and I have the good version of it. Here is the answer I have to the "ffmpeg -version" command :enter image description here.

    


    Does anyone know what could be the issue or what could cause it ? I can show some code if needed, even tho it works perfectly fine locally.

    


    Here's my code :

    


    const { DisTube } = require('distube')
const Discord = require('discord.js')
const { EmbedBuilder } = require('discord.js')
const client = new Discord.Client({
  intents: [
    Discord.GatewayIntentBits.Guilds,
    Discord.GatewayIntentBits.GuildMessages,
    Discord.GatewayIntentBits.GuildVoiceStates,
    Discord.GatewayIntentBits.MessageContent,
  ]
})
const { ActivityType } = require('discord.js')
const fs = require('fs')
const dotenv = require("dotenv")
dotenv.config()
const { SpotifyPlugin } = require('@distube/spotify')
const { SoundCloudPlugin } = require('@distube/soundcloud')
const { YtDlpPlugin } = require('@distube/yt-dlp')

client.distube = new DisTube(client, {
  leaveOnStop: false,
  emitNewSongOnly: true,
  emitAddSongWhenCreatingQueue: false,
  emitAddListWhenCreatingQueue: false,
  plugins: [
    new SpotifyPlugin({
      emitEventsAfterFetching: true
    }),
    new SoundCloudPlugin(),
    new YtDlpPlugin()
  ]
})
client.commands = new Discord.Collection()
client.aliases = new Discord.Collection()

fs.readdir('./commands/', (err, files) => {
  if (err) return console.log('Could not find any commands!')
  const jsFiles = files.filter(f => f.split('.').pop() === 'js')
  if (jsFiles.length <= 0) return console.log('Could not find any commands!')
  jsFiles.forEach(file => {
    const cmd = require(`./commands/${file}`)
    console.log(`Loaded ${file}`)
    client.commands.set(cmd.name, cmd)
    if (cmd.aliases) cmd.aliases.forEach(alias => client.aliases.set(alias, cmd.name))
  })
})

client.on('ready', () => {
  console.log(`${client.user.tag} is ready to play music.`)
})

client.on('messageCreate', async message => {
  if (message.author.bot || !message.guild) return
  const prefix = "!"
  if (!message.content.startsWith(prefix)) return
  const args = message.content.slice(prefix.length).trim().split(/ +/g)
  const command = args.shift().toLowerCase()
  const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
  if (!cmd) return
  if (cmd.inVoiceChannel && !message.member.voice.channel) {
    return message.channel.send(`You must be in a voice channel!`)
  }
  try {
    cmd.run(client, message, args)
  } catch (e) {
    console.error(e)
    message.channel.send(`Error: \`${e}\``)
  }
})

// Add filters to the queue status :
// | Filter: \`${queue.filters.names.join(', ') || 'Off'}\` 

const status = queue =>
  `Volume: \`${queue.volume}%\` | Loop: \`${
    queue.repeatMode ? (queue.repeatMode === 2 ? 'All Queue' : 'This Song') : 'Off'
  }\` | Autoplay: \`${queue.autoplay ? 'On' : 'Off'}\``
client.distube
  .on('playSong', (queue, song) =>
    queue.textChannel.send({
      embeds: [
        new Discord.EmbedBuilder()
          .setTitle('Now playing')
          .setDescription(`\`${song.name}\` - \`${song.formattedDuration}\`\n${status(queue)}\n\nRequested by: \`${song.user.tag}\``)
          .setThumbnail(`${song.thumbnail}`)
      ]
    })
  )
  .on('addSong', (queue, song) =>
    queue.textChannel.send({
      embeds: [
        new Discord.EmbedBuilder()
          .setTitle('Song added to the queue')
          .setDescription(`${song.name} - \`${song.formattedDuration}\`\n\nRequested by: \`${song.user.tag}\``)
          .setThumbnail(`${song.thumbnail}`)
      ]
    })
  )
  .on('addList', (queue, playlist) =>
    queue.textChannel.send({
      embeds: [
        new Discord.EmbedBuilder()
          .setTitle(`Playlist added to the queue`)
          .setDescription(`\`${playlist.name}\` (${
            playlist.songs.length
          } songs)\n${status(queue)}\n\nRequested by: \`${song.user.tag}\``)
          .setThumbnail(`${song.thumbnail}`)
      ]
    })
  )
  .on('error', (channel, e) => {
    if (channel) channel.send(`An error encountered: ${e.toString().slice(0, 1974)}`)
    else console.error(e)
  })
  .on('empty', channel => channel.send('There is no one here. Im alone, again...'))
  .on('searchNoResult', (message, query) =>
    message.channel.send(`No result found for \`${query}\`!`)
  )
  .on('finish', queue => queue.textChannel.send("https://tenor.com/view/end-thats-all-folks-gif-10601784"))

client.on("ready", () => {
  client.user.setPresence({
      activities: [{
        name: 'AURORA',
        type: ActivityType.Listening
      }],
      status: "idle"
  })
})

client.login(process.env.TOKEN)


    


    It does come from my ffpmeg, I need to install one of these packages instead of the npm installation : https://github.com/BtbN/FFmpeg-Builds/releases

    


    How do I install it on a server (Vultr) ?

    


  • Making my Discord Bot automatically play music from WAV on loop

    5 décembre 2022, par Mativ9

    So I was trying to make a Discord Bot in Python, which would atomatically join a voice channel and play my own music from a list in a loop. So far it's joining the channel, shuffling the list so the music is on random, but when I try to write a code so after one song it will play the next one it crushes and doesn't play anything (tho it's joining the channel)

    


    import discord
import random
from discord.ext import commands
from discord import FFmpegPCMAudio

#playlist as a list
queue = [FFmpegPCMAudio('Iceland1.wav'), FFmpegPCMAudio('Iceland2.wav'), FFmpegPCMAudio('Iceland3.wav'), FFmpegPCMAudio('Iceland4.wav'),
         FFmpegPCMAudio('Iceland5.wav'), FFmpegPCMAudio('Iceland6.wav'), FFmpegPCMAudio('Iceland7.wav'), FFmpegPCMAudio('Iceland8.wav'),
         FFmpegPCMAudio('Iceland9.wav'), FFmpegPCMAudio('Iceland10.wav'), FFmpegPCMAudio('Norway1.wav'), FFmpegPCMAudio('Norway2.wav'),
         FFmpegPCMAudio('Norway3.wav'), FFmpegPCMAudio('Norway4.wav'), FFmpegPCMAudio('Norway5.wav'), FFmpegPCMAudio('Norway6.wav'),
         FFmpegPCMAudio('Norway7.wav'), FFmpegPCMAudio('Norway8.wav'), FFmpegPCMAudio('Norway9.wav'), FFmpegPCMAudio('Norway10.wav'),
         FFmpegPCMAudio('Norway11.wav'), FFmpegPCMAudio('Presents1.wav'), FFmpegPCMAudio('Presents2.wav'), FFmpegPCMAudio('Presents3.wav'),
         FFmpegPCMAudio('Presents4.wav'), FFmpegPCMAudio('Presents5.wav'), FFmpegPCMAudio('Presents6.wav'), FFmpegPCMAudio('Presents7.wav'),
         FFmpegPCMAudio('Presents8.wav'), FFmpegPCMAudio('Presents9.wav'), FFmpegPCMAudio('Presents10.wav'), FFmpegPCMAudio('Autumn1.wav'),
         FFmpegPCMAudio('Autumn2.wav'), FFmpegPCMAudio('Autumn3.wav'), FFmpegPCMAudio('Autumn4.wav'), FFmpegPCMAudio('Autumn5.wav'),
         FFmpegPCMAudio('Autumn6.wav'), FFmpegPCMAudio('Autumn7.wav'), FFmpegPCMAudio('Autumn8.wav'), FFmpegPCMAudio('Covers1.wav'),
         FFmpegPCMAudio('Covers2.wav'), FFmpegPCMAudio('Covers3.wav'), FFmpegPCMAudio('Covers4.wav'), FFmpegPCMAudio('Covers5.wav'),
         FFmpegPCMAudio('Covers6.wav'), FFmpegPCMAudio('Covers7.wav'), FFmpegPCMAudio('Covers8.wav'), FFmpegPCMAudio('Covers9.wav'),
         FFmpegPCMAudio('Covers10.wav'), FFmpegPCMAudio('Covers11.wav'), FFmpegPCMAudio('Covers12.wav')]

intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix='>', intents=intents)

@client.event
async def on_ready():
    global voice
    print("The Matt Bot is ready")
    print("--------------------------")
    await client.change_presence(activity=discord.Game('Matt Krupa')) #makes my bot play Matt Krupa
    channel = client.get_channel(thechannelid) #geting channel ID
    voice = await channel.connect() #connecting to channel
    random.shuffle(queue) #randomazing the playlist
    def after_song(): #moving the first song to the end so its on loop, and playling the next one
        queue.append(queue[0])
        del queue[0]
        player = await voice.play(queue[0], after=await after_song())
    player = await voice.play(queue[0], after=await after_song()) #plays song from the playlist, after the song doing the after_song() function

client.run(mytokenidontwanttoshowitsry)


    


    I wanted it to play all the songs on the infinite loop, i can't find how to correctly detect the end of a song...