【发布时间】:2020-06-16 09:06:34
【问题描述】:
所以我正在尝试制作一个从本地目录发布随机图像的机器人。我似乎无法弄清楚该怎么做。我花了一些时间在网上查看一些方法,但其中大多数都与嵌入式链接有关。
#Version 1.1.0
import os
import random
import discord
import asyncio
from discord.ext import commands
from discord.ext.commands import Bot
#Release#
TOKEN = 'token#'
#WIP#
#TOKEN = 'TOKEN#'
default_emojis = [
"????"
]
bot = commands.Bot(command_prefix='!croc')
@bot.event
async def on_ready():
print("CrocBOT | Version 1.1.0")
@bot.event
async def on_message(message):
print('A user has entered a command.')
await bot.process_commands(message)
@bot.event
async def on_message(message):
if message.content.startswith('version'):
channel = message.channel
await channel.send('CrocBOT | Version 1.1.0')
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if "croc" in message.content.lower():
await message.add_reaction("????")
elif "aligator" in message.content.lower():
await message.add_reaction("????")
elif "caiman" in message.content.lower():
await message.add_reaction("????")
elif "gharial" in message.content.lower():
await message.add_reaction("????")
elif "alligator" in message.content.lower():
await message.add_reaction("????")
elif "liopleurodon" in message.content.lower():
await message.add_reaction("????")
elif "nile" in message.content.lower():
await message.add_reaction("????")
elif "sagan" in message.content.lower():
await message.add_reaction("????")
elif "krokodil" in message.content.lower():
await message.add_reaction("????")
elif "sobek" in message.content.lower():
await message.add_reaction("????")
elif "spin" in message.content.lower():
await message.add_reaction("????")
elif "roll" in message.content.lower():
await message.add_reaction("????")
elif "крокодил" in message.content.lower():
await message.add_reaction("????")
elif "gavialis" in message.content.lower():
await message.add_reaction("????")
elif "????" in message.content.lower():
await message.add_reaction("????")
elif ":crocodile:" in message.content.lower():
await message.add_reaction("????")
#with open('my_image.png', 'rb') as f:
# picture = discord.File(f)
# await channel.send(channel, picture)
#@bot.command()
#async def pic():
# fp = random.choice(os.listdir("D:\Discord_BOTs\BOT\CrocBOT\crocs"))
# await bot.send_file(ctx.message.channel, "D:\Discord_BOTs\BOT\CrocBOT\crocs{}".png(fp))
bot.run(TOKEN)
我在这里尝试了一些东西,但将它们更改为笔记,因为它们似乎根本不起作用。另外,我希望从本地目录发布图像。 非常感谢任何帮助。
谢谢!
【问题讨论】: