Fix pylint issues

This commit is contained in:
ekzyis 2021-09-24 21:36:53 +02:00
parent 602a53dde4
commit 085e4459b9
2 changed files with 33 additions and 12 deletions

22
.pylintrc Normal file
View File

@ -0,0 +1,22 @@
[MASTER]
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()) + '/src'); sys.path.append(os.path.dirname(find_pylintrc()) + '/test')"
[MESSAGES CONTROL]
disable=
missing-module-docstring,
missing-class-docstring,
missing-function-docstring,
global-statement,
too-many-arguments,
too-few-public-methods,
wrong-import-position,
redefined-outer-name,
invalid-name,
no-self-use
[FORMAT]
indent-string=' '
max-line-length=160
[SIMILARITIES]
ignore-comments = no

View File

@ -1,5 +1,5 @@
import asyncio
import os import os
import sys
import discord import discord
from discord.ext import commands from discord.ext import commands
@ -28,9 +28,9 @@ class Music(commands.Cog):
"""Plays a file from the local filesystem""" """Plays a file from the local filesystem"""
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query)) 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() @commands.command()
async def yt(self, ctx, *, url): async def yt(self, ctx, *, url):
@ -38,9 +38,9 @@ class Music(commands.Cog):
async with ctx.typing(): async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop) 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() @commands.command()
async def stream(self, ctx, *, url): async def stream(self, ctx, *, url):
@ -48,9 +48,9 @@ class Music(commands.Cog):
async with ctx.typing(): async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True) 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() @commands.command()
async def volume(self, ctx, volume: int): async def volume(self, ctx, volume: int):
@ -60,7 +60,7 @@ class Music(commands.Cog):
return await ctx.send("Not connected to a voice channel.") return await ctx.send("Not connected to a voice channel.")
ctx.voice_client.source.volume = volume / 100 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() @commands.command()
async def stop(self, ctx): async def stop(self, ctx):
@ -82,13 +82,12 @@ class Music(commands.Cog):
ctx.voice_client.stop() ctx.voice_client.stop()
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), description='Relatively simple music bot example')
description='Relatively simple music bot example')
@bot.event @bot.event
async def on_ready(): async def on_ready():
print('Logged in as {0} ({0.id})'.format(bot.user)) print(f"Logged in as {bot.user} ({bot.user.id})")
print('------') print('------')
bot.add_cog(Music(bot)) bot.add_cog(Music(bot))
@ -96,6 +95,6 @@ bot.add_cog(Music(bot))
token = os.environ.get("BOT_TOKEN", None) token = os.environ.get("BOT_TOKEN", None)
if not token: if not token:
print("No token fouund in BOT_TOKEN") print("No token fouund in BOT_TOKEN")
exit(1) sys.exit(1)
bot.run(token) bot.run(token)