mirror of
https://github.com/TotalFreedomMC/TotalFreedomBot.git
synced 2024-12-22 23:54:58 +00:00
Update server_commands.py
This commit is contained in:
parent
0cd97cf2bf
commit
0c46abdaa9
1 changed files with 45 additions and 8 deletions
|
@ -4,7 +4,7 @@ import requests
|
||||||
from checks import *
|
from checks import *
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functions import fix_reports, format_list_entry
|
from functions import *
|
||||||
from unicode import *
|
from unicode import *
|
||||||
from telnetlib import Telnet
|
from telnetlib import Telnet
|
||||||
|
|
||||||
|
@ -19,10 +19,22 @@ class ServerCommands(commands.Cog):
|
||||||
eventhostrole = ctx.guild.get_role(event_host)
|
eventhostrole = ctx.guild.get_role(event_host)
|
||||||
if eventhostrole in user.roles:
|
if eventhostrole in user.roles:
|
||||||
await user.remove_roles(eventhostrole)
|
await user.remove_roles(eventhostrole)
|
||||||
await ctx.send(f'```Succesfully took Event Host from {user.name}```')
|
await ctx.send(f'```Succesfully took {eventhostrole.name} from {user.name}```')
|
||||||
else:
|
else:
|
||||||
await user.add_roles(eventhostrole)
|
await user.add_roles(eventhostrole)
|
||||||
await ctx.send(f'```Succesfully added Event Host to {user.name}```')
|
await ctx.send(f'```Succesfully added {eventhostrole.name} to {user.name}```')
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@is_creative_designer()
|
||||||
|
async def masterbuilder(self, ctx, user: discord.Member):
|
||||||
|
'Add or remove master builder role - ECD only'
|
||||||
|
master_builder_role = ctx.guild.get_role(master_builder)
|
||||||
|
if master_builder_role in user.roles:
|
||||||
|
await user.remove_roles(master_builder_role)
|
||||||
|
await ctx.send(f'```Succesfully took {master_builder_role.name} from {user.name}```')
|
||||||
|
else:
|
||||||
|
await user.add_roles(master_builder_role)
|
||||||
|
await ctx.send(f'```Succesfully added {master_builder_role.name} to {user.name}```')
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@is_staff()
|
@is_staff()
|
||||||
|
@ -49,7 +61,7 @@ class ServerCommands(commands.Cog):
|
||||||
'Stops the server'
|
'Stops the server'
|
||||||
em = discord.Embed()
|
em = discord.Embed()
|
||||||
try:
|
try:
|
||||||
self.bot.telnet_session.write(bytes('stop', 'ascii') + b"\r\n")
|
self.bot.telnet_object.session.write(bytes('stop', 'ascii') + b"\r\n")
|
||||||
except:
|
except:
|
||||||
em.title='Command error'
|
em.title='Command error'
|
||||||
em.colour = 0xFF0000
|
em.colour = 0xFF0000
|
||||||
|
@ -61,13 +73,38 @@ class ServerCommands(commands.Cog):
|
||||||
em.description = 'Server stopped.'
|
em.description = 'Server stopped.'
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
|
@commands.command(aliases=['adminconsole', 'ac'])
|
||||||
|
@is_staff()
|
||||||
|
async def telnet(self, ctx, *args):
|
||||||
|
'mv, gtfo, kick, mute or warn from discord'
|
||||||
|
em = discord.Embed()
|
||||||
|
command = ''
|
||||||
|
for x in range(len(args)):
|
||||||
|
command += f'{args[x]} '
|
||||||
|
try:
|
||||||
|
if args[0] in ['mute', 'stfu', 'gtfo', 'ban', 'noob', 'tban', 'tempban', 'warn', 'mv', 'kick']:
|
||||||
|
self.bot.telnet_object.session.write(bytes(command, 'ascii') + b"\r\n")
|
||||||
|
else:
|
||||||
|
raise no_permission(['IS_SENIOR_ADMIN'])
|
||||||
|
await ctx.send(embed=em)
|
||||||
|
except Exception as e:
|
||||||
|
em.title='Command error'
|
||||||
|
em.colour = 0xFF0000
|
||||||
|
em.description = f'{e}'
|
||||||
|
await ctx.send(embed=em)
|
||||||
|
else:
|
||||||
|
em.title = 'Success'
|
||||||
|
em.colour = 0x00FF00
|
||||||
|
em.description = 'Command sent.'
|
||||||
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@is_senior()
|
@is_senior()
|
||||||
async def kill(self, ctx):
|
async def kill(self, ctx):
|
||||||
'Kills the server'
|
'Kills the server'
|
||||||
em = discord.Embed()
|
em = discord.Embed()
|
||||||
try:
|
try:
|
||||||
self.bot.telnet_session.write(bytes('telnet.stop', 'ascii') + b"\r\n")
|
self.bot.telnet_object.session.write(bytes('telnet.stop', 'ascii') + b"\r\n")
|
||||||
except:
|
except:
|
||||||
em.title='Command error'
|
em.title='Command error'
|
||||||
em.colour = 0xFF0000
|
em.colour = 0xFF0000
|
||||||
|
@ -86,7 +123,7 @@ class ServerCommands(commands.Cog):
|
||||||
'Restarts the server'
|
'Restarts the server'
|
||||||
em = discord.Embed()
|
em = discord.Embed()
|
||||||
try:
|
try:
|
||||||
self.bot.telnet_session.write(bytes('restart', 'ascii') + b"\r\n")
|
self.bot.telnet_object.session.write(bytes('restart', 'ascii') + b"\r\n")
|
||||||
except:
|
except:
|
||||||
em.title='Command error'
|
em.title='Command error'
|
||||||
em.colour = 0xFF0000
|
em.colour = 0xFF0000
|
||||||
|
@ -105,7 +142,7 @@ class ServerCommands(commands.Cog):
|
||||||
'''await ctx.send(f'```:[{str(datetime.utcnow().replace(microsecond=0))[11:]} INFO]: {ctx.author.name} issued server command: /{command}```')'''
|
'''await ctx.send(f'```:[{str(datetime.utcnow().replace(microsecond=0))[11:]} INFO]: {ctx.author.name} issued server command: /{command}```')'''
|
||||||
em = discord.Embed()
|
em = discord.Embed()
|
||||||
try:
|
try:
|
||||||
self.bot.telnet_session.write(bytes(command, 'ascii') + b"\r\n")
|
self.bot.telnet_object.session.write(bytes(command, 'ascii') + b"\r\n")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
em.title='Command error'
|
em.title='Command error'
|
||||||
em.colour = 0xFF0000
|
em.colour = 0xFF0000
|
||||||
|
|
Loading…
Reference in a new issue