From ae36be3f56038600c78839b672f1811a05240c01 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Wed, 22 Jul 2020 21:25:04 +0100 Subject: [PATCH] Checking if message is sent within a guild or not --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index ec2f100d..c40be2b1 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ from typing import Optional import discord import mariadb from decouple import config -from discord import Embed, DMChannel +from discord import Embed from discord.ext import commands, tasks from discord.ext.commands import when_mentioned_or, has_permissions, guild_only, is_owner @@ -75,7 +75,7 @@ API_TOKEN = config('DISCORD_TOKEN') # Method to allow the commands to be used with mentioning the bot async def get_prefix(bot, message): - if isinstance(message.channel, DMChannel): + if message.guild is None: return "~" return when_mentioned_or(get_prefix_for_guild(str(message.guild.id)))(bot, message)