Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
833 B
4
Indexable
Never
import discord
from discord import Intents
from PyDictionary import PyDictionary

client = discord.Client(intents=discord.Intents.all())
dictionary = PyDictionary()

@client.event
async def on_ready():
    print('Logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('!dictionary'):
        word = message.content.split(' ')[1]
        definition = dictionary.meaning(word)
        if definition:
            for key, val in definition.items():
                await message.channel.send(f'**{key}**: {", ".join(val)}')
        else:
            await message.channel.send('Sorry, I could not find a definition for that word.')
client.run('MTIyNjQ4NTAzNzk1Mjc5NDY2NQ.G9UZ6p.a7MLmRD6w9Nn50ojn7LOILWNtgXDEiYtbD3j0k')
Leave a Comment