Discord.py Self Bot using rewrite

2024/10/11 14:18:27

I'm trying to make a selfbot using discord.py rewrite.

I'm encountering issues when attempting to create a simple command.

I'd like my selfbot to respond with "oof" when ">>>test" is sent.

Here is my code:

import asyncio
import discord
from discord.ext import commandsbot = commands.Bot(command_prefix=(">>>"), self_bot=True)@bot.event
async def on_ready():print("Bot presence t u r n e d on ( ͡° ͜ʖ ͡°)")@bot.command()
async def test(self, ctx):await self.bot.say("oof")bot.run("my token", bot=False)
Answer

A self-bot isn't a bot that uses self, it's a bot that logs in using your credentials instead of a bot account. Self bots are against the Discord TOS (and you're not doing anything that requires one), so you should set up a bot account through their website and use a bot account for your bot.

That said, bot.say has been replaced by ctx.send in rewrite, and you're not in a cog so you shouldn't use self as all.

from discord.ext import commandsbot = commands.Bot(">>>", self_bot=True)@bot.event
async def on_ready():print("Bot presence t u r n e d on ( ͡° ͜ʖ ͡°)")@bot.command()
async def test(ctx):await ctx.send("oof")bot.run("my token", bot=False)
https://en.xdnf.cn/q/118314.html

Related Q&A

int to binary python

This question is probably very easy for most of you, but i cant find the answer so far.Im building a network packet generator that goes like this:class PacketHeader(Packet): fields = OrderedDict([(&quo…

Get aiohttp results as string

Im trying to get data from a website using async in python. As an example I used this code (under A Better Coroutine Example): https://www.blog.pythonlibrary.org/2016/07/26/python-3-an-intro-to-asyncio…

Waiting for a timer to terminate before continuing running the code

The following code updates the text of a button every second after the START button was pressed. The intended functionality is for the code to wait until the timer has stopped before continuing on with…

PySpark: how to resolve path of a resource file present inside the dependency zip file

I have a mapPartitions on an RDD and within each partition, a resource file has to be opened. This module that contains the method invoked by mapPartitions and the resource file is passed on to each ex…

Convert normal Python script to REST API

Here I have an excel to pdf conversion script. How can I modify it to act as a REST API? import os import comtypes.client SOURCE_DIR = D:/projects/python TARGET_DIR = D:/projects/python app = comtypes…

How to track changes in specific registry key or file with Python? [closed]

Closed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting …

How to use Android NDK to compile Numpy as .so?

Because the Numpy isnt a static library(it contains .py files, .pyc files, .so files, etc), so if I want to import it to my python code which is used in an Android phone(using CLE), I should recompile …

passing boolean function to if-condition in python

I"m learning python, and Im trying to do this, which I thought should be trivial, but apparently, its not. $python >>> def isTrue(data): ... "ping" in data ... >>>…

Unsupported operand type(s) for str and str. Python

Ive got the IF statement;if contactstring == "[Practice Address Not Available]" | contactstring == "[]":Im not sure what is going wrong(possibly the " "s?) but I keep ge…

getting Monday , june 5 , 2016 instead of June 5 ,2016 using DateTimeField

I have an app using Django an my my model has the following field: date = models.DateTimeField(auto_now_add=True,auto_now=False)Using that I get this: June 5, 2016, 9:16 p.m.but I need something like…