Skip to content

Commit

Permalink
Slash command support for setting activity
Browse files Browse the repository at this point in the history
  • Loading branch information
eibex committed Nov 18, 2021
1 parent df0d692 commit 0e59b9d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
47 changes: 28 additions & 19 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,32 +1225,41 @@ async def set_colour(


@commands.is_owner()
@bot.command(name="activity")
async def add_activity(ctx):
new_activity = ctx.message.content[(len(prefix) + len("activity")) :].strip()
if not activity:
await ctx.send(response.get("activity-info"))
@settings_group.command(name="activity", brief=response.get("brief-settings-activity"))
async def change_activity(
ctx,
action: str = commands.Option(description=response.get("settings-activity-option-action")),
activity: str = commands.Option(None, description=response.get("settings-activity-option-activity"))
):
if action.lower() == "add" and activity:
if "," in activity:
await ctx.send(response.get("activity-no-commas"))

elif "," in new_activity:
await ctx.send(response.get("activity-no-commas"))
else:
activities.add(activity)
await ctx.send(response.get("activity-success").format(new_activity=activity))

else:
activities.add(new_activity)
await ctx.send(response.get("activity-success").format(new_activity=new_activity))
elif action.lower() == "list":
if activities.activity_list:
formatted_list = []
for item in activities.activity_list:
formatted_list.append(f"`{item}`")

await ctx.send(response.get("current-activities").format(activity_list="\n- ".join(formatted_list)))

@commands.is_owner()
@bot.command(name="activitylist")
async def list_activities(ctx):
if activities.activity_list:
formatted_list = []
for item in activities.activity_list:
formatted_list.append(f"`{item}`")
else:
await ctx.send(response.get("no-current-activities"))

await ctx.send(response.get("current-activities").format(activity_list="\n- ".join(formatted_list)))
elif action.lower() == "remove" and activity:
removed = activities.remove(activity)
if removed:
await ctx.send(response.get("rm-activity-success").format(activity_to_delete=activity))

else:
await ctx.send(response.get("rm-activity-not-exists"))

else:
await ctx.send(response.get("no-current-activities"))
await ctx.send(response.get("activity-add-list-remove"))


@commands.is_owner()
Expand Down
8 changes: 6 additions & 2 deletions files/i18n/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"brief-settings-systemchannel": "Updates the main or server system channel where the bot sends errors and update notifications",
"brief-settings-language": "Sets the bot language",
"brief-settings-colour": "Sets the colour of the embeds of new and newly edited reaction role messages",
"brief-settings-activity": "Add or remove an activity for the bot to loop through and show as status",
"message-edit-option-channel": "The channel in which the message you want to edit is located",
"message-edit-option-number": "The number of the message in the channel (enter 0 for explanation)",
"message-edit-option-message": "The message of the reaction-role message (enter 'none' to skip)",
Expand All @@ -138,9 +139,12 @@
"message-reaction-option-number": "The number of the message in the channel (enter 0 for explanation)",
"message-reaction-option-reaction": "The reaction you want to add or remove",
"message-reaction-option-role": "The role you want to associate to the new reaction (not necessary for 'remove')",
"no-add-remove-specified": "The only accepted actions are **add** and **remove**",
"no-add-remove-specified": "The only accepted actions are `add` and `remove`",
"settings-systemchannel-option-type": "Define if it is a 'main' (general errors) or 'server' (guild speficic errors) channel",
"settings-systemchannel-option-channel": "The channel in which error message will be sent",
"settings-language-option-language": "The language to set, enter 'check' to see the available languages",
"settings-colour-option-colour": "The hex value of the colour you wish to set (e.g. 0xffff00)"
"settings-colour-option-colour": "The hex value of the colour you wish to set (e.g. 0xffff00)",
"settings-activity-option-action": "Use 'add', 'remove', 'list' to add/remove/view a bot status message",
"settings-activity-option-activity": "The text that appears after 'Playing' in the bot's status message (case sensitive)",
"activity-add-list-remove": "The only actions supported are `add`, `list`, and `remove`. You need to provide an activity if using `add` or `remove`."
}

0 comments on commit 0e59b9d

Please sign in to comment.