Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import discord
- import os
- from discord.ext import commands
- from discord.ext import commands
- from discord.ext.commands import has_permissions, CheckFailure
- import shlex, subprocess
- bot = commands.Bot(command_prefix="!", pm_help=True)
- class ServerCommands(commands.Cog):
- @commands.command(name='start',
- brief="Starts the arma server",
- pass_context=True)
- @has_permissions(administrator=True)
- async def start(self, ctx):
- await ctx.send("Starting Server...")
- subprocess.call(shlex.split('"D:\Server\Program Files (x86)\arma3server_x64.exe" -port=2302 "-config=D:\Server\arma3\TADST\default\TADST_config.cfg" "-cfg=D:\Server\arma3\TADST\default\TADST_basic.cfg" "-profiles=D:\Server\arma3\TADST\default" -name=default -filePatching'))
- @commands.command(name='stop',
- brief="Stop the arma server",
- pass_context=True)
- @has_permissions(administrator=True)
- async def stop(self, ctx):
- os.system('taskkill /f /im "arma3server_x64.exe"')
- await ctx.send("Stop the Server.")
- @bot.event
- async def on_ready():
- print('Logged in as')
- print(bot.user.name)
- print(bot.user.id)
- print('------------')
- def main():
- bot.add_cog(ServerCommands(bot))
- bot.run("ENTER_TOKEN")
- if __name__ == '__main__':
- main()
- #make bot join server:
- # https://discordapp.com/oauth2/authorize?client_id=xxxxxx&scope=bot
- #https://discordpy.readthedocs.io/en/rewrite/ext/commands/api.html#event-reference
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement