|
@@ -4,6 +4,7 @@ from discord.ext import commands
|
|
|
from local_settings import WEB_SCHEME, WEB_HOST
|
|
from local_settings import WEB_SCHEME, WEB_HOST
|
|
|
from query.guild_access_token import get_active_token, upsert_token
|
|
from query.guild_access_token import get_active_token, upsert_token
|
|
|
from common.datetime import plus10min
|
|
from common.datetime import plus10min
|
|
|
|
|
+from common.logging import report
|
|
|
|
|
|
|
|
def setup(bot: commands.Bot):
|
|
def setup(bot: commands.Bot):
|
|
|
bot.add_cog(Admin(bot))
|
|
bot.add_cog(Admin(bot))
|
|
@@ -25,9 +26,10 @@ class Admin(commands.Cog):
|
|
|
|
|
|
|
|
if record: # Check for active token
|
|
if record: # Check for active token
|
|
|
await ctx.send(f"Token {record['id']} is in use by {record['user']} until {plus10min(record['created'])}.")
|
|
await ctx.send(f"Token {record['id']} is in use by {record['user']} until {plus10min(record['created'])}.")
|
|
|
- else:
|
|
|
|
|
|
|
+ else: # No active token
|
|
|
token = secrets.token_urlsafe(40)[:40]
|
|
token = secrets.token_urlsafe(40)[:40]
|
|
|
await upsert_token(self.bot.pg, ctx.guild.id, ctx.author.id, token)
|
|
await upsert_token(self.bot.pg, ctx.guild.id, ctx.author.id, token)
|
|
|
|
|
|
|
|
await ctx.author.send(f"{WEB_SCHEME}://{WEB_HOST}/config/channel-settings/{ctx.channel.id}/{token}") # DM token
|
|
await ctx.author.send(f"{WEB_SCHEME}://{WEB_HOST}/config/channel-settings/{ctx.channel.id}/{token}") # DM token
|
|
|
- await ctx.send("Your access token has been sent to you in a private DM.")
|
|
|
|
|
|
|
+ await ctx.send("Your access token has been sent to you in a private DM.")
|
|
|
|
|
+ await report(self.bot, f"`{ctx.author}` has requested a token for `{ctx.guild.name}`.")
|