Skip to content

Commit

Permalink
Optional Deafen
Browse files Browse the repository at this point in the history
When I first had @DestinyofYeet pr for me, I didn't have this be optional. It really should've been. This fixes that.
  • Loading branch information
AutumnClove committed Jul 21, 2023
1 parent b6a9708 commit f068fe8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions config/example_options.ini
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ DefaultSearchResults = 3
# Specify a custom message to use as the bots embed footer.
CustomEmbedFooter =

# Sets if you'd like the bot to deafen when joining a voice channel
SelfDeafen = yes

[Files]
# Path to your i18n file. Do not set this if you do not know what it does.
i18nFile =
17 changes: 13 additions & 4 deletions musicbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ def __init__(self, config_file=None, perms_file=None, aliases_file=None):

async def _doBotInit(self):
self.http.user_agent = "MusicBot/%s" % BOTVERSION
self.session = aiohttp.ClientSession(headers={"User-Agent": self.http.user_agent})
self.session = aiohttp.ClientSession(
headers={"User-Agent": self.http.user_agent}
)

self.spotify = None
if self.config._spotify:
Expand Down Expand Up @@ -479,7 +481,7 @@ async def get_voice_client(self, channel: discord.abc.GuildChannel):
else:
client = await channel.connect(timeout=60, reconnect=True)
await channel.guild.change_voice_state(
channel=channel, self_mute=False, self_deaf=True
channel=channel, self_mute=False, self_deaf=self.config.self_deafen
)
return client

Expand Down Expand Up @@ -1311,6 +1313,9 @@ async def on_ready(self):
" Leave non owners: "
+ ["Disabled", "Enabled"][self.config.leavenonowners]
)
log.info(
" Self Deafen: " + ["Disabled", "Enabled"][self.config.self_deafen]
)

print(flush=True)

Expand Down Expand Up @@ -1789,7 +1794,9 @@ async def _cmd_play(
continue
else:
break
await self._do_playlist_checks(permissions, player, author, res)
await self._do_playlist_checks(
permissions, player, author, res
)
procmesg = await self.safe_send_message(
channel,
self.str.get(
Expand Down Expand Up @@ -2342,7 +2349,9 @@ async def cmd_stream(self, _player, channel, author, permissions, song_url):
)

async with channel.typing():
await player.playlist.add_stream_entry(song_url, channel=channel, author=author)
await player.playlist.add_stream_entry(
song_url, channel=channel, author=author
)

return Response(
self.str.get("cmd-stream-success", "Streaming."), delete_after=6
Expand Down
7 changes: 5 additions & 2 deletions musicbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ def __init__(self, config_file):
self.footer_text = config.get(
"MusicBot", "CustomEmbedFooter", fallback=ConfigDefaults.footer_text
)
self.self_deafen = config.getboolean(
"MusicBot", "SelfDeafen", fallback=ConfigDefaults.self_deafen
)
self.searchlist = config.getboolean(
"MusicBot", "SearchList", fallback=ConfigDefaults.searchlist
)
Expand Down Expand Up @@ -260,7 +263,7 @@ def run_checks(self):

if not self._login_token:
# Attempt to fallback to an environment variable.
token_env = os.environ.get('MUSICBOT_TOKEN')
token_env = os.environ.get("MUSICBOT_TOKEN")
if token_env:
self._login_token = token_env
self.auth = (self._login_token,)
Expand Down Expand Up @@ -472,7 +475,6 @@ def find_autoplaylist(self):
log.warning("No autoplaylist file found.")



class ConfigDefaults:
owner_id = None

Expand Down Expand Up @@ -517,6 +519,7 @@ class ConfigDefaults:
leavenonowners = False
usealias = True
searchlist = False
self_deafen = True
defaultsearchresults = 3
footer_text = "Just-Some-Bots/MusicBot ({})".format(BOTVERSION)

Expand Down

0 comments on commit f068fe8

Please sign in to comment.