-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
43 lines (29 loc) · 935 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import discord
from discord.ext import commands
token = os.getenv("DISCORD_WEATHER_BOT_TOKEN")
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f'Bot 已登入為 {bot.user}')
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if '早安' in message.content:
await message.channel.send('晚安!')
if '晚安' in message.content:
await message.channel.send('早安!')
if '午安' in message.content:
await message.channel.send('牛安!')
if '安安' in message.content:
await message.channel.send('安安安!')
@bot.command()
async def ping(ctx):
await ctx.send('Pong!')
@bot.command()
async def 你是誰(ctx):
await ctx.send('Hi! 我是用來查詢天氣的機器人')
bot.run(token)