mirror of
https://git.mctaylors.ru/mctaylors/Lurker.git
synced 2024-11-23 01:08:02 +03:00
120 lines
4.5 KiB
Python
120 lines
4.5 KiB
Python
import next
|
|
import extensions
|
|
|
|
from random import randrange
|
|
from time import time
|
|
from math import trunc
|
|
from next.ext import commands
|
|
|
|
|
|
class Client(commands.CommandsClient):
|
|
async def get_prefix(self, message: next.Message):
|
|
return "!"
|
|
|
|
async def on_ready(self):
|
|
print(f"Authorized as {self.user.name}#{self.user.discriminator}")
|
|
try:
|
|
await self.edit_status(presence = next.PresenceType.focus,
|
|
text = "Watching friend requests...")
|
|
except Exception as e:
|
|
print(f"Unable to edit status. ({e})")
|
|
|
|
@commands.command()
|
|
async def random(self, ctx: commands.Context, *args):
|
|
"""[x] (y) - Generates a random number"""
|
|
if not args:
|
|
await ctx.send("No arguments passed!")
|
|
return
|
|
|
|
try:
|
|
x = int(args[0])
|
|
y = 0
|
|
if 1 < len(args):
|
|
y = int(args[1])
|
|
except ValueError:
|
|
await ctx.send("Not a number!")
|
|
return
|
|
|
|
if x > y:
|
|
result = randrange(y, x + 1)
|
|
await ctx.send(extensions.random_message(result, y, x))
|
|
return
|
|
|
|
result = randrange(x, y + 1)
|
|
await ctx.send(extensions.random_message(result, x, y))
|
|
|
|
@commands.command()
|
|
async def timestamp(self, ctx: commands.Context):
|
|
"""Shows current timestamp"""
|
|
timestamp = trunc(time())
|
|
table = str()
|
|
styles = ['d', 'D', 't', 'T', 'f', 'F', 'R']
|
|
for style in styles:
|
|
table = table + f"\n| `<t:{timestamp}:{style}>` | <t:{timestamp}:{style}> |"
|
|
await ctx.send(f"## {timestamp}\n"
|
|
f"| Chat syntax | Result |\n"
|
|
f"| --- | --- |"
|
|
+ table)
|
|
|
|
@commands.command()
|
|
async def self(self, ctx: commands.Context):
|
|
"""Shows info about current user"""
|
|
author = ctx.author
|
|
|
|
name = f"{author.original_name}#{author.discriminator}"
|
|
if author.display_name is not None:
|
|
name = f"{author.display_name}\n" + name
|
|
|
|
original_avatar = None
|
|
if author.original_avatar is not None:
|
|
original_avatar = extensions.icon_info(author.original_avatar)
|
|
guild_avatar = None
|
|
if author.guild_avatar is not None:
|
|
guild_avatar = extensions.icon_info(author.guild_avatar)
|
|
|
|
roles = str()
|
|
for role in author.roles:
|
|
roles = f"{roles} {role.name},"
|
|
roles = roles[:-1]
|
|
if roles is str():
|
|
roles = None
|
|
|
|
logo = ":01J37TY299JWPPAT121HT2KKS9:"
|
|
await ctx.send(f"## {name}\n"
|
|
f"| ID | `{author.id}` |\n| --- | --- |\n"
|
|
f"| {logo} member since | <t:{trunc(author.created_at.timestamp())}:D> |\n"
|
|
f"| Profile picture | {original_avatar} |\n"
|
|
f"---\n| Server statistics | Value |\n| --- | --- |\n"
|
|
f"| Server nickname | {author.nickname} |\n"
|
|
f"| Server member since | <t:{trunc(author.created_at.timestamp())}:D> |\n"
|
|
f"| Server profile picture | {guild_avatar} |\n"
|
|
f"| Roles | {roles} |")
|
|
|
|
@commands.command()
|
|
async def server(self, ctx: commands.Context):
|
|
"""Shows info about current server"""
|
|
server = ctx.author.server
|
|
|
|
description = "No server description."
|
|
if server.description is not None:
|
|
description = '>'.join(('\n' + server.description.lstrip()).splitlines(True))
|
|
|
|
icon = None
|
|
if server.icon is not None:
|
|
icon = extensions.icon_info(server.icon)
|
|
banner = None
|
|
if server.banner is not None:
|
|
banner = extensions.icon_info(server.banner)
|
|
|
|
await ctx.send(f"## {server.name}\n"
|
|
f"{description}\n"
|
|
f"| ID | `{server.id}` |\n| --- | --- |\n"
|
|
f"| Created at | <t:{trunc(server.created_at.timestamp())}:D> |\n"
|
|
f"| Server icon | {icon} |\n"
|
|
f"| Server banner | {banner} |\n"
|
|
f"| Server owner | {server.owner.original_name}#{server.owner.discriminator} |\n"
|
|
f"---\n| Statistics | Value |\n| --- | --- |\n"
|
|
f"| Members | {len(server.members)} |\n"
|
|
f"| Channels | {len(server.channels)} |\n"
|
|
f"| Roles | {len(server.roles)} |\n"
|
|
f"| Emojis | {len(server.emojis)} |")
|