Rename main.py to moai.py

This commit is contained in:
Marco Thomas
2022-12-26 18:17:33 +01:00
parent f39c96f2c4
commit bcaacc7131
2 changed files with 2 additions and 2 deletions

58
moai.py Normal file
View File

@@ -0,0 +1,58 @@
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.all()
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('🗿')
async def play(ctx, src: str):
# delete message
await ctx.message.delete()
vc = ctx.author.voice.channel
if vc:
connection = await vc.connect()
connection.play(discord.FFmpegPCMAudio(source=src))
# 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.command()
async def moai(ctx):
await play(ctx, "audio/moai.mp3")
bot.run(settings['token'])