camm9909 / valheim-discord-bot

Valheim Discord bot that reports in-game players and events
34 stars 19 forks source link

update #14

Open Grim-reap3r opened 1 year ago

Grim-reap3r commented 1 year ago

Hello.

Are there any updates planned for this bot?

regards Grim

molenear commented 1 year ago

If you aren't able to run the bot it may be because of changes in discord.py. Below are the changes to vdb_main.py that have (so far) worked for me.

In vdb_main.py, find the bot declaration (line 21):

bot = commands.Bot(command_prefix=';', help_command=None)

Replace this with:

bot = commands.Bot(command_prefix=';', help_command=None, intents=discord.Intents.all())

And at the end of the file (lines 195-196):

bot.loop.create_task(mainloop(file))
bot.run(config.BOT_TOKEN)

Replace them with:

async def main():
    async with bot:
        bot.loop.create_task(mainloop(file))
        await bot.start(config.BOT_TOKEN)

asyncio.run(main())

Also, there is a fork of this at cavanpage/valheim-discord-bot that adds player join/leave announcements and the ;player command. The changes above also need to be made there.

tiagojofran commented 1 year ago

If you aren't able to run the bot it may be because of changes in discord.py. Below are the changes to vdb_main.py that have (so far) worked for me.

In vdb_main.py, find the bot declaration (line 21):

bot = commands.Bot(command_prefix=';', help_command=None)

Replace this with:

bot = commands.Bot(command_prefix=';', help_command=None, intents=discord.Intents.all())

And at the end of the file (lines 195-196):

bot.loop.create_task(mainloop(file))
bot.run(config.BOT_TOKEN)

Replace them with:

async def main():
    async with bot:
        bot.loop.create_task(mainloop(file))
        await bot.start(config.BOT_TOKEN)

asyncio.run(main())

Also, there is a fork of this at cavanpage/valheim-discord-bot that adds player join/leave announcements and the ;player command. The changes above also need to be made there.

Hi, molenear. Could you please shine some light on my issue? So, this bot used to work perfectly on my server, but a few months ago it suddenly stopped working and I just have no idea what happened. I tried reinstalling it from scratch today and modifying the lines you mentioned above, but the issues still persist. I'll list all the functionality that still works and those that don't, hoping you could help me identifying the cause of the problem:

Working fine:

Not working:

Do you have any idea how to make it work again?

stolenvw commented 1 year ago

If you aren't able to run the bot it may be because of changes in discord.py. Below are the changes to vdb_main.py that have (so far) worked for me. In vdb_main.py, find the bot declaration (line 21):

bot = commands.Bot(command_prefix=';', help_command=None)

Replace this with:

bot = commands.Bot(command_prefix=';', help_command=None, intents=discord.Intents.all())

And at the end of the file (lines 195-196):

bot.loop.create_task(mainloop(file))
bot.run(config.BOT_TOKEN)

Replace them with:

async def main():
    async with bot:
        bot.loop.create_task(mainloop(file))
        await bot.start(config.BOT_TOKEN)

asyncio.run(main())

Also, there is a fork of this at cavanpage/valheim-discord-bot that adds player join/leave announcements and the ;player command. The changes above also need to be made there.

Hi, molenear. Could you please shine some light on my issue? So, this bot used to work perfectly on my server, but a few months ago it suddenly stopped working and I just have no idea what happened. I tried reinstalling it from scratch today and modifying the lines you mentioned above, but the issues still persist. I'll list all the functionality that still works and those that don't, hoping you could help me identifying the cause of the problem:

Working fine:

  • the bot can connect to my discord server and it's being shown as online there
  • the script is reading my game server logs and it's updating both the .csv files just fine

Not working:

  • the bot is not replying to any command messages on discord
  • the bot is not posting any automatic notification messages to discord
  • the bot is not showing the current player count on a voice channel on discord

Do you have any idea how to make it work again?

Not working could be bot not having the right discord permissions,

Player count could be either discord permissions or the valheim server running with crossplay

tiagojofran commented 1 year ago

Not working could be bot not having the right discord permissions,

Player count could be either discord permissions or the valheim server running with crossplay

Hi. So, I've activated all the possible permissions during my tests and nothing worked, I don't think that is the issue in my case. And crossplay is not enabled on my server.

I just noticed you have an updated/upgraded version of the bot, I might just try yours to see how it behaves on my server :)

molenear commented 1 year ago

@stolenvw are you getting any error messages? for example, here is how I launch my bot:

cd /home/username/valheim-discord-bot/code
python3.8 _logsubprocess.py > /home/username/valheim-discord-bot/log-logprocess.log > /dev/null 2>&1 &
python3.8 vdb_main.py config.py -logfile /home/username/vh2022/log/console/vhserver-console.log > /home/username/valheim-discord-bot/log-bot.log 2>&1 &

This launches both scripts as background processes, which will not output anything to the main server console, instead redirecting that to the file /home/username/valheim-discord-bot/log-bot.log. Looking at that file should give clues as to why things aren't working.

And @tiagojofran - the updated bot is by @cavanpage - I have nothing to do with it beyond liking the improvements made.

I also ran a diff of my working vdb_main.py against both ckbaudio's and cavanpage's versions. The only differences were the changes I documented above. I would check your Discord settings, both bot/channel and your Discord application settings (https://discord.com/developers/applications).

stolenvw commented 1 year ago

@stolenvw are you getting any error messages? for example, here is how I launch my bot:

cd /home/username/valheim-discord-bot/code
python3.8 _logsubprocess.py > /home/username/valheim-discord-bot/log-logprocess.log > /dev/null 2>&1 &
python3.8 vdb_main.py config.py -logfile /home/username/vh2022/log/console/vhserver-console.log > /home/username/valheim-discord-bot/log-bot.log 2>&1 &

This launches both scripts as background processes, which will not output anything to the main server console, instead redirecting that to the file /home/username/valheim-discord-bot/log-bot.log. Looking at that file should give clues as to why things aren't working.

And @tiagojofran - the updated bot is by @cavanpage - I have nothing to do with it beyond liking the improvements made.

I also ran a diff of my working vdb_main.py against both ckbaudio's and cavanpage's versions. The only differences were the changes I documented above. I would check your Discord settings, both bot/channel and your Discord application settings (https://discord.com/developers/applications).

I dont use this bot anymore, i use a complete rewrite that i did

tiagojofran commented 1 year ago

@stolenvw are you getting any error messages? for example, here is how I launch my bot:

cd /home/username/valheim-discord-bot/code
python3.8 _logsubprocess.py > /home/username/valheim-discord-bot/log-logprocess.log > /dev/null 2>&1 &
python3.8 vdb_main.py config.py -logfile /home/username/vh2022/log/console/vhserver-console.log > /home/username/valheim-discord-bot/log-bot.log 2>&1 &

This launches both scripts as background processes, which will not output anything to the main server console, instead redirecting that to the file /home/username/valheim-discord-bot/log-bot.log. Looking at that file should give clues as to why things aren't working.

And @tiagojofran - the updated bot is by @cavanpage - I have nothing to do with it beyond liking the improvements made.

I also ran a diff of my working vdb_main.py against both ckbaudio's and cavanpage's versions. The only differences were the changes I documented above. I would check your Discord settings, both bot/channel and your Discord application settings (https://discord.com/developers/applications).

I see, thanks for the reply anyway. I installed @stolenvw's version and so far it's working really well on my server, plus it has so many new cool functionality, my friends and I are enjoying it so much now, I can't recommend it enough. Thanks for the quality work you've made on updating and improving the project, stolenvw.