Skip to content

Commit

Permalink
Merge pull request #9 from ChocoMeow/beta
Browse files Browse the repository at this point in the history
Fix issues with mentions, settings, inbox view, and files typo
  • Loading branch information
ChocoMeow authored Jun 28, 2023
2 parents 7809afe + c0330d1 commit 4bca89e
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 63 deletions.
2 changes: 2 additions & 0 deletions .env Example
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ SPOTIFY_CLIENT_SECRET = YOUR_SPOTIFY_CLIENT_SECRET

YOUTUBE_API_KEY = YOUR_YOUTUBE_API_KEY

GENIUS_TOKEN = YOUR_GENIUS_TOKEN

MONGODB_URL = YOUR_MONGODB_URL
MONGODB_NAME = YOUR_MONGODB_DB_NAME
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ BUG_REPORT_CHANNEL_ID = 123456789012345678
SPOTIFY_CLIENT_ID = 0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
SPOTIFY_CLIENT_SECRET = 0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

GENIUS_TOKEN = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

YOUTUBE_API_KEY = AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

MONGODB_URL = mongodb+srv://user:password@clusterURL
Expand Down
8 changes: 4 additions & 4 deletions cogs/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def play(self, ctx: commands.Context, *, query: str) -> None:
await ctx.send(player.get_msg('playlistLoad').format(tracks.name, index))
else:
position = await player.add_track(tracks[0])
await ctx.send((f"`{player.get_msg('live')}`" if tracks[0].is_stream else "") + (player.get_msg('trackLoad_pos').format(tracks[0].title, tracks[0].author, tracks[0].formatLength, position) if position >= 1 and player.is_playing else player.get_msg('trackLoad').format(tracks[0].title, tracks[0].author, tracks[0].formatLength)))
await ctx.send((f"`{player.get_msg('live')}`" if tracks[0].is_stream else "") + (player.get_msg('trackLoad_pos').format(tracks[0].title, tracks[0].author, tracks[0].formatLength, position) if position >= 1 and player.is_playing else player.get_msg('trackLoad').format(tracks[0].title, tracks[0].author, tracks[0].formatLength)), allowed_mentions=False)
except voicelink.QueueFull as e:
await ctx.send(e)
finally:
Expand Down Expand Up @@ -142,7 +142,7 @@ async def _play(self, interaction: discord.Interaction, message: discord.Message
await interaction.response.send_message(player.get_msg('playlistLoad').format(tracks.name, index))
else:
position = await player.add_track(tracks[0])
await interaction.response.send_message((f"`{player.get_msg('live')}`" if tracks[0].is_stream else "") + (player.get_msg('trackLoad_pos').format(tracks[0].title, tracks[0].author, tracks[0].formatLength, position) if position >= 1 and player.is_playing else player.get_msg('trackLoad').format(tracks[0].title, tracks[0].author, tracks[0].formatLength)))
await interaction.response.send_message((f"`{player.get_msg('live')}`" if tracks[0].is_stream else "") + (player.get_msg('trackLoad_pos').format(tracks[0].title, tracks[0].author, tracks[0].formatLength, position) if position >= 1 and player.is_playing else player.get_msg('trackLoad').format(tracks[0].title, tracks[0].author, tracks[0].formatLength)), allowed_mentions=False)
except voicelink.QueueFull as e:
await interaction.response.send_message(e)

Expand Down Expand Up @@ -203,7 +203,7 @@ async def search(self, ctx: commands.Context, *, query: str, platform: str = "Yo
position = await player.add_track(track)
msg += ((f"`{player.get_msg('live')}`" if track.is_stream else "") + (player.get_msg('trackLoad_pos').format(track.title, track.author, track.formatLength,
position) if position >= 1 else player.get_msg('trackLoad').format(track.title, track.author, track.formatLength)))
await ctx.send(msg)
await ctx.send(msg, allowed_mentions=False)

if not player.is_playing:
await player.do_next()
Expand All @@ -230,7 +230,7 @@ async def playtop(self, ctx: commands.Context, query: str):
await ctx.send(player.get_msg('playlistLoad').format(tracks.name, index))
else:
position = await player.add_track(tracks[0], at_font=True)
await ctx.send((f"`{player.get_msg('live')}`" if tracks[0].is_stream else "") + (player.get_msg('trackLoad_pos').format(tracks[0].title, tracks[0].author, tracks[0].formatLength, position) if position >= 1 and player.is_playing else player.get_msg('trackLoad').format(tracks[0].title, tracks[0].author, tracks[0].formatLength)))
await ctx.send((f"`{player.get_msg('live')}`" if tracks[0].is_stream else "") + (player.get_msg('trackLoad_pos').format(tracks[0].title, tracks[0].author, tracks[0].formatLength, position) if position >= 1 and player.is_playing else player.get_msg('trackLoad').format(tracks[0].title, tracks[0].author, tracks[0].formatLength)), allowed_mentions=False)

except voicelink.QueueFull as e:
await ctx.send(e)
Expand Down
2 changes: 1 addition & 1 deletion cogs/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async def inbox(self, ctx: commands.Context) -> None:
return await ctx.send(get_lang(ctx.guild.id, 'inboxNoMsg'), ephemeral=True)

inbox = user['inbox'].copy()
view = InboxView(ctx.author.name, user['inbox'])
view = InboxView(ctx.author, user['inbox'])
message = await ctx.send(embed=view.build_embed(), view=view, ephemeral=True)
view.response = message
await view.wait()
Expand Down
2 changes: 1 addition & 1 deletion function.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def init():
global settings

json = open_json(os.path.join(root_dir, "settings.json"))
if json:
if json is not None:
settings = Settings(json)

def langs_setup():
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
discord.py==2.2.3
discord.py==2.3.0
pymongo==4.1.1
dnspython==2.2.1
tldextract==3.2.1
Expand Down
2 changes: 1 addition & 1 deletion update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

root_dir = os.path.dirname(os.path.abspath(__file__))
install_pack_dir = os.path.join(root_dir, "Vocard.zip")
__version__ = "v2.6.4"
__version__ = "v2.6.4a"

def checkVersion(withMsg = False):
resp = requests.get("https://api.github.com/repos/ChocoMeow/Vocard/releases/latest")
Expand Down
8 changes: 4 additions & 4 deletions views/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ async def callback(self, interaction: discord.Interaction):
class InboxView(discord.ui.View):
def __init__(self, author, inbox):
super().__init__(timeout=60)
self.author = author
self.author: discord.Member = author
self.inbox = inbox
self.response = None
self.newplaylist = []

self.current = None
self.add_item(Select_message(inbox))

async def interaction_check(self, interaction):
async def interaction_check(self, interaction: discord.Interaction):
if interaction.user == self.author:
return True
return False

def build_embed(self):
embed=discord.Embed(title=f"📭 All {self.author}'s Inbox",
embed=discord.Embed(title=f"📭 All {self.author.name}'s Inbox",
description=f'Max Messages: {len(self.inbox)}/10' + '```%0s %2s %20s\n' % (" ", "ID:", "Title:") + '\n'.join('%0s %2s. %35s'% ('✉️' if mail['type'] == 'invite' else '📢', index, mail['title'][:35] + "...") for index, mail in enumerate(self.inbox, start=1)) + '```',
color=func.settings.embed_color)
if self.current:
Expand Down
11 changes: 6 additions & 5 deletions web/static/js/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ class DataInput {

constructor(bytes) {
if (typeof bytes === "string") {
var decodedString = atob(bytes);
var bytes = new Uint8Array(decodedString.length);
const decodedString = atob(bytes);
const byteArr = new Uint8Array(decodedString.length);
for (let i = 0; i < decodedString.length; i++) {
bytes[i] = decodedString.charCodeAt(i);
byteArr[i] = decodedString.charCodeAt(i);
}
bytes = byteArr;
}
this.#buf = bytes;
this.#view = new DataView(bytes.buffer);
}

#_advance(bytes) {
if (this.#pos + bytes > this.#buf.length) {
throw new Error("");
throw new Error("Buffer overflow: cannot advance further.");
}
const p = this.#pos;
this.#pos += bytes;
Expand All @@ -59,7 +60,7 @@ class DataInput {
}

readBoolean() {
return this.readByte()
return this.readByte() !== 0;
}

readUnsignedShort() {
Expand Down
92 changes: 46 additions & 46 deletions web/static/js/Socket.js → web/static/js/socket.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
class Socket {
constructor(url) {
this.url = url;
this.socket = null;
}

connect(player) {
this.socket = io.connect(this.url);

this.socket.on('connect', () => {
console.log("Connected to server!");
});

this.socket.on('disconnect', () => {
player.init();
console.log("Disconnected from server!");
});

this.socket.on('error', (e) => {
console.log(e);
})
}

disconnect() {
if (this.socket) {
this.socket.disconnect();
}
}

send(msg) {
if (this.socket) {
this.socket.emit('message', msg);
}
}

addMessageListener(callback) {
if (this.socket) {
this.socket.on('message', callback);
}
}

removeMessageListener(callback) {
if (this.socket) {
this.socket.off('message', callback);
}
}
class Socket {
constructor(url) {
this.url = url;
this.socket = null;
}

connect(player) {
this.socket = io.connect(this.url);

this.socket.on('connect', () => {
console.log("Connected to server!");
});

this.socket.on('disconnect', () => {
player.init();
console.log("Disconnected from server!");
});

this.socket.on('error', (e) => {
console.log(e);
})
}

disconnect() {
if (this.socket) {
this.socket.disconnect();
}
}

send(msg) {
if (this.socket) {
this.socket.emit('message', msg);
}
}

addMessageListener(callback) {
if (this.socket) {
this.socket.on('message', callback);
}
}

removeMessageListener(callback) {
if (this.socket) {
this.socket.off('message', callback);
}
}
}

0 comments on commit 4bca89e

Please sign in to comment.