-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord_basic.py
82 lines (63 loc) · 2.15 KB
/
discord_basic.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import discord
import youtube_dl
import nest_asyncio
from discord.ext import commands
from to import Token , ydl_opts , func1 , func2
from cro import temper , s_r
from discord.voice_client import VoiceClient
from discord import FFmpegPCMAudio
from youtube_dl import YoutubeDL
nest_asyncio.apply()
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='!',intents=discord.Intents.all())
ydl = YoutubeDL(ydl_opts)
@bot.event
async def on_ready():
print('연결이 완료되었습니다.')
await bot.change_presence(status=discord.Status.online, activity=None)
@bot.command()
async def Hello(ctx):
await ctx.send('Hello!')
@bot.command()
async def Play(ctx, *, song_title):
# search for the song on YouTube
await ctx.send( song_title + " 재생")
ydl_opts = {
'default_search': 'ytsearch',
'quiet': True,
}
ydl = youtube_dl.YoutubeDL(ydl_opts)
info = ydl.extract_info(song_title, download=False)
song_url = info['entries'][0]['webpage_url']
voice_client = await ctx.author.voice.channel.connect()
player = discord.FFmpegPCMAudio(song_url)
player = discord.PCMVolumeTransformer(player)
voice_client.play(player, after=lambda: print('done'))
@bot.command()
async def Leave(ctx):
await ctx.send( "재생 종료")
await bot.voice_clients[0].disconnect()
@bot.command()
async def Menu(ctx):
d = func1()
output = d
await ctx.send(output + "추천" )
@bot.command()
async def Help(ctx):
commands = [
("hello", "인사를 합니다."),
("cody", "온도와 날씨, 그리고 거기에 맞는 옷을 추천합니다."),
("Menu" , "메뉴를 추천해줍니다.") ,
("Play title", "현재 들어가 있는 보이스 채널에서 title을 재생합니다"),
("Leave", "음악을 종료합니다."), ]
output = "\n".join([f"!{command}: {description}" for command, description in commands])
await ctx.send(output)
print( temper , s_r )
@bot.command()
async def Cody(ctx):
await ctx.send( "날씨 : " + temper + "°C " + s_r + "\n" )
cmp = float(temper)
output = func2( cmp )
await ctx.send( output )
bot.run(Token)