Checking if message is sent within a guild or not

pull/8/head
sgoudham 4 years ago
parent 79d9b1e504
commit ae36be3f56

@ -7,7 +7,7 @@ from typing import Optional
import discord import discord
import mariadb import mariadb
from decouple import config from decouple import config
from discord import Embed, DMChannel from discord import Embed
from discord.ext import commands, tasks from discord.ext import commands, tasks
from discord.ext.commands import when_mentioned_or, has_permissions, guild_only, is_owner 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 # Method to allow the commands to be used with mentioning the bot
async def get_prefix(bot, message): async def get_prefix(bot, message):
if isinstance(message.channel, DMChannel): if message.guild is None:
return "~" return "~"
return when_mentioned_or(get_prefix_for_guild(str(message.guild.id)))(bot, message) return when_mentioned_or(get_prefix_for_guild(str(message.guild.id)))(bot, message)

Loading…
Cancel
Save