Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
Update channels and add a few notes
Browse files Browse the repository at this point in the history
  • Loading branch information
dragdev committed Aug 25, 2020
1 parent 8d04ce2 commit 877a9d8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions riftgun/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RiftGun(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
if not os.path.exists("./.riftgun"):
print("")
print("Configuration folder does not exist. Creating...")
os.mkdir("./.riftgun")
try:
with open("./.riftgun/rifts.min.json") as rfile:
Expand Down Expand Up @@ -82,8 +82,7 @@ async def queue_sender(self):

def cog_unload(self):
self.worker.cancel()
with open("./.riftgun/rifts.min.json", "w+") as wfile:
json.dump(self.data, wfile)
self.save()
print("Saved data and unloaded module")

def save(self):
Expand Down Expand Up @@ -113,6 +112,7 @@ async def open_rifts(self, ctx: commands.Context):

to_tabulate = []
for _, info in self.data.items():
# note to all editors: what the hell is this?
master = int(info["source"])
sub = int(info["target"])

Expand Down Expand Up @@ -168,6 +168,7 @@ async def close_rift(self, ctx: commands.Context, notify: Optional[bool]=True, *
This command takes the same arguments as [p]openrift.
If the bot can no longer see the rift channel, you can provide the ID instead and it will still be deleted"""
# TODO: need to make it so you can provide either source or target channel.
if not isinstance(target, int):
target: discord.TextChannel
if notify and target.permissions_for(target.guild.me).send_messages:
Expand Down Expand Up @@ -223,14 +224,15 @@ async def channel_info(self, ctx: commands.Context, *, channel: GlobalTextChanne
This should be used to make sure you got the right channel before opening."""
channel: discord.TextChannel
nsfw = channel.is_nsfw()
news = channel.is_news()
ago = channel.created_at.strftime("%c") + " " + humanize.naturaltime(channel.created_at)
perms = channel.permissions_for(channel.guild.me).value
e = discord.Embed(
title=f"Name: {channel.name}",
description="ID: `{0.id}`\nGuild: {0.guild.name} (`{0.guild.id}`)\nCategory: {0.category}\n"
"Slowmode: {0.slowmode_delay}\nNSFW: {1}\nCreated at: {2}\n"
"Slowmode: {0.slowmode_delay}\nNSFW: {1}\nAnnouncement: {5}Created at: {2}\n"
"[Permissions Value]({3}): {4}".format(
channel, nsfw, ago, f"https://discordapi.com/permissions.html#{perms}", str(perms)),
channel, nsfw, ago, f"https://discordapi.com/permissions.html#{perms}", str(perms), news),
color=channel.guild.owner.color,
timestamp=channel.created_at
)
Expand Down

0 comments on commit 877a9d8

Please sign in to comment.