Can I make a sub class of discord.client?











up vote
1
down vote

favorite












I'm trying to program a discord bot with discord.py. I want to make a subclass of the discord.client class so I can add some attributes to the class. Unfortunately I keep getting this error:




Traceback (most recent call last):
File "C:/Users/laser/PycharmProjects/DiscordNut/main.py", line 5, in
class Bot(client):
TypeError: module.init() takes at most 2 arguments (3 given)




Here's my code:



from discord import client
import random as rand


class Bot(client):
pass


async def roll(self, *args):
input = args[0]
target = input.find('d')
numDice = int(input[:target])
diceSize = int(input[target + 1:])
output = 0
for i in range(numDice):
output += rand.randint(1, diceSize)

await self.send_message(self.get_channel("505154560726269953"), "You rolled a: " + str(output))


def parse(content, delimeter):
target = content.find(delimeter)
if content.find(""") == 0:
content = content[1:]
target = content.find(""")
if target == 0:
return parse(content[1:], delimeter)
elif target < 0:
return [content]
else:
parsed =
parsed.append(content[:target])
return parsed + parse(content[target + 1:], delimeter)


client = Bot()


@client.event
async def on_ready():
client.users = [i for i in client.get_all_memebers()]
print(client.users)


@client.event
async def on_message(message):
parsed = None
if message.startswith('!'):
parsed = parse(message.content[1:], " ")
if parsed[0] in client.commands:
args = [i for i in parsed if i != parsed[0]]
client.commands[parsed[0]](args)


client.run("<TOKEN>")









share|improve this question






















  • from discord import Client note the uppercase C. I'm not sure why this has to be a subclass though, it could just be a coroutine.
    – Patrick Haugh
    Nov 5 at 2:30















up vote
1
down vote

favorite












I'm trying to program a discord bot with discord.py. I want to make a subclass of the discord.client class so I can add some attributes to the class. Unfortunately I keep getting this error:




Traceback (most recent call last):
File "C:/Users/laser/PycharmProjects/DiscordNut/main.py", line 5, in
class Bot(client):
TypeError: module.init() takes at most 2 arguments (3 given)




Here's my code:



from discord import client
import random as rand


class Bot(client):
pass


async def roll(self, *args):
input = args[0]
target = input.find('d')
numDice = int(input[:target])
diceSize = int(input[target + 1:])
output = 0
for i in range(numDice):
output += rand.randint(1, diceSize)

await self.send_message(self.get_channel("505154560726269953"), "You rolled a: " + str(output))


def parse(content, delimeter):
target = content.find(delimeter)
if content.find(""") == 0:
content = content[1:]
target = content.find(""")
if target == 0:
return parse(content[1:], delimeter)
elif target < 0:
return [content]
else:
parsed =
parsed.append(content[:target])
return parsed + parse(content[target + 1:], delimeter)


client = Bot()


@client.event
async def on_ready():
client.users = [i for i in client.get_all_memebers()]
print(client.users)


@client.event
async def on_message(message):
parsed = None
if message.startswith('!'):
parsed = parse(message.content[1:], " ")
if parsed[0] in client.commands:
args = [i for i in parsed if i != parsed[0]]
client.commands[parsed[0]](args)


client.run("<TOKEN>")









share|improve this question






















  • from discord import Client note the uppercase C. I'm not sure why this has to be a subclass though, it could just be a coroutine.
    – Patrick Haugh
    Nov 5 at 2:30













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm trying to program a discord bot with discord.py. I want to make a subclass of the discord.client class so I can add some attributes to the class. Unfortunately I keep getting this error:




Traceback (most recent call last):
File "C:/Users/laser/PycharmProjects/DiscordNut/main.py", line 5, in
class Bot(client):
TypeError: module.init() takes at most 2 arguments (3 given)




Here's my code:



from discord import client
import random as rand


class Bot(client):
pass


async def roll(self, *args):
input = args[0]
target = input.find('d')
numDice = int(input[:target])
diceSize = int(input[target + 1:])
output = 0
for i in range(numDice):
output += rand.randint(1, diceSize)

await self.send_message(self.get_channel("505154560726269953"), "You rolled a: " + str(output))


def parse(content, delimeter):
target = content.find(delimeter)
if content.find(""") == 0:
content = content[1:]
target = content.find(""")
if target == 0:
return parse(content[1:], delimeter)
elif target < 0:
return [content]
else:
parsed =
parsed.append(content[:target])
return parsed + parse(content[target + 1:], delimeter)


client = Bot()


@client.event
async def on_ready():
client.users = [i for i in client.get_all_memebers()]
print(client.users)


@client.event
async def on_message(message):
parsed = None
if message.startswith('!'):
parsed = parse(message.content[1:], " ")
if parsed[0] in client.commands:
args = [i for i in parsed if i != parsed[0]]
client.commands[parsed[0]](args)


client.run("<TOKEN>")









share|improve this question













I'm trying to program a discord bot with discord.py. I want to make a subclass of the discord.client class so I can add some attributes to the class. Unfortunately I keep getting this error:




Traceback (most recent call last):
File "C:/Users/laser/PycharmProjects/DiscordNut/main.py", line 5, in
class Bot(client):
TypeError: module.init() takes at most 2 arguments (3 given)




Here's my code:



from discord import client
import random as rand


class Bot(client):
pass


async def roll(self, *args):
input = args[0]
target = input.find('d')
numDice = int(input[:target])
diceSize = int(input[target + 1:])
output = 0
for i in range(numDice):
output += rand.randint(1, diceSize)

await self.send_message(self.get_channel("505154560726269953"), "You rolled a: " + str(output))


def parse(content, delimeter):
target = content.find(delimeter)
if content.find(""") == 0:
content = content[1:]
target = content.find(""")
if target == 0:
return parse(content[1:], delimeter)
elif target < 0:
return [content]
else:
parsed =
parsed.append(content[:target])
return parsed + parse(content[target + 1:], delimeter)


client = Bot()


@client.event
async def on_ready():
client.users = [i for i in client.get_all_memebers()]
print(client.users)


@client.event
async def on_message(message):
parsed = None
if message.startswith('!'):
parsed = parse(message.content[1:], " ")
if parsed[0] in client.commands:
args = [i for i in parsed if i != parsed[0]]
client.commands[parsed[0]](args)


client.run("<TOKEN>")






python python-3.x discord.py subclassing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 5 at 1:53









user10003286

114




114












  • from discord import Client note the uppercase C. I'm not sure why this has to be a subclass though, it could just be a coroutine.
    – Patrick Haugh
    Nov 5 at 2:30


















  • from discord import Client note the uppercase C. I'm not sure why this has to be a subclass though, it could just be a coroutine.
    – Patrick Haugh
    Nov 5 at 2:30
















from discord import Client note the uppercase C. I'm not sure why this has to be a subclass though, it could just be a coroutine.
– Patrick Haugh
Nov 5 at 2:30




from discord import Client note the uppercase C. I'm not sure why this has to be a subclass though, it could just be a coroutine.
– Patrick Haugh
Nov 5 at 2:30

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147343%2fcan-i-make-a-sub-class-of-discord-client%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147343%2fcan-i-make-a-sub-class-of-discord-client%23new-answer', 'question_page');
}
);

Post as a guest




















































































這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()