-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (36 loc) · 1.35 KB
/
Copy pathmain.py
File metadata and controls
47 lines (36 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import discord
import requests, asyncio, platform, os
from ctypes.util import find_library
discord.opus.load_opus(find_library("opus"))
# Make sure we're in the bot's root dir
os.chdir(os.path.dirname(os.path.realpath(__file__)))
with open("token.txt", "r") as token_file:
# We have to grab the first line
# because a newline in the string will
# cause cryptic errors, and nobody
# likes those
lines = token_file.read().splitlines()
global TOKEN
TOKEN = lines[0]
client = discord.Client()
commands = {}
@client.event
async def on_message(message):
# No self-replying
if message.author == client.user:
return
if message.content == "!dedede":
with open("dedede.jpg", "rb") as dedede_jpg:
await client.send_file(message.channel, dedede_jpg, filename="Dedede.jpg", content="All hail our lord and savior")
return
if message.content.startswith("!d"):
args = message.content[3:].split(" ")
if args[0] in commands.keys():
commands[args[0]](args[1:])
@client.event
async def on_ready():
print("Logged in as " + client.user.name)
voice = await client.join_voice_channel(client.get_channel("477643870042325007"))
player = voice.create_ffmpeg_player("hypno.flac", before_options="-fflags +genpts -stream_loop -1 ")
player.start()
client.run(TOKEN)