Implement a basic bot with a single hello command
This commit is contained in:
parent
9709859d88
commit
f7ca997c96
1 changed files with 9 additions and 13 deletions
22
matchy.py
22
matchy.py
|
@ -1,22 +1,18 @@
|
||||||
# This example requires the 'message_content' intent.
|
# This example requires the 'message_content' intent.
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
|
|
||||||
client = discord.Client(intents=intents)
|
bot = commands.Bot(command_prefix='$', description="test", intents=intents)
|
||||||
|
|
||||||
@client.event
|
@bot.command()
|
||||||
async def on_ready():
|
async def hello(ctx, *args):
|
||||||
print(f'We have logged in as {client.user}')
|
"""Just say hello back"""
|
||||||
|
await ctx.send(f"Hi {ctx.author.mention}")
|
||||||
|
|
||||||
@client.event
|
bot.run(os.getenv("BOT_TOKEN"))
|
||||||
async def on_message(message):
|
|
||||||
if message.author == client.user:
|
|
||||||
return
|
|
||||||
|
|
||||||
if message.content.startswith('$hello'):
|
|
||||||
await message.channel.send('Hello!')
|
|
||||||
|
|
||||||
client.run('your token here')
|
|
Loading…
Add table
Add a link
Reference in a new issue