Fix on_message to not execute on DMs

This commit is contained in:
Zeva Rose 2021-07-02 13:27:59 -06:00
parent 24616d14dc
commit 6e21b7bb67

View file

@ -1,7 +1,7 @@
from pathlib import Path
import pymongo
from datetime import datetime, timedelta
from discord import Intents, Member, Message
from discord import Intents, Member, Message, DMChannel
from discord.ext import commands
from discord.ext.tasks import loop
from discord.utils import find, get
@ -70,13 +70,14 @@ async def on_member_join(user: Member):
@jarvis.event
async def on_message(message: Message):
db = DBManager(get_config().mongo).mongo
autoreact = db.jarvis.autoreact.find_one(
{"guild": message.guild.id, "channel": message.channel.id}
)
if autoreact:
for reaction in autoreact["reactions"]:
await message.add_reaction(reaction)
if not isinstance(message.channel, DMChannel):
db = DBManager(get_config().mongo).mongo
autoreact = db.jarvis.autoreact.find_one(
{"guild": message.guild.id, "channel": message.channel.id}
)
if autoreact:
for reaction in autoreact["reactions"]:
await message.add_reaction(reaction)
await jarvis.process_commands(message)