fix #3
This commit is contained in:
1 parent
1324fec8dd
commit
3679ba44af
2 files changed
+16
-3
No files matched your search
+10
-1
@@ -83,6 +83,15 @@
|
|||||||
"detail": "subprocess",
|
"detail": "subprocess",
|
||||||
"documentation": {}
|
"documentation": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "re",
|
||||||
|
"kind": 6,
|
||||||
|
"isExtraImport": true,
|
||||||
|
"importPath": "re",
|
||||||
|
"description": "re",
|
||||||
|
"detail": "re",
|
||||||
|
"documentation": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "load_dotenv",
|
"label": "load_dotenv",
|
||||||
"importPath": "dotenv",
|
"importPath": "dotenv",
|
||||||
@@ -159,7 +168,7 @@
|
|||||||
"kind": 6,
|
"kind": 6,
|
||||||
"importPath": "cogs.sysinfo",
|
"importPath": "cogs.sysinfo",
|
||||||
"description": "cogs.sysinfo",
|
"description": "cogs.sysinfo",
|
||||||
"peekOfCode": "class SysInfo(commands.Cog):\n def __init__(self,bot):\n self.bot = bot\n @commands.command()\n async def fetch(self, ctx):\n result = subprocess.run(['fastfetch', '--pipe'], capture_output=True, text=True)\n await ctx.reply(f'```\\n{result.stdout}\\n```')\nasync def setup(bot):\n await bot.add_cog(SysInfo(bot))",
|
"peekOfCode": "class SysInfo(commands.Cog):\n def __init__(self, bot):\n self.bot = bot\n def strip_ansi(self, text):\n return re.sub(r'\\x1b\\[[0-9;]*[a-zA-Z]|\\[[0-9]+[A-Z]', '', text)\n @commands.command()\n async def fetch(self, ctx):\n result = subprocess.run(['fastfetch', '--pipe'], capture_output=True, text=True)\n clean = self.strip_ansi(result.stdout)\n await ctx.reply(f'```\\n{clean}\\n```')",
|
||||||
"detail": "cogs.sysinfo",
|
"detail": "cogs.sysinfo",
|
||||||
"documentation": {}
|
"documentation": {}
|
||||||
},
|
},
|
||||||
|
|||||||
+6
-2
@@ -1,16 +1,20 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
import re
|
||||||
|
|
||||||
class SysInfo(commands.Cog):
|
class SysInfo(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
|
def strip_ansi(self, text):
|
||||||
|
return re.sub(r'\x1b\[[0-9;]*[a-zA-Z]|\[[0-9]+[A-Z]', '', text)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def fetch(self, ctx):
|
async def fetch(self, ctx):
|
||||||
result = subprocess.run(['fastfetch', '--pipe'], capture_output=True, text=True)
|
result = subprocess.run(['fastfetch', '--pipe'], capture_output=True, text=True)
|
||||||
await ctx.reply(f'```\n{result.stdout}\n```')
|
clean = self.strip_ansi(result.stdout)
|
||||||
|
await ctx.reply(f'```\n{clean}\n```')
|
||||||
|
|
||||||
async def setup(bot):
|
async def setup(bot):
|
||||||
await bot.add_cog(SysInfo(bot))
|
await bot.add_cog(SysInfo(bot))
|
||||||
Reference in new issue
Block a user