from discord.ext import commands import discord import json import time try: with open("settings.json", "r") as f: settings = json.loads(f.read()) except Exception as e: print(e) intents = discord.Intents.default() intents.message_content = True bot = commands.Bot( command_prefix=settings['prefix'], description='Moai', intents=intents) @bot.event async def on_ready(): bot.AppInfo = await bot.application_info() # activity_name = f"with stones | {settings['prefix']}moai" activity_name = "with stones" activity = discord.Activity( name=activity_name, type=discord.ActivityType.playing) await bot.change_presence(activity=activity) @bot.command() async def stone(ctx): await ctx.send('🗿') @bot.command() async def moai(ctx): # delete message await ctx.message.delete() vc = ctx.author.voice.channel if vc: connection = await vc.connect() connection.play(discord.FFmpegPCMAudio(source="moai.mp3")) # instantly disconnect, after audio is done playing while connection.is_playing(): time.sleep(0.1) await connection.disconnect() else: print("User is not in a channel!") bot.run(settings['token'])