Setup
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
settings.json
|
||||
13
README.md
Normal file
13
README.md
Normal 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
54
main.py
Normal 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'])
|
||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
discord.py[voice]
|
||||
Reference in New Issue
Block a user