Skip to content

Commit

Permalink
Added LINK_INVITE .env variable, added invite and support emojis, rem…
Browse files Browse the repository at this point in the history
…oved navi lite emoji
  • Loading branch information
Miriel committed Mar 9, 2024
1 parent e9cbf3e commit 95132c8
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ celerybeat.pid
*.sage.py

# Environments
.env
.env*
.venv
env/
venv/
Expand Down
18 changes: 13 additions & 5 deletions cogs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Contains error handling and the help and about commands"""

import discord
from discord import slash_command
from discord.ext import bridge, commands

from content import main
Expand Down Expand Up @@ -35,21 +36,28 @@ async def about(self, ctx: bridge.BridgeContext) -> None:
"""About command"""
await main.command_about(self.bot, ctx)

# Slash commands
if settings.LINK_INVITE is not None:
@slash_command(name='invite', description='Invite Navi to your server!')
async def invite(self, ctx: discord.ApplicationContext) -> None:
"""Sends and invite link"""
await ctx.respond(f'Click [here]({settings.LINK_INVITE}) to invite me!')

# Text commands
@commands.command(name='invite', aliases=('inv',))
@commands.bot_has_permissions(send_messages=True)
async def invite(self, ctx: commands.Context) -> None:
async def invite_prefix(self, ctx: commands.Context) -> None:
"""Invite command"""
invite_link = 'https://canary.discord.com/api/oauth2/authorize?client_id=1213487623688167494&permissions=378944&scope=bot'
if ctx.guild.me.id == 1213487623688167494: # Navi Lite#9605
if settings.LINK_INVITE is not None:
answer = (
f'Click [here]({invite_link}) to invite me!'
f'Click [here]({settings.LINK_INVITE}) to invite me!'
)
else:
navi_lite_invite = 'https://canary.discord.com/api/oauth2/authorize?client_id=1213487623688167494&permissions=378944&scope=bot'
answer = (
f'Sorry, you can\'t invite this Navi.\n\n'
f'However, you have 2 options:\n'
f'1. [Invite Navi Lite]({invite_link}), a global version of Navi with a few limitations.\n'
f'1. [Invite Navi Lite]({navi_lite_invite}), a global version of Navi with a few limitations.\n'
f'2. [Run Navi yourself](https://github.com/MirielCH/Navi). Navi is free and open source.\n'
)
await ctx.reply(answer)
Expand Down
16 changes: 4 additions & 12 deletions content/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
from resources import emojis, functions, settings, strings


LINK_INVITE_NAVI_LITE = 'https://canary.discord.com/api/oauth2/authorize?client_id=1213487623688167494&permissions=378944&scope=bot'


class LinksView(discord.ui.View):
"""View with link buttons."""
def __init__(self):
super().__init__(timeout=None)
if settings.LINK_SUPPORT is not None:
self.add_item(discord.ui.Button(label="Support", style=discord.ButtonStyle.link,
url=settings.LINK_SUPPORT, emoji=emojis.NAVI, row=0))
url=settings.LINK_SUPPORT, emoji=emojis.SUPPORT, row=0))
self.add_item(discord.ui.Button(label="Changelog", style=discord.ButtonStyle.link,
url=strings.LINK_CHANGELOG, emoji=emojis.GITHUB, row=0))
self.add_item(discord.ui.Button(label="Github", style=discord.ButtonStyle.link,
Expand All @@ -36,10 +33,11 @@ def __init__(self):
if settings.LINK_TERMS is not None:
self.add_item(discord.ui.Button(label="Terms of Service", style=discord.ButtonStyle.link,
url=settings.LINK_TERMS, emoji=emojis.TERMS, row=1))
if settings.LINK_INVITE is not None:
self.add_item(discord.ui.Button(label="Invite", style=discord.ButtonStyle.link,
url=settings.LINK_INVITE, emoji=emojis.INVITE, row=2))




# --- Commands ---
async def command_event_reduction(bot: bridge.AutoShardedBot, ctx: bridge.BridgeContext) -> None:
"""Help command"""
Expand All @@ -51,9 +49,6 @@ async def command_event_reduction(bot: bridge.AutoShardedBot, ctx: bridge.Bridge
async def command_help(bot: bridge.AutoShardedBot, ctx: Union[bridge.BridgeContext, discord.Message]) -> None:
"""Help command"""
view = LinksView()
if ctx.guild.me.id == 1213487623688167494: # Navi Lite#9605
view.add_item(discord.ui.Button(label="Invite", style=discord.ButtonStyle.link,
url=LINK_INVITE_NAVI_LITE, emoji='<:invite:1215733334542385265>', row=2))
embed = await embed_help(bot, ctx)
if isinstance(ctx, discord.Message):
await ctx.reply(embed=embed, view=view)
Expand All @@ -69,9 +64,6 @@ async def command_about(bot: bridge.AutoShardedBot, ctx: bridge.BridgeContext) -
api_latency = end_time - start_time
img_navi, embed = await embed_about(bot, api_latency)
view = LinksView()
if ctx.guild.me.id == 1213487623688167494: # Navi Lite#9605
view.add_item(discord.ui.Button(label="Invite", style=discord.ButtonStyle.link,
url=LINK_INVITE_NAVI_LITE, emoji='<:invite:1215733334542385265>', row=2))
channel_permissions = ctx.channel.permissions_for(ctx.guild.me)
if not channel_permissions.attach_files:
await interaction.edit(content=None, embed=embed, view=view)
Expand Down
10 changes: 7 additions & 3 deletions default.env
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ DEV_IDS=
# Use hex format (e.g. 00FFAA).
EMBED_COLOR=000000

# Optional. Sets a link to your Navi support server or channel. If this is set, Navi will show a link button in /help and /about.
# Example: LINK_SUPPORT=https://discord.com/channels/1234/1234
LINK_SUPPORT=
# Optional. Sets a link with which your Navi can be invited if you choose to let people do so. If this is set, Navi will show an invite button in /help and /about.
# Example: https://canary.discord.com/api/oauth2/authorize?client_id=1213487623688167494&permissions=378944&scope=bot
LINK_INVITE=

# Optional. Sets a link to your privacy policy. If this is set, Navi will show a link button in /help and /about.
# Example: LINK_PRIVACY_POLICY=https://github.com/YourName/Navi/blob/master/PRIVACY.md
LINK_PRIVACY_POLICY=

# Optional. Sets a link to your Navi support server or channel. If this is set, Navi will show a link button in /help and /about.
# Example: LINK_SUPPORT=https://discord.com/channels/1234/1234
LINK_SUPPORT=

# Optional. Sets a link to your terms of service. If this is set, Navi will show a link button in /help and /about.
# Example: LINK_TERMS=https://github.com/YourName/Navi/blob/master/TERMS.md
LINK_TERMS=
Expand Down
Binary file added images/emojis/Misc/invite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/emojis/Misc/navi_lite.png
Binary file not shown.
Binary file added images/emojis/Misc/support.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions resources/emojis.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@
ENABLED = '<:enabled:1065722838935412797>'
ERROR = '❌'
GITHUB = '<:github:1010927917297053707>'
INVITE = '<:invite:1215733334542385265>'
NAVI = '<:navi:1214997490533662762>'
NAVI_LITE = '<:navi_lite:1214642272524828742>'
NAVI = NAVI_LITE if settings.LITE_MODE else NAVI
PARTNER_ALERT = '💌'
PRIVACY_POLICY = '<:privacy:1213508477285048360>s'
REMOVE = '<:remove:1214996418696183938>'
SUPPORT = '<:support:1216056995971338361>'
TERMS = '<:terms:1213494032215314513>'
WARNING = '⚠️'

Expand Down
6 changes: 6 additions & 0 deletions resources/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
print(f'Can\'t convert value "{EMBED_COLOR}" of variable EMBED_COLOR in the .env file to an integer.')
sys.exit()

LINK_INVITE = os.getenv('LINK_INVITE')
if LINK_INVITE != '' and LINK_INVITE is not None:
LINK_INVITE = LINK_INVITE.strip('" ')
else:
LINK_INVITE = None

LINK_SUPPORT = os.getenv('LINK_SUPPORT')
if LINK_SUPPORT != '' and LINK_SUPPORT is not None:
LINK_SUPPORT = LINK_SUPPORT.strip('" ')
Expand Down

0 comments on commit 95132c8

Please sign in to comment.