use bradme's code

This commit is contained in:
Daniel afx 2022-03-24 01:27:00 +02:00
parent 62b19d91de
commit e767fb564b
6 changed files with 39 additions and 7 deletions

View file

@ -1 +0,0 @@
config.ini

View file

@ -1,9 +1,6 @@
[radio]
token = "radio_bot_token" token = "radio_bot_token"
channel = "channel_id" channel = "channel_id"
name = "Example Radio" name = "Example Radio"
url = "http://example.net" url = "http://example.net"
[voice]
passes = 2 passes = 2
bitrate = 44100 bitrate = 44100

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
# Internal # Internal
config/config.ini .env

View file

@ -9,6 +9,4 @@ RUN pip --no-cache-dir install \
WORKDIR /app WORKDIR /app
ENV CONFIG_FILE="./config/config.ini"
COPY . /app COPY . /app

View file

@ -5,4 +5,7 @@ services:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
env_file:
- .env
command: python3 main.py
restart: always restart: always

35
main.py Normal file
View file

@ -0,0 +1,35 @@
import discord
from discord.ext.commands import Bot
bot_version = "0.1"
client = Bot(command_prefix="!")
isPlaying = False
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content == 'version':
await message.channel.send('radiobot ' + bot_version)
@client.event
async def on_voice_state_update(self, member, before, after):
clients_before = len(before.channel.members)
# If nobody in the channel based on before, invoke join the channel
if clients_before == 0:
self.voiceChannel = await after.channel.connect()
# if after join channel members > 0, join the channel
if clients_before == 1:
print("gg")
await self.voiceChannel.disconnect()
client = MyClient()
client.run('') # Get token for this shit