Skip to content

Commit

Permalink
Merge pull request #157 from UnifierHQ/lang
Browse files Browse the repository at this point in the history
Move v2.1.0 development to dev branch
  • Loading branch information
greeeen-dev authored Aug 6, 2024
2 parents 1f5c6af + a67c595 commit 84fc705
Show file tree
Hide file tree
Showing 18 changed files with 2,978 additions and 1,598 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TOKEN=token_goes_here
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ all on your messaging app of choice.
Using threading and optimizations, Unifier has been tested to be able to send up to 33 messages a second through webhooks, so
nobody needs to wait to see your messages. Do note that this speed will vary depending on lots of factors.

### Revolt and Guilded support
With [Revolt](https://github.com/UnifierHQ/unifier-revolt) and [Guilded](https://github.com/UnifierHQ/unifier-guilded)
support plugins, you can bring your communities outside of Discord together, or get a break from Discord without losing your
community.
### External platforms support
With support for external platforms, you can bring your communities outside of Discord together, or get a break from Discord
without losing your community. Unifier supports virtually any platform with the help of support Plugins, so the possibilities
are endless.

Support plugins need to be installed to enable support for these platforms.
We've written a platform support Plugin for [Revolt](https://github.com/UnifierHQ/unifier-revolt), so give that a try!

### Moderation commands
After you assign bot admins, they can assign moderators, who can help moderate the chat and take action against bad actors.
Expand Down
41 changes: 26 additions & 15 deletions cogs/badge.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Unifier - A sophisticated Discord bot uniting servers and platforms
Copyright (C) 2024 Green, ItsAsheer
Copyright (C) 2023-present UnifierHQ
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
Expand All @@ -18,27 +18,32 @@

import nextcord
from nextcord.ext import commands
from utils import log, restrictions as r
from utils import log, langmgr, restrictions as r
from enum import Enum

restrictions = r.Restrictions()
language = langmgr.partial()
language.load()

class UserRole(Enum):
OWNER = "the instance\'s **owner**"
ADMIN = "the instance\'s **admin**"
MODERATOR = "the instance\'s **moderator**"
TRUSTED = "a **verified user**"
BANNED = "**BANNED**"
USER = "a **user**"
# let values be None until set by langmgr
OWNER = language.get('owner','badge.roles')
ADMIN = language.get('admin','badge.roles')
MODERATOR = language.get('moderator','badge.roles')
TRUSTED = language.get('trusted','badge.roles')
BANNED = language.get('banned','badge.roles')
USER = language.get('user','badge.roles')

class Badge(commands.Cog, name=':medal: Badge'):
"""Badge contains commands that show you your role in Unifier.
Developed by Green and ItsAsheer"""

def __init__(self, bot):
global language
self.bot = bot
self.logger = log.buildlogger(self.bot.package, 'badge', self.bot.loglevel)
language = self.bot.langmgr
self.embed_colors = {
UserRole.OWNER: (
self.bot.colors.greens_hair if self.bot.user.id==1187093090415149056 else self.bot.colors.unifier
Expand All @@ -51,9 +56,9 @@ def __init__(self, bot):
}
restrictions.attach_bot(self.bot)

@commands.command()
@commands.command(description=language.desc('badge.badge'))
async def badge(self, ctx, *, user=None):
"""Shows your Unifier user badge."""
selector = language.get_selector(ctx)
if user:
try:
user = self.bot.get_user(int(user.replace('<@','',1).replace('>','',1).replace('!','',1)))
Expand All @@ -63,24 +68,27 @@ async def badge(self, ctx, *, user=None):
user = ctx.author
user_role = self.get_user_role(user.id)
embed = nextcord.Embed(
description=f"<@{user.id}> is {user_role.value}.",
description=selector.fget("easter_egg", values={
'mention':f"<@{user.id}>",'role': user_role.value
}),
color=self.embed_colors[user_role]
)
embed.set_author(
name=f'@{user.name}',
icon_url=user.avatar.url if user.avatar else None
)
if user_role==UserRole.BANNED:
embed.set_footer(text='L bozo')
embed.set_footer(text=selector.get("easter_egg"))

await ctx.send(embed=embed)

@commands.command(hidden=True,aliases=['trust'],description='Verifies a user.')
@commands.command(hidden=True,aliases=['trust'],description=language.desc('badge.verify'))
@restrictions.admin()
async def verify(self, ctx, action, user: nextcord.User):
selector = language.get_selector(ctx)
action = action.lower()
if action not in ['add', 'remove']:
return await ctx.send("Invalid action. Please use 'add' or 'remove'.")
return await ctx.send(selector.get('invalid_action'))

if action == 'add':
if user.id not in self.bot.trusted_group:
Expand All @@ -95,7 +103,10 @@ async def verify(self, ctx, action, user: nextcord.User):
user_role = UserRole.TRUSTED if action == 'add' else UserRole.USER
embed = nextcord.Embed(
title="Unifier",
description=f"{'Added' if action == 'add' else 'Removed'} user {user.mention} from the trust group.",
description=(
selector.fget('added',values={'user':user.mention}) if action=='add' else
selector.fget('removed',values={'user':user.mention})
),
color=self.embed_colors[user_role],
)
await ctx.send(embed=embed)
Expand Down
Loading

0 comments on commit 84fc705

Please sign in to comment.