use bradme's code
This commit is contained in:
parent
62b19d91de
commit
e767fb564b
6 changed files with 39 additions and 7 deletions
|
@ -1 +0,0 @@
|
|||
config.ini
|
|
@ -1,9 +1,6 @@
|
|||
[radio]
|
||||
token = "radio_bot_token"
|
||||
channel = "channel_id"
|
||||
name = "Example Radio"
|
||||
url = "http://example.net"
|
||||
|
||||
[voice]
|
||||
passes = 2
|
||||
bitrate = 44100
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
# Internal
|
||||
config/config.ini
|
||||
.env
|
|
@ -9,6 +9,4 @@ RUN pip --no-cache-dir install \
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
ENV CONFIG_FILE="./config/config.ini"
|
||||
|
||||
COPY . /app
|
|
@ -5,4 +5,7 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
command: python3 main.py
|
||||
restart: always
|
||||
|
|
35
main.py
Normal file
35
main.py
Normal 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
|
Loading…
Reference in a new issue