fmbot-discord / fmbot

.fmbot is a social Discord bot that provides music statistics for you and your friends.
https://fmbot.xyz/
Other
291 stars 44 forks source link

Include a standardised way for scrobbling from bots #283

Open CyberFlameGO opened 4 weeks ago

CyberFlameGO commented 4 weeks ago

Currently, tracks being played by bots are only scrobbled if the music bot's track-playing format is hardcoded into the bot, which is limiting for people self-hosting music bots - my suggestion is to either add formats for well-known self-hostable music bots (with a configurable bot ID per server), or as a more complex solution, allow servers to configure (via regex or a now-playing format builder) formats that FM Bot should listen for from a bot ID.

th0mk commented 4 weeks ago

Someone was recently working on a PR for this, I wrote my feedback on that here: https://github.com/fmbot-discord/fmbot/pull/268#pullrequestreview-1773838281

For Red music bot it would work like this:

So for example we can determine if a music bot is Red by:

  • The name starts with 'red'
  • Or it has a role called 'red music bot'

Doing a role check is fairly straightforward, for example:

if (context.User is IGuildUser guildUser)
{
    var role = context.Guild.Roles.FirstOrDefault(x => string.Equals(x.Name, "red music bot", StringComparison.OrdinalIgnoreCase));
    if (role != null && guildUser.RoleIds.Contains(role.Id))
    {

    }
}

A role is easy to add for any server staff and it would still allow custom names for the bot itself.

CyberFlameGO commented 4 weeks ago

Ohh, I was looking at that PR and it seemed a bit stale - that is pretty similar to what I had in mind for my suggestion though there are a couple more popular self-hostable bots out in the wild; JMusicBot comes to mind