質問編集履歴

2

追記

2020/06/26 14:18

投稿

Winter_1214
Winter_1214

スコア11

test CHANGED
File without changes
test CHANGED
@@ -27,8 +27,6 @@
27
27
  import youtube_dl
28
28
 
29
29
  from discord.ext import tasks,commands
30
-
31
-
32
30
 
33
31
 
34
32
 
@@ -72,8 +70,6 @@
72
70
 
73
71
 
74
72
 
75
-
76
-
77
73
  @tasks.loop(seconds=5.0)
78
74
 
79
75
  async def loop():
@@ -96,6 +92,8 @@
96
92
 
97
93
  del mylist[0]
98
94
 
95
+
96
+
99
97
  client.run(MYTOKEN)
100
98
 
101
99
  ```

1

追記

2020/06/26 14:18

投稿

Winter_1214
Winter_1214

スコア11

test CHANGED
File without changes
test CHANGED
@@ -19,6 +19,42 @@
19
19
 
20
20
 
21
21
  ```python
22
+
23
+ import asyncio
24
+
25
+ import discord
26
+
27
+ import youtube_dl
28
+
29
+ from discord.ext import tasks,commands
30
+
31
+
32
+
33
+
34
+
35
+ client = commands.Bot(command_prefix = '!')
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+ @client.command()
46
+
47
+ async def play(ctx,url):
48
+
49
+ async with ctx.typing():
50
+
51
+ player = await YTDLSource.from_url(str(url),loop=asyncio.get_event_loop())
52
+
53
+ ctx.author.guild.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
54
+
55
+ await ctx.channel.send('Now playing: {}'.format(player.title))
56
+
57
+
22
58
 
23
59
  mylist = []
24
60
 
@@ -60,4 +96,6 @@
60
96
 
61
97
  del mylist[0]
62
98
 
99
+ client.run(MYTOKEN)
100
+
63
101
  ```