Add files via upload
This commit is contained in:
parent
175e130c0c
commit
c4c9fa3560
9 changed files with 134 additions and 0 deletions
1
Procfile
Normal file
1
Procfile
Normal file
|
@ -0,0 +1 @@
|
|||
worker: python catmusicbot.py
|
60
catmusicbot.py
Normal file
60
catmusicbot.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
import os
|
||||
import asyncio
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import yandex_music
|
||||
|
||||
# Add bot to a server:
|
||||
# https://discord.com/api/oauth2/authorize?client_id=861599847441104926&permissions=2184277249&scope=bot
|
||||
|
||||
# Options
|
||||
token = 'ODYxNTk5ODQ3NDQxMTA0OTI2.YOMJYw.8Q6ZIfp_hr4_TCJYOwoAebhPAI0'
|
||||
bot = commands.Bot(command_prefix='/')
|
||||
# Setting up YandexMusic
|
||||
ymcl = yandex_music.Client.from_credentials('achtest22@yandex.ru', 'tEs#t22')
|
||||
|
||||
# Command /catplay <search query>
|
||||
@bot.command(name='catplay', description='Plays the music in a voice channel')
|
||||
async def catplay(ctx, *args):
|
||||
|
||||
# Get the server (guild) and the music channel
|
||||
curserver = ctx.guild
|
||||
music_channel = None
|
||||
for vch in curserver.voice_channels:
|
||||
if (vch.name == 'Музыка'):
|
||||
music_channel = vch
|
||||
|
||||
if (music_channel != None):
|
||||
|
||||
song_query = ' '.join(args)
|
||||
await ctx.send(':mag: **Searching...**')
|
||||
|
||||
song = ymcl.search(song_query, True, 'track').tracks.results[0]
|
||||
song.download(str(song.id) + '.mp3', 'mp3')
|
||||
artist = ''
|
||||
|
||||
# Joining artists into a string
|
||||
for artist_obj in song.artists:
|
||||
artist += artist_obj.name + ', '
|
||||
# Removing a comma in the end of the string
|
||||
artist = artist[:len(artist)-2]
|
||||
|
||||
# Beautiful notification
|
||||
notif = discord.Embed(color=0xe3813e, title='Playing:', description=f'{artist} - {song.title}')
|
||||
notif.set_image(url=song.cover_uri)
|
||||
|
||||
# Connecting to the voice channel
|
||||
sp = await music_channel.connect()
|
||||
# Stopping previously playing music
|
||||
if (sp.is_playing()):
|
||||
sp.stop()
|
||||
# Playing music to the voice channel
|
||||
sp.play(discord.FFmpegPCMAudio(source=(str(song.id) + '.mp3')), after=None)
|
||||
await ctx.send(embed=notif)
|
||||
while (sp.is_playing()):
|
||||
await asyncio.sleep(1)
|
||||
sp.stop()
|
||||
os.remove(str(song.id) + '.mp3')
|
||||
|
||||
# Starting bot after setup
|
||||
bot.run(token)
|
BIN
logo/cat-006.png
Normal file
BIN
logo/cat-006.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 MiB |
BIN
logo/catmusic.png
Normal file
BIN
logo/catmusic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 MiB |
BIN
logo/catmusic.xcf
Normal file
BIN
logo/catmusic.xcf
Normal file
Binary file not shown.
BIN
logo/license.pdf
Normal file
BIN
logo/license.pdf
Normal file
Binary file not shown.
46
logo/playlist.svg
Normal file
46
logo/playlist.svg
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 405.333 405.333" style="enable-background:new 0 0 405.333 405.333;" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<rect x="0" y="53.333" width="256" height="42.667"/>
|
||||
<rect x="0" y="138.667" width="256" height="42.667"/>
|
||||
<path d="M298.667,53.333v174.613c-6.72-2.453-13.76-3.947-21.333-3.947c-35.307,0-64,28.693-64,64c0,35.307,28.693,64,64,64
|
||||
c35.307,0,64-28.693,64-64V96h64V53.333H298.667z"/>
|
||||
<rect x="0" y="224" width="170.667" height="42.667"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 939 B |
26
requirements.txt
Normal file
26
requirements.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
aiohttp==3.7.4.post0
|
||||
async-timeout==3.0.1
|
||||
attrs==21.2.0
|
||||
beautifulsoup4==4.9.3
|
||||
certifi==2020.12.5
|
||||
cffi==1.14.5
|
||||
chardet==4.0.0
|
||||
click==7.1.2
|
||||
discord.py==1.7.3
|
||||
idna==2.10
|
||||
multidict==5.1.0
|
||||
numpy==1.20.2
|
||||
Pillow==8.2.0
|
||||
pycparser==2.20
|
||||
pygal==2.4.0
|
||||
pygame==2.0.1
|
||||
PyNaCl==1.4.0
|
||||
PySocks==1.7.1
|
||||
requests==2.25.1
|
||||
six==1.15.0
|
||||
soupsieve==2.2.1
|
||||
typing-extensions==3.10.0.0
|
||||
urllib3==1.26.3
|
||||
wikipedia==1.4.0
|
||||
yandex-music==1.0.0
|
||||
yarl==1.6.3
|
1
runtime.txt
Normal file
1
runtime.txt
Normal file
|
@ -0,0 +1 @@
|
|||
python-3.9.5
|
Loading…
Add table
Reference in a new issue