-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Python' into MiataBoy-patch-1
- Loading branch information
Showing
11 changed files
with
53 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
import discord | ||
from discord import slash_command | ||
from discord import slash_command, option | ||
from discord.ext import commands | ||
from discord.ext.commands import Bot | ||
|
||
from utilities.database import modifier | ||
from utilities.utility import check_ip | ||
|
||
|
||
class SetServer(discord.Cog): | ||
def __init__(self, bot: Bot): | ||
def __init__(self, bot: discord.Bot): | ||
self.bot = bot | ||
|
||
@slash_command(aliases=["set"], description="Set the default server to use if no argument is provided in the status command.") | ||
@slash_command() | ||
@commands.has_permissions(manage_guild=True) | ||
async def setserver(self, ctx, server=None): | ||
if server is None: | ||
@option("server", description="The server to set as default", default=None) | ||
async def setserver(self, ctx, server): | ||
""" Set the default server to use if no argument is provided in the status command """ | ||
if not server: | ||
await modifier("DELETE FROM server WHERE guild_id = %s", [ctx.guild_id]) | ||
return await ctx.respond("Default server has been removed. Use `setserver <server>` to set a new one.", ephemeral=True) | ||
return await ctx.respond(f"Default server has been removed. Use </{ctx.command.name}:{ctx.command.id}> with the \"server\" option to set a new one.", ephemeral=True) | ||
server = check_ip(server) | ||
if not server: | ||
return await ctx.respond("Please provide a valid Aternos IP.", ephemeral=True) | ||
|
||
await modifier("INSERT INTO server (guild_id, server_ip) VALUES (%s, %s) ON DUPLICATE KEY UPDATE server_ip = %s", [ctx.guild_id, server, server]) | ||
await ctx.respond(f'The IP has been set to {server}. Use `status` without an argument to view it.' , ephemeral=True) | ||
status_command = self.bot.get_application_command("status") | ||
await ctx.respond(f'The IP has been set to {server}. Use </{status_command.name}:{status_command.id}> without an argument to view it.', ephemeral=True) | ||
|
||
|
||
def setup(bot: Bot): | ||
def setup(bot: discord.Bot): | ||
bot.add_cog(SetServer(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters