Update code naar 2.0 versie van discordpy #17
+4
-4
@@ -207,7 +207,7 @@ class Chatbot(commands.Cog):
|
|||||||
messageIterator = channel.history(limit=nrOfMessages, before=None, after=None, oldest_first=False, around=None)
|
messageIterator = channel.history(limit=nrOfMessages, before=None, after=None, oldest_first=False, around=None)
|
||||||
allMessages = []
|
allMessages = []
|
||||||
for i in range(nrOfMessages):
|
for i in range(nrOfMessages):
|
||||||
msg = yield from messageIterator.next()
|
msg = yield from anext(messageIterator)
|
||||||
allMessages.append(msg)
|
allMessages.append(msg)
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
@@ -256,10 +256,10 @@ class Chatbot(commands.Cog):
|
|||||||
|
|
||||||
#Get previous message to respond to
|
#Get previous message to respond to
|
||||||
messageIterator = ctx.channel.history(limit=3, before=None, after=None, oldest_first=False, around=None)
|
messageIterator = ctx.channel.history(limit=3, before=None, after=None, oldest_first=False, around=None)
|
||||||
messageToRespondTo = yield from messageIterator.next() #this will be the !reageer command. skip
|
messageToRespondTo = yield from anext(messageIterator) #this will be the !reageer command. skip
|
||||||
messageToRespondTo = yield from messageIterator.next()
|
messageToRespondTo = yield from anext(messageIterator)
|
||||||
if messageToRespondTo.content.strip()[0] == '!' or messageToRespondTo.author.bot: #another chance
|
if messageToRespondTo.content.strip()[0] == '!' or messageToRespondTo.author.bot: #another chance
|
||||||
messageToRespondTo = yield from messageIterator.next() #but it's not a huge problem if he responds to himself
|
messageToRespondTo = yield from anext(messageIterator) #but it's not a huge problem if he responds to himself
|
||||||
if messageToRespondTo.content.strip()[0] == '!':
|
if messageToRespondTo.content.strip()[0] == '!':
|
||||||
wordsToRespondTo = []
|
wordsToRespondTo = []
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class Points(commands.Cog):
|
|||||||
self.voice_states = {}
|
self.voice_states = {}
|
||||||
|
|
||||||
self.BANK_ID = 42
|
self.BANK_ID = 42
|
||||||
|
self.init()
|
||||||
|
|
||||||
def __check(self, ctx):
|
def __check(self, ctx):
|
||||||
return True
|
return True
|
||||||
@@ -263,7 +264,8 @@ class Points(commands.Cog):
|
|||||||
np.save("pointscount.npy", pointsCount)
|
np.save("pointscount.npy", pointsCount)
|
||||||
|
|
||||||
# Add new/unknown members:
|
# Add new/unknown members:
|
||||||
memberList = self.bot.get_channel(self.bot.hdChannels["shitpost"]).members
|
list_channel = self.bot.get_channel(self.bot.hdChannels["shitpost"])
|
||||||
|
memberList = list_channel.members if list_channel else []
|
||||||
for member in memberList:
|
for member in memberList:
|
||||||
# Give new members 100 points
|
# Give new members 100 points
|
||||||
if member.id not in pointsCount.keys() and not member.bot:
|
if member.id not in pointsCount.keys() and not member.bot:
|
||||||
|
|||||||
@@ -25,5 +25,6 @@ Requirements:
|
|||||||
* `numpy`
|
* `numpy`
|
||||||
* `youtube_dl`
|
* `youtube_dl`
|
||||||
* `ffmpeg-python`
|
* `ffmpeg-python`
|
||||||
|
* `caldav`
|
||||||
|
|
||||||
Verder zoek je het zelf maar uit.
|
Verder zoek je het zelf maar uit.
|
||||||
+15
-14
@@ -15,7 +15,18 @@ from discord.ext import commands
|
|||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True)
|
async def add_cogs(bot):
|
||||||
|
await bot.add_cog(Shitpost.Shitpost(bot))
|
||||||
|
await bot.add_cog(General.General(bot))
|
||||||
|
await bot.add_cog(Cryptocoin.Cryptocoin(bot))
|
||||||
|
await bot.add_cog(Chatbot.Chatbot(bot))
|
||||||
|
await bot.add_cog(Points.Points(bot))
|
||||||
|
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
intents.members = True
|
||||||
|
|
||||||
|
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True, intents=intents)
|
||||||
|
|
||||||
#Read configuration file:
|
#Read configuration file:
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
@@ -24,6 +35,7 @@ bot.tokens = config["tokens"]
|
|||||||
bot.hdChannels = {}
|
bot.hdChannels = {}
|
||||||
for channel in config["channels"]: #channelIDs must be integers
|
for channel in config["channels"]: #channelIDs must be integers
|
||||||
bot.hdChannels[channel] = int(config["channels"][channel])
|
bot.hdChannels[channel] = int(config["channels"][channel])
|
||||||
|
|
||||||
#passwords are base64 encoded, which makes it like 1% safer
|
#passwords are base64 encoded, which makes it like 1% safer
|
||||||
bot.passwords = {}
|
bot.passwords = {}
|
||||||
for pw in config["passwords"]:
|
for pw in config["passwords"]:
|
||||||
@@ -33,20 +45,9 @@ for pw in config["passwords"]:
|
|||||||
print("Problem with decoding password!")
|
print("Problem with decoding password!")
|
||||||
bot.passwords[pw] = config["passwords"][pw]
|
bot.passwords[pw] = config["passwords"][pw]
|
||||||
|
|
||||||
#bot.add_cog(Music.Music(bot))
|
|
||||||
#TODO: Re-add music functions now that we require a stronger host
|
|
||||||
bot.add_cog(Shitpost.Shitpost(bot))
|
|
||||||
bot.add_cog(General.General(bot))
|
|
||||||
bot.add_cog(Cryptocoin.Cryptocoin(bot))
|
|
||||||
bot.add_cog(Chatbot.Chatbot(bot))
|
|
||||||
pointsBot = Points.Points(bot)
|
|
||||||
bot.add_cog(pointsBot)
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
@asyncio.coroutine
|
async def on_ready():
|
||||||
def on_ready():
|
await add_cogs(bot)
|
||||||
print('Logged in as:\n{0} (ID: {0.id})'.format(bot.user))
|
print('Logged in as:\n{0} (ID: {0.id})'.format(bot.user))
|
||||||
#TODO: find out how to do this properly:
|
|
||||||
pointsBot.init()
|
|
||||||
|
|
||||||
bot.run(bot.tokens["discordbot"])
|
bot.run(bot.tokens["discordbot"])
|
||||||
|
|||||||
Reference in New Issue
Block a user