Bugfix: Profile update async problems

This commit is contained in:
Logan Cusano
2021-12-28 20:51:11 -05:00
parent 108a0b5999
commit 69f6127cb4

15
bot.py
View File

@@ -4,6 +4,7 @@ import time
import discord
import sound
import configparser
import asyncio
from discord.ext import commands
from subprocess import Popen, PIPE
@@ -93,7 +94,7 @@ class Bot(commands.Bot):
self.start_sdr()
# Change the activity to the channel and band-type being used
self.set_activity()
await self.set_activity()
else:
# Return that the opus library would not load
@@ -105,7 +106,7 @@ class Bot(commands.Bot):
# Disconnect the client from the voice channel
await ctx.voice_client.disconnect()
# Change the presence to away and '@ me'
self.set_activity(False)
await self.set_activity(False)
# Stop the SDR so it can cool off
self.stop_sdr()
@@ -305,7 +306,7 @@ class Bot(commands.Bot):
self.sdr_started = False
def set_activity(self, connected=True):
async def set_activity(self, connected=True):
if connected:
if self.profile_name is None:
await self.change_presence(activity=discord.Activity(type=discord.ActivityType.listening,
@@ -340,7 +341,9 @@ class Bot(commands.Bot):
if self.sdr_started:
self.start_sdr()
self.set_activity()
loop = asyncio.get_event_loop()
coroutine = self.set_activity()
loop.run_until_complete(coroutine)
def load_radio_config(self, profile_name):
config = configparser.ConfigParser()
@@ -355,4 +358,6 @@ class Bot(commands.Bot):
if self.sdr_started:
self.start_sdr()
self.set_activity()
loop = asyncio.get_event_loop()
coroutine = self.set_activity()
loop.run_until_complete(coroutine)