fix intents

This commit is contained in:
Milka64 2023-12-13 21:22:50 +01:00
parent a9cc9e20c0
commit 5792a88911

View file

@ -53,6 +53,7 @@ class Mybot(discord.Client):
def __init__( def __init__(
self, self,
bot, bot,
intents=None,
gl_url=None, gl_url=None,
gl_token=None, gl_token=None,
gif_token=None, gif_token=None,
@ -181,6 +182,7 @@ class Mybot(discord.Client):
@commands.command(help='check if bot always online') @commands.command(help='check if bot always online')
async def ping(self, message): async def ping(self, message):
print('trying to repondre')
await message.channel.send('pong') await message.channel.send('pong')
@commands.command(help='Restart Bot') @commands.command(help='Restart Bot')
@ -601,7 +603,7 @@ def get_word(word_type):
#Le do[main]e de Kabot. #Le do[main]e de Kabot.
def main(): def main():
intents = discord.Intents.default() intents = discord.Intents.all()
intents.members = True intents.members = True
intents.messages = True intents.messages = True
logger.info("Initialisation de Kabot") logger.info("Initialisation de Kabot")
@ -648,6 +650,19 @@ def main():
intents=intents, intents=intents,
audio_path="/home/mika/kabot-audio", audio_path="/home/mika/kabot-audio",
) )
bot.add_cog(
Mybot(
bot,
intents = intents,
gl_url=gl_url,
gl_token=gl_token,
gif_token=gif_token,
audio_path="/home/mika/kabot-audio",
nickname=nickname,
voice_channel=voice_channel,
text_channel=text_channel,
)
)
test = False test = False
if "test" in argv[-1]: if "test" in argv[-1]:
@ -690,7 +705,7 @@ def main():
cmd = bot.get_command(command_name) cmd = bot.get_command(command_name)
await cmd.invoke(message) await cmd.invoke(message)
else: else:
with message.channel.typing(): async with message.channel.typing():
if "http" in response: if "http" in response:
await asyncio.sleep(len(response) / 8) await asyncio.sleep(len(response) / 8)
else: else:
@ -698,7 +713,7 @@ def main():
await message.channel.send(response) await message.channel.send(response)
await bot.process_commands(message) await bot.process_commands(message)
@bot.command() @bot.command(help='demerde toi')
async def join(interaction: discord.Interaction): async def join(interaction: discord.Interaction):
channel = [x for x in bot.get_all_channels() if x.name == voice_channel][0] channel = [x for x in bot.get_all_channels() if x.name == voice_channel][0]
await channel.connect() await channel.connect()
@ -711,10 +726,10 @@ def main():
user = interaction.message.author.name user = interaction.message.author.name
print(user) print(user)
try: try:
audio_file = random.choice([f for f in os.listdir(bot.audio_path + '/%s/' % user) if f.endswith('.mp3')]) audio_file = random.choice([f for f in os.listdir(audio_path + '/%s/' % user) if f.endswith('.mp3')])
audio_file = bot.audio_path + '/%s/' % user + audio_file audio_file = audio_path + '/%s/' % user + audio_file
except: except:
audio_file = random.choice([f"{f}" for f in Path(bot.audio_path + '/').glob('**/*.mp3')]) audio_file = random.choice([f"{f}" for f in Path(audio_path + '/').glob('**/*.mp3')])
bot.sounds.append((audio_file, interaction)) bot.sounds.append((audio_file, interaction))
@bot.event @bot.event
@ -764,19 +779,8 @@ def main():
await joke.invoke(ctx) await joke.invoke(ctx)
@bot.command(help='check if bot always online') @bot.command(help='check if bot always online')
async def ping(ctx): async def ping(ctx):
print("trying to repondre again")
await ctx.channel.send('pong') await ctx.channel.send('pong')
bot.add_cog(
Mybot(
bot,
gl_url=gl_url,
gl_token=gl_token,
gif_token=gif_token,
audio_path=audio_path,
nickname=nickname,
voice_channel=voice_channel,
text_channel=text_channel,
)
)
bot.run(token) bot.run(token)