| 
1 | 1 | import discord  | 
2 | 2 | from discord.ext import commands  | 
 | 3 | +from discord.enums import ActivityType  | 
 | 4 | + | 
3 | 5 | import datetime  | 
4 | 6 | import traceback  | 
5 | 7 | import inspect  | 
@@ -265,30 +267,50 @@ async def update(self, ctx):  | 
265 | 267 |             else:  | 
266 | 268 |                 em.description = 'Already up to date with master repository.'  | 
267 | 269 | 
 
  | 
268 |  | -              | 
269 | 270 |         await ctx.send(embed=em)  | 
270 | 271 | 
 
  | 
271 |  | -    @commands.command(name='status', aliases=['customstatus', 'presence'])  | 
 | 272 | +    @commands.command(aliases=['presence'])  | 
272 | 273 |     @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.  | 
 | 274 | +    async def activity(self, ctx, activity_type: str, *, message: str = ''):  | 
277 | 275 |         """  | 
 | 276 | +        Set a custom activity for the bot.  | 
 | 277 | +
  | 
 | 278 | +        Possible activity types: `playing`, `streaming`, `listening`, `watching`, `clear`  | 
278 | 279 | 
  | 
279 |  | -        if message == 'clear':  | 
280 |  | -            self.bot.config['status'] = None  | 
 | 280 | +        When activity type is set to `clear`, the current activity is removed.  | 
 | 281 | +        """  | 
 | 282 | +        if activity_type == 'clear':  | 
 | 283 | +            await self.bot.change_presence(activity=None)  | 
 | 284 | +            self.bot.config['activity_type'] = None  | 
 | 285 | +            self.bot.config['activity_message'] = None  | 
281 | 286 |             await self.bot.config.update()  | 
282 |  | -            return await self.bot.change_presence(activity=None)  | 
 | 287 | +            em = discord.Embed(  | 
 | 288 | +                title='Activity Removed',  | 
 | 289 | +                color=discord.Color.green()  | 
 | 290 | +            )  | 
 | 291 | +            return await ctx.send(embed=em)  | 
 | 292 | + | 
 | 293 | +        if not message:  | 
 | 294 | +            raise commands.UserInputError  | 
283 | 295 | 
 
  | 
284 |  | -        await self.bot.change_presence(activity=discord.Game(message))  | 
285 |  | -        self.bot.config['status'] = message  | 
 | 296 | +        try:  | 
 | 297 | +            activity_type = ActivityType[activity_type]  | 
 | 298 | +        except KeyError:  | 
 | 299 | +            raise commands.UserInputError  | 
 | 300 | + | 
 | 301 | +        url = 'https://www.twitch.tv/discord-modmail/' if activity_type == ActivityType.streaming else None  | 
 | 302 | +        activity = discord.Activity(type=activity_type, name=message, url=url)  | 
 | 303 | +        await self.bot.change_presence(activity=activity)  | 
 | 304 | +        self.bot.config['activity_type'] = activity_type  | 
 | 305 | +        self.bot.config['activity_message'] = message  | 
286 | 306 |         await self.bot.config.update()  | 
287 | 307 | 
 
  | 
288 |  | -        em = discord.Embed(title='Status Changed')  | 
289 |  | -        em.description = message  | 
290 |  | -        em.color = discord.Color.green()  | 
291 |  | -        await ctx.send(embed=em)  | 
 | 308 | +        em = discord.Embed(  | 
 | 309 | +            title='Activity Changed',  | 
 | 310 | +            description=f'Current activity is: {activity_type.name} {message}.',  | 
 | 311 | +            color=discord.Color.green()  | 
 | 312 | +        )  | 
 | 313 | +        return await ctx.send(embed=em)  | 
292 | 314 | 
 
  | 
293 | 315 |     @commands.command()  | 
294 | 316 |     @trigger_typing  | 
 | 
0 commit comments