Files
aikaterna-cogs/region/region.py
Draper ae9dbf569c Data API Complicance (Red 3.4) (#136)
* Simple ones first

* Less simple but still simple.

* Slightly more complicated

* use correct name

* move to module

* Black -l 120

* review

* give users the proper feedback

Co-authored-by: aikaterna <20862007+aikaterna@users.noreply.github.com>
2020-08-26 09:57:43 -07:00

52 lines
1.7 KiB
Python

import discord
from redbot.core import checks, commands
from redbot.core.utils.chat_formatting import humanize_list
class Region(commands.Cog):
"""Change the guild voice region."""
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
return
@checks.mod_or_permissions(administrator=True)
@commands.cooldown(1, 60, discord.ext.commands.BucketType.guild)
@commands.command()
async def region(self, ctx, *, region: str):
"""Set the current guild's voice region."""
regions = [
"japan",
"singapore",
"eu-central",
"europe",
"india",
"us-central",
"london",
"eu-west",
"amsterdam",
"brazil",
"dubai",
"us-west",
"hongkong",
"us-south",
"southafrica",
"us-east",
"sydney",
"frankfurt",
"russia",
]
region = region.replace(" ", "-")
if region not in regions:
ctx.command.reset_cooldown(ctx)
return await ctx.send(
f"`{region}` was not found in the list of Discord voice regions. Valid regions are: {humanize_list(regions)}."
)
try:
await ctx.guild.edit(region=region)
except discord.errors.Forbidden:
return await ctx.send("I don't have permissions to edit this guild's settings.")
except discord.errors.HTTPException:
return await ctx.send(f"Error: An invalid server region was passed: `{region}`")
await ctx.send(f"The voice server region for `{ctx.guild.name}` has been changed to `{region}`.")