私はDiscord Python APIを使ってPython Discord Botを作っています。私は彼らがイベントの現在のリストにevent_add {メッセージ/彼らが追加したいイベント}をメッセージした後にメッセージを比較しようとしています。メッセージが現在のイベントリストと一致する場合、ボットは既にイベントがある旨のメッセージを返します。私の問題は、文字列がリストと比較したくないということであり、常に一致しないことを返します。Python Discord Botメッセージをリストと比較する
OS:Windowsの10クリエーターアップデート
のPython:3.6.2
Discord.py:https://discordpy.readthedocs.io/en/latest/、GitHubの:https://github.com/Rapptz/discord.py
コード:
import discord
from discord.ext import commands
import logging
import sys
import time
import asyncio
bot = commands.Bot(command_prefix="/")
console = discord.Object("357208549614419970")
events = {"learn to bake"}
@bot.event
async def on_ready():
print("Logged in as: ")
print(bot.user.id)
print(bot.user.name)
print("******************")
@bot.command(pass_context = True)
async def test(ctx):
await bot.say("Testing...... Am I a real boy yet?")
events = ['drawn out a dragon, and do a hand stand']
await bot.say(events)
@bot.command(pass_context = True)
async def add_event(ctx, event):
if event in events:
await bot.say("Sorry we already have that, also we need to teach %s
to read. Add that to the list please." % ctx.message.author.mention)
else:
await bot.say("Something is broken %s" % ctx.message.author.mention)
プログラム全体を貼り付けるのではなく、問題の原因となっているコードの簡潔な部分を投稿してください。 – squaswin