aboutsummaryrefslogtreecommitdiff
path: root/examples/basic_voice.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-04-04 04:40:19 -0400
committerRapptz <[email protected]>2021-04-04 07:03:53 -0400
commit9d39b135f4f84239787b0901d06a4f370a82d4bb (patch)
tree8826845cfd47eafa5c9d2ef1fcbedd36382714f4 /examples/basic_voice.py
parentBump minimum Python version to 3.8 (diff)
downloaddiscord.py-9d39b135f4f84239787b0901d06a4f370a82d4bb.tar.xz
discord.py-9d39b135f4f84239787b0901d06a4f370a82d4bb.zip
Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by default. It also changes some methods to use `yield from`.
Diffstat (limited to 'examples/basic_voice.py')
-rw-r--r--examples/basic_voice.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/basic_voice.py b/examples/basic_voice.py
index 42cea2c8..45387911 100644
--- a/examples/basic_voice.py
+++ b/examples/basic_voice.py
@@ -70,9 +70,9 @@ class Music(commands.Cog):
"""Plays a file from the local filesystem"""
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
- ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None)
+ ctx.voice_client.play(source, after=lambda e: print(f'Player error: {e}') if e else None)
- await ctx.send('Now playing: {}'.format(query))
+ await ctx.send(f'Now playing: {query}')
@commands.command()
async def yt(self, ctx, *, url):
@@ -80,9 +80,9 @@ class Music(commands.Cog):
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop)
- ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
+ ctx.voice_client.play(player, after=lambda e: print(f'Player error: {e}') if e else None)
- await ctx.send('Now playing: {}'.format(player.title))
+ await ctx.send(f'Now playing: {player.title}')
@commands.command()
async def stream(self, ctx, *, url):
@@ -90,9 +90,9 @@ class Music(commands.Cog):
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
- ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
+ ctx.voice_client.play(player, after=lambda e: print(f'Player error: {e}') if e else None)
- await ctx.send('Now playing: {}'.format(player.title))
+ await ctx.send(f'Now playing: {player.title}')
@commands.command()
async def volume(self, ctx, volume: int):
@@ -102,7 +102,7 @@ class Music(commands.Cog):
return await ctx.send("Not connected to a voice channel.")
ctx.voice_client.source.volume = volume / 100
- await ctx.send("Changed volume to {}%".format(volume))
+ await ctx.send(f"Changed volume to {volume}%")
@commands.command()
async def stop(self, ctx):