Add indexing to starboard, refs #46
This commit is contained in:
parent
3c661fbf8c
commit
fd1bcbfaac
1 changed files with 9 additions and 3 deletions
|
@ -2,13 +2,12 @@ from datetime import datetime
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import discord
|
import discord
|
||||||
|
import jarvis
|
||||||
from discord import Message, TextChannel
|
from discord import Message, TextChannel
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.utils import find
|
from discord.utils import find
|
||||||
from discord_slash import SlashContext, cog_ext
|
from discord_slash import SlashContext, cog_ext
|
||||||
from discord_slash.utils.manage_commands import create_option
|
from discord_slash.utils.manage_commands import create_option
|
||||||
|
|
||||||
import jarvis
|
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
from jarvis.utils.db import DBManager
|
from jarvis.utils.db import DBManager
|
||||||
|
@ -187,6 +186,9 @@ class StarboardCog(commands.Cog):
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
count = self.db.jarvis.stars.find(
|
||||||
|
{"guild": message.guild.id, "starboard": starboard.id}
|
||||||
|
).count()
|
||||||
content = message.content
|
content = message.content
|
||||||
|
|
||||||
attachments = message.attachments
|
attachments = message.attachments
|
||||||
|
@ -200,7 +202,7 @@ class StarboardCog(commands.Cog):
|
||||||
content = "\u200b"
|
content = "\u200b"
|
||||||
|
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title="Click Here to view context",
|
title=f"[#{count}] Click Here to view context",
|
||||||
description=content,
|
description=content,
|
||||||
fields=[],
|
fields=[],
|
||||||
url=message.jump_url,
|
url=message.jump_url,
|
||||||
|
@ -221,6 +223,7 @@ class StarboardCog(commands.Cog):
|
||||||
|
|
||||||
self.db.jarvis.stars.insert_one(
|
self.db.jarvis.stars.insert_one(
|
||||||
{
|
{
|
||||||
|
"index": count,
|
||||||
"message": message.id,
|
"message": message.id,
|
||||||
"channel": message.channel.id,
|
"channel": message.channel.id,
|
||||||
"guild": message.guild.id,
|
"guild": message.guild.id,
|
||||||
|
@ -238,3 +241,6 @@ class StarboardCog(commands.Cog):
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(StarboardCog(bot))
|
bot.add_cog(StarboardCog(bot))
|
||||||
|
|
||||||
|
|
||||||
|
cog(StarboardCog(bot))
|
||||||
|
|
Loading…
Add table
Reference in a new issue