This commit is contained in:
Marco Thomas
2022-12-17 23:20:10 +01:00
commit b648c05316
5 changed files with 69 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
settings.json

13
README.md Normal file
View File

@@ -0,0 +1,13 @@
# 🗿
Requires `ffmpeg`. Install requirements: `python3 -m pip -U -r requirements.txt`.
## Settings
Requires a `settings.json`:
```json
{
"prefix": "!",
"token": "42"
}
```

54
main.py Normal file
View File

@@ -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'])

BIN
moai.mp3 Normal file

Binary file not shown.

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
discord.py[voice]