【问题标题】:Discord.py bot, random image posterDiscord.py bot,随机图片海报
【发布时间】: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)

我在这里尝试了一些东西,但将它们更改为笔记,因为它们似乎根本不起作用。另外,我希望从本地目录发布图像。 非常感谢任何帮助。

谢谢!

【问题讨论】:

    标签: python discord


    【解决方案1】:

    IIUC,

    查看此网址How to Make a Discord Bot in Python

    【讨论】:

    • 我已经设置了一个机器人,只是不知道如何实现这个特定的功能。
    猜你喜欢
    • 1970-01-01
    • 2023-03-24
    • 2019-09-25
    • 1970-01-01
    • 1970-01-01
    • 2013-08-16
    • 1970-01-01
    • 1970-01-01
    • 2017-10-22
    相关资源
    最近更新 更多