Closed dannyvoid closed 8 years ago
This USED to function, and then out of no where ONLY the last command in the code works. (!bungo) What am I doing wrong?
import os import sys import time import random import requests import subprocess from datetime import * from time import sleep from bs4 import BeautifulSoup import discord import asyncio # on start print ("Connecting...") # globals bot_token = "" # your app token channel_id = '' # id of the text channel the bot will be in owner = "" # username of admin # define client and channel client = discord.Client() channel = discord.Object(id=channel_id) # countdown for rise of iron today = date.today() roi_release_date = date(2016,9,20) daysleft = roi_release_date - today # find the nightfall strike nf_url = 'http://www.destiny-daily.com/Nightfall' requ = requests.get(nf_url) soup = BeautifulSoup(requ.text, 'html.parser') current_nf = soup.find('h3') # find the nightfall modifiers modifiers = soup.findAll('td') modifiers_one = "**" + str(modifiers[1]) + "**" modifiers_two = "**" + str(modifiers[4]) + "**" modifiers_three = "**" + str(modifiers[7]) + "**" modifiers_four = "**" + str(modifiers[10]) + "**" modifiers_five = "**" + str(modifiers[13]) + "**" all_modifiers = modifiers_one + ', ' + modifiers_two + ', ' + modifiers_three + ', ' + modifiers_four + ', and ' + modifiers_five all_modifiers = all_modifiers.replace("<td>", "") all_modifiers = all_modifiers.replace("</td>", "") list_modifiers = all_modifiers # find the daily story and crucible daily_url = 'http://www.destiny-daily.com/Daily' requ_daily = requests.get(daily_url) soup_daily = BeautifulSoup(requ_daily.text, 'html.parser') current_daily_story = "**" + str(soup_daily.find('h3')) + "**" current_daily_story = current_daily_story.replace('<h3 style="margin-top: 0px;">', "") current_daily_story = current_daily_story.replace('</h3>', "") current_daily_crucible = soup_daily.findAll('td') current_daily_crucible_ = "**" + str(current_daily_crucible[6]) + "**" current_daily_crucible_ = current_daily_crucible_.replace('<td style="text-align: center; width: 150px; font-size: 36px;">', "") current_daily_crucible_ = current_daily_crucible_.replace('</td>', "") # on message events @client.event async def on_message(message): if message.content.startswith('!say') and message.author.name == owner: msg = message.content.strip('!say ') await client.send_typing(message.channel) sleep(1) await client.send_message(client.get_channel(channel_id), msg) @client.event async def on_message(message): if message.content.startswith('!status') and message.author.name == owner: status = message.content.strip('!status ') await client.change_status(game=discord.Game(name=status)) @client.event async def on_message(message): if message.content.startswith('!reboot') and message.author.name == owner: msg = "Rebooting Server..." await client.send_typing(message.channel) sleep(.3) await client.send_message(message.channel, msg) os.system("systemctl reboot") @client.event async def on_message(message): if message.content.startswith('!bungo'): msg = "The current **Nightfall** is " + "**" + current_nf.text + "**" + " with the following modifiers: " + list_modifiers + "." msg2 = "The current **Daily Story** is " + current_daily_story + "." msg3 = "The current **Daily Crucible** is " + current_daily_crucible_ + "." msg4 = "**" + str(daysleft.days) + "**" + " days until **Rise of Iron**." await client.send_typing(message.channel) sleep(.3) await client.send_message(message.channel, msg) await client.send_typing(message.channel) sleep(.3) await client.send_message(message.channel, msg2) await client.send_typing(message.channel) sleep(.3) await client.send_message(message.channel, msg3) await client.send_typing(message.channel) sleep(.3) await client.send_message(message.channel, msg4) # on connect events @client.event async def on_ready(): os.system('clear') print('Logged in as') print(client.user.name) print(client.user.id) print('------') # sign in client.run(bot_token)
You can only define one event handler per event. Combine them into one.
from time import sleep
http://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean
This USED to function, and then out of no where ONLY the last command in the code works. (!bungo) What am I doing wrong?