Skip to content

Commit 23c6919

Browse files
committed
Bumpped version and formatted code
1 parent 1b4cbb4 commit 23c6919

7 files changed

Lines changed: 49 additions & 29 deletions

File tree

cogs/commandlistener.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,23 @@ async def on_ready(self):
5050
# Sends message to mods, when bot is online
5151
print("Now Online")
5252
await self.utils.sendModsMessage(
53-
"Bot is now online.\nVersion:\tDiscordBot DataBot v2.3.1"
53+
"Bot is now online.\nVersion:\tDiscordBot DataBot v2.4.0"
5454
)
5555
# Sets the bot's presence to "Online" or "Do not Disturb" to indicate if it's logging or not.
5656
if self.ch.getFromConfig("log") == "True":
57-
await self.bot.change_presence(status=discord.Status.online, activity=discord.Game(str(self.ch.getFromConfig("command_prefix")) + "help"))
58-
else:
59-
await self.bot.change_presence(status=discord.Status.dnd, activity=discord.Game(str(self.ch.getFromConfig("command_prefix")) + "help"))
57+
await self.bot.change_presence(
58+
status=discord.Status.online,
59+
activity=discord.Game(
60+
str(self.ch.getFromConfig("command_prefix")) + "help"
61+
),
62+
)
63+
else:
64+
await self.bot.change_presence(
65+
status=discord.Status.dnd,
66+
activity=discord.Game(
67+
str(self.ch.getFromConfig("command_prefix")) + "help"
68+
),
69+
)
6070

6171
# When a member joins a guild
6272
@commands.Cog.listener()
@@ -263,7 +273,7 @@ async def on_voice_state_update(self, member, before, after):
263273
if notFirstVoiceChannel:
264274
lastChannel = max(
265275
notFirstVoiceChannel,
266-
key=lambda c: int(c.name[len(channelWithoutNumber):]),
276+
key=lambda c: int(c.name[len(channelWithoutNumber) :]),
267277
)
268278

269279
# Removes channel from blacklist if necessary
@@ -310,11 +320,11 @@ async def on_voice_state_update(self, member, before, after):
310320
channel
311321
for channel in allChannel
312322
if after.channel.name[:nameIndex] in channel.name
313-
and channel.name[len(channelWithoutNumber):].isdigit()
323+
and channel.name[len(channelWithoutNumber) :].isdigit()
314324
]
315325
# Get all numbers in the end of voiceChannelsWithName
316326
numbersOfChannels = [
317-
int(channel.name[len(channelWithoutNumber):])
327+
int(channel.name[len(channelWithoutNumber) :])
318328
for channel in voiceChanelsWithName
319329
]
320330
lowestFreeID = min(
@@ -326,7 +336,7 @@ async def on_voice_state_update(self, member, before, after):
326336
)
327337

328338
channelWithNumberBefore = find(
329-
lambda c: c.name[-len(str(lowestFreeID - 1)):]
339+
lambda c: c.name[-len(str(lowestFreeID - 1)) :]
330340
== str(lowestFreeID - 1),
331341
voiceChanelsWithName,
332342
)

cogs/commandowner.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,21 @@ async def startlog(self, ctx):
7474
guildName = str(self.bot.get_guild(guildID))
7575
await self.utils.log(f"Start to log users from Server:\n\t{guildName}", 2)
7676
# Sets the bot's presence to "Online" to indicate it's logging.
77-
await self.bot.change_presence(status=discord.Status.online, activity=discord.Game(str(self.ch.getFromConfig("command_prefix")) + "help"))
77+
await self.bot.change_presence(
78+
status=discord.Status.online,
79+
activity=discord.Game(
80+
str(self.ch.getFromConfig("command_prefix")) + "help"
81+
),
82+
)
7883
else:
7984
await ctx.send("Bot is logging. Logging state: True")
8085
# Sets the bot's presence to "Online" to indicate it's logging.
81-
await self.bot.change_presence(status=discord.Status.online, activity=discord.Game(str(self.ch.getFromConfig("command_prefix")) + "help"))
86+
await self.bot.change_presence(
87+
status=discord.Status.online,
88+
activity=discord.Game(
89+
str(self.ch.getFromConfig("command_prefix")) + "help"
90+
),
91+
)
8292

8393
@commands.command(
8494
name="stoplog",
@@ -96,7 +106,12 @@ async def stoplog(self, ctx):
96106
self.ch.saveConfig()
97107
await self.utils.log(f"Stopped to log users from Server:\n\t{guildName}", 2)
98108
# Sets the bot's presence to "Do not Disturb" to indicate it's not logging.
99-
await self.bot.change_presence(status=discord.Status.dnd, activity=discord.Game(str(self.ch.getFromConfig("command_prefix")) + "help"))
109+
await self.bot.change_presence(
110+
status=discord.Status.dnd,
111+
activity=discord.Game(
112+
str(self.ch.getFromConfig("command_prefix")) + "help"
113+
),
114+
)
100115
else:
101116
await ctx.send("Bot is NOT logging. Logging state: False")
102117

cogs/commandsubroutine.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,15 @@ def addMembersOnlineVoiceXp(self, serverid):
235235
]
236236
# Total all connected members
237237
for channel in voiceChanels:
238-
membersInChannel = [
239-
member for member in channel.members if not member.bot]
238+
membersInChannel = [member for member in channel.members if not member.bot]
240239
# Check if more than one person is in channel
241240
if len(membersInChannel) >= 2:
242241
membersNotMutedOrBot = [
243242
member
244243
for member in membersInChannel
245244
if not (member.voice.self_mute or member.bot)
246245
]
247-
self.uh.addAllUserVoice(
248-
[member.id for member in membersNotMutedOrBot])
246+
self.uh.addAllUserVoice([member.id for member in membersNotMutedOrBot])
249247
# Extra XP
250248
membersStreamOrVideo = [
251249
member

cogs/commandsubserver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,7 @@ def get_all_subserver_roles(self):
659659
]
660660
# Sort by subserver name. '+ r.name[1]' is for sorting sub roles on top of
661661
# subway roles, since '+ r.name[1]' is 'u' or 'w'.
662-
sorted_roles = sorted(
663-
sub_roles, key=lambda r: r.name.split("-")[1] + r.name[1])
662+
sorted_roles = sorted(sub_roles, key=lambda r: r.name.split("-")[1] + r.name[1])
664663
if not sorted_roles:
665664
return []
666665
# Data pattern: [(sub-a, sw-a), ...]

helpfunctions/decorators.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ def decorator(func):
132132
def wrapper(*args, **kwargs):
133133
# Wrapper for inputs in func
134134
dm = isinstance(args[1].channel, discord.channel.DMChannel)
135-
if dm or not (
136-
args[1].channel.id in items or args[1].channel.name in items
137-
):
135+
if dm or not (args[1].channel.id in items or args[1].channel.name in items):
138136
return func(*args, **kwargs)
139137
return passFunc()
140138

helpfunctions/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ def getLeaderboardPageBy(self, page, sortBy):
206206
nick = "".join(
207207
[c for c in member.display_name if c not in UNICODE_EMOJI["en"]]
208208
)
209-
name = "".join(
210-
[c for c in member.name if c not in UNICODE_EMOJI["en"]]
211-
)
209+
name = "".join([c for c in member.name if c not in UNICODE_EMOJI["en"]])
212210
else:
213211
# When user is not in guild.
214212
nick = "Not on guild"
@@ -237,9 +235,13 @@ def _get_leaderboard_pageFirstRank(leaderboard_page: str) -> int:
237235
Determines the first rank number on leaderboard page. Used to identify the number of the current page.
238236
"""
239237
leaderboard_search_pattern = re.compile("```as\n *[0-9]+\.")
240-
leaderboard_search_match = leaderboard_search_pattern.search(str(leaderboard_page))
238+
leaderboard_search_match = leaderboard_search_pattern.search(
239+
str(leaderboard_page)
240+
)
241241
# Check if match was found.
242-
leaderboard_search_result = "" if not leaderboard_search_match else leaderboard_search_match.group(0)
242+
leaderboard_search_result = (
243+
"" if not leaderboard_search_match else leaderboard_search_match.group(0)
244+
)
243245
pageFirstRank = int(str(leaderboard_search_result)[6:-1])
244246
return pageFirstRank
245247

test/datahandler/testUserHandle.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class TestUserHandle(unittest.TestCase):
1515
def test_isInData(self):
1616
for i in range(1, 11):
1717
self.assertTrue(
18-
self.userHandler.isInData(
19-
i), f"User with ID {i} should be in database."
18+
self.userHandler.isInData(i), f"User with ID {i} should be in database."
2019
)
2120
self.assertTrue(
2221
self.userHandler.isInData(str(i)),
@@ -26,8 +25,7 @@ def test_isInData(self):
2625
self.userHandler.isInData(0), "User with ID 0 should not be in database."
2726
)
2827
self.assertFalse(
29-
self.userHandler.isInData(
30-
11), "User with ID 11 should not be in database."
28+
self.userHandler.isInData(11), "User with ID 11 should not be in database."
3129
)
3230
self.assertFalse(
3331
self.userHandler.isInData(100),

0 commit comments

Comments
 (0)