Discord Selfbot Python

时间:2019-03-20 04:18:23

标签: python python-3.x bots discord discord.py

我正在为与一些irl朋友一起工作的服务器制作一个自拍程序。 自动取款机我有点卡住,不知道如何修复我的python代码。 当我说“ ayy”时,机器人应该说“ lmao”;当我说“ lmao”时,机器人应该说“ ayy” 只是一些乐趣:) 如果可能的话,我希望自助机器人只对我回应,没有其他人。

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio

#TOKEN
TOKEN = "Token goes here"

client = discord.Client()
b = Bot(command_prefix = "ayy")

@b.event
async def on_ready():
    print("ayy lmao")

@b.event
async def on_message(message):
    if message.content == "ayy":
        away.b.send_message(message.channel, "lmao")

b.run(TOKEN, bot = False)

错误:

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\FoxMaccloud\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 227, in _run_event
    await coro(*args, **kwargs)
  File "F:\Python\Random\Discord_bot\BetterBakaBot2.py", line 25, in on_message
NameError: name 'away' is not defined
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\FoxMaccloud\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 227, in _run_event
    await coro(*args, **kwargs)
  File "F:\Python\Random\Discord_bot\BetterBakaBot2.py", line 25, in on_message
NameError: name 'away' is not defined
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\FoxMaccloud\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 227, in _run_event
    await coro(*args, **kwargs)
  File "F:\Python\Random\Discord_bot\BetterBakaBot2.py", line 24, in on_message
    away.b.send_message(message.channel, "lmao")
NameError: name 'away' is not defined

2 个答案:

答案 0 :(得分:1)

我将第25行更改为:

await message.channel.send("lmao")

似乎现在可以正常工作:)

答案 1 :(得分:0)

做到这一点

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio

#TOKEN
TOKEN = "Token goes here"

client = discord.Client()
b = Bot(command_prefix = "ayy")

@b.event
async def on_ready():
    print("ayy lmao")

@b.event
async def on_message(message, ctx):
    if message.content == "ayy":
        await ctx.send("lmao")

b.run(TOKEN, bot = False)