async def DEV_UPDATE(self, ctx): if ctx.author.id in VDict["Perms"]["Dev"]: print("Pulling from git.") os.system("git pull") if platform.system().lower() == "windows": os.system("start bot.py") else: os.system("python bot.py") exit()
async def DEV_RESTART(self, ctx): if ctx.author.id in VDict["Perms"]["Dev"]: print("Bot restarting.") for cog in Vars.Loaded_Cogs: self.bot.unload_extension(cog) if platform.system().lower() == "windows": os.system("start bot.py") else: os.system("python bot.py") exit()
async def on_command_error(self, ctx, error): if hasattr(ctx.command, "on_error"): return O = "An error has occured: \n\n--ST3VI3'S ERROR HANDLER--\n\n " # output if ctx.command != None: O = f"{O}Command: {ctx.command}\n " #Below is temporarily disabled. The intention is to print back cog name and line number for error. #try: #error #except: # exc_type, exc_obj, exc_tb = sys.exc_info() # fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] #O = f"{O}File: {error.__traceback__.tb_frame.f_code.co_filename}\n Line: {error.__traceback__.tb_lineno}\n " error = getattr(error, 'original', error) Severity = "Undetermined" Class = "Unknown" if isinstance(error, commands.MissingRequiredArgument): Severity = "Unimportant" Class = "User invoked" if isinstance(error, commands.BadArgument): Severity = "Unimportant" Class = "User invoked" if isinstance(error, commands.CommandNotFound): Severity = "Unimportant" Class = "User invoked" if isinstance(error, commands.CommandInvokeError): Severity = "Medium" Class = "Code error" if isinstance(error, AttributeError): Severity = "Medium" Class = "Code error / Var error" if isinstance(error, UnboundLocalError): Severity = "Critical" Class = "Code error / Var print" O = f"{O}Error: {str(error)}\n Error type: {str(type(error))[8:-2]}\n Error class: {Class}\n Sverity: {Severity}\n " O = f"{O}\n--------------------------" print(O, type="err") await ctx.send(f"```{O}```")
async def on_ready(): print("Bot ready. ")
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import discord from discord.ext import commands import os import BotBase from BotBase import Vars from BotBase.Core.Print import prt as print from BotBase.Core import Settings from BotBase.Vars import VDict from BotBase.Core import Intents print("Bot initialising [phase 1/3]", end="\r") Settings.Load() print("Bot initialising [phase 2/3]", end="\r") intents = discord.Intents.default() intents = Intents.SetIntents(intents, VDict["Intents"]) bot = commands.Bot( command_prefix=VDict["Prefix"], intents=intents) # This sets the prefix that the bot will use. bot.remove_command('help') #Removes the default discord help command print("Bot initialising [phase 3/3]", end="\r") try: bot.load_extension(f"BotBase.Core_Cogs.Cog_Funcs") Vars.Loaded_Cogs.append("BotBase.Core_Cogs.Cog_Funcs") except:
async def DEV_REMOTE_CONSOLE(self, ctx, *, cmd: str): if ctx.author.id in VDict["Perms"]["Dev"]: CmdO = os.popen(cmd).read() if CmdO != "": await ctx.send(f"Command returned: ```{str(CmdO)}```") else: await ctx.send("Command returned no output.") print(f"Rcon command (\"{cmd}\") returned: {str(CmdO)}")
async def DEV_SHUTDOWN(self, ctx): if ctx.author.id in VDict["Perms"]["Dev"]: print("Bot shutting down.") for cog in Vars.Loaded_Cogs: self.bot.unload_extension(cog) exit()