Skip to content

Commit ef21073

Browse files
committed
Move activity type to utility.py
1 parent 1cd2957 commit ef21073

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

cogs/modmail.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import discord
77
from discord.ext import commands
8-
from discord.enums import ActivityType
98

109
import dateutil.parser
1110

@@ -125,19 +124,6 @@ async def move(self, ctx, *, category: discord.CategoryChannel):
125124
await thread.channel.edit(category=category)
126125
await ctx.message.add_reaction('✅')
127126

128-
@commands.command()
129-
async def status(self, ctx, activity_type: str, *, message: str):
130-
activity_type = ActivityType[activity_type]
131-
self.bot: commands.Bot
132-
activity = discord.Activity(type=activity_type, name=message)
133-
await self.bot.change_presence(activity=activity)
134-
em = discord.Embed(
135-
title='Status Changed',
136-
description=f'{ActivityType(activity_type)}: {message}.',
137-
color=discord.Color.green()
138-
)
139-
await ctx.send(embed=em)
140-
141127
async def send_scheduled_close_message(self, ctx, after, silent=False):
142128
human_delta = human_timedelta(after.dt)
143129

cogs/utility.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import discord
22
from discord.ext import commands
3+
from discord.enums import ActivityType
4+
35
import datetime
46
import traceback
57
import inspect
@@ -268,26 +270,36 @@ async def update(self, ctx):
268270

269271
await ctx.send(embed=em)
270272

271-
@commands.command(name='status', aliases=['customstatus', 'presence'])
273+
@commands.command(aliases=['presence'])
272274
@commands.has_permissions(administrator=True)
273-
async def _status(self, ctx, *, message):
274-
"""Set a custom playing status for the bot.
275-
276-
Set the message to `clear` if you want to remove the playing status.
275+
async def status(self, ctx, activity_type: str, *, message: str = ''):
277276
"""
277+
Set a custom playing status for the bot.
278278
279-
if message == 'clear':
280-
self.bot.config['status'] = None
279+
[prefix]status activity message...
280+
281+
Set the message to `clear` if you want to remove the status.
282+
"""
283+
if activity_type == 'clear':
284+
await self.bot.change_presence(activity=None)
285+
self.bot.config['activity_type'] = None
286+
self.bot.config['activity_message'] = None
281287
await self.bot.config.update()
282-
return await self.bot.change_presence(activity=None)
288+
return
283289

284-
await self.bot.change_presence(activity=discord.Game(message))
285-
self.bot.config['status'] = message
290+
activity_type = ActivityType[activity_type]
291+
self.bot: commands.Bot
292+
activity = discord.Activity(type=activity_type, name=message)
293+
await self.bot.change_presence(activity=activity)
294+
self.bot.config['activity_type'] = activity_type
295+
self.bot.config['activity_message'] = message
286296
await self.bot.config.update()
287297

288-
em = discord.Embed(title='Status Changed')
289-
em.description = message
290-
em.color = discord.Color.green()
298+
em = discord.Embed(
299+
title='Status Changed',
300+
description=f'{ActivityType(activity_type)}: {message}.',
301+
color=discord.Color.green()
302+
)
291303
await ctx.send(embed=em)
292304

293305
@commands.command()

0 commit comments

Comments
 (0)