Update bot.py

- Add new intents
- Add new function 'on_ready'
This commit is contained in:
trueold89 2024-06-03 19:02:19 +03:00
parent b07af72901
commit 9d10ffc70f
Signed by: trueold89
GPG Key ID: C122E85DD49E6B30
1 changed files with 17 additions and 2 deletions

View File

@ -2,7 +2,8 @@
from hellmbot.env import ENV from hellmbot.env import ENV
from hellmbot.db import ServersDB from hellmbot.db import ServersDB
from discord import Intents, Member, VoiceState from discord import Intents, Member, VoiceState, Permissions
from discord.utils import oauth_url
from discord.ext import commands from discord.ext import commands
@ -17,6 +18,7 @@ def init_bot() -> commands.Bot:
:return: Bot class object :return: Bot class object
""" """
intents = Intents.default() intents = Intents.default()
intents.members = True
intents.message_content = True intents.message_content = True
return commands.Bot(command_prefix="/", intents=intents) return commands.Bot(command_prefix="/", intents=intents)
@ -32,6 +34,19 @@ def start() -> None:
bot.run(ENV.BOT_TOKEN.fget(None)) bot.run(ENV.BOT_TOKEN.fget(None))
@bot.event
async def on_ready() -> None:
"""
Displays a link to add a bot to the server
"""
client_id = ENV.CLIENT_ID.fget(None)
invite = oauth_url(client_id, permissions=Permissions(
manage_channels=True,
move_members=True
))
print(f"Your bot invite link: {invite}")
@bot.command() @bot.command()
async def create(ctx: commands.Context) -> None: async def create(ctx: commands.Context) -> None:
""" """
@ -54,7 +69,7 @@ user_before_channels = {}
@bot.event @bot.event
async def on_voice_state_update(member: Member, before: VoiceState, after: VoiceState): async def on_voice_state_update(member: Member, before: VoiceState, after: VoiceState) -> None:
""" """
Moves the user through the group channels if the user has been connected to one of them Moves the user through the group channels if the user has been connected to one of them