commit b648c0531691ded18a350574efef553d4c8d541a Author: Marco Thomas Date: Sat Dec 17 23:20:10 2022 +0100 Setup diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e38da20 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +settings.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..86a7853 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# 🗿 + +Requires `ffmpeg`. Install requirements: `python3 -m pip -U -r requirements.txt`. + +## Settings +Requires a `settings.json`: + +```json +{ + "prefix": "!", + "token": "42" +} +``` diff --git a/main.py b/main.py new file mode 100644 index 0000000..0ac123c --- /dev/null +++ b/main.py @@ -0,0 +1,54 @@ +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']) diff --git a/moai.mp3 b/moai.mp3 new file mode 100644 index 0000000..12634d9 Binary files /dev/null and b/moai.mp3 differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7d0cb38 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +discord.py[voice]