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>")
python python-3.x discord.py subclassing
add a comment |
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>")
python python-3.x discord.py subclassing
from discord import Client
note the uppercaseC
. 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
add a comment |
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>")
python python-3.x discord.py subclassing
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
python python-3.x discord.py subclassing
asked Nov 5 at 1:53
user10003286
114
114
from discord import Client
note the uppercaseC
. 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
add a comment |
from discord import Client
note the uppercaseC
. 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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
from discord import Client
note the uppercaseC
. 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