Skip to content

Commit

Permalink
fixes #15
Browse files Browse the repository at this point in the history
fixes #16
added an Embed/EmbedBuilder extension to send it directly to a channel. (commands will use this shortly)
  • Loading branch information
GreemDev committed Feb 5, 2019
1 parent 3fc5168 commit c24601b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Volte/Core/Extensions/EmbedExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Net;
using System.Threading.Tasks;
using Discord;
using Discord.WebSocket;
using Volte.Helpers;

namespace Volte.Core.Extensions {
public static class EmbedExtensions {
public static async Task SendTo(this EmbedBuilder e, IMessageChannel c) {
await Utils.Send(c, e.Build());
}

public static async Task SendTo(this Embed e, IMessageChannel c) {
await Utils.Send(c, e);
}

public static async Task SendTo(this EmbedBuilder e, SocketGuildUser c) {
await Utils.Send(await c.GetOrCreateDMChannelAsync(), e.Build());
}

public static async Task SendTo(this Embed e, SocketGuildUser c) {
await Utils.Send(await c.GetOrCreateDMChannelAsync(), e);
}
}
}
26 changes: 25 additions & 1 deletion Volte/Core/Services/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Discord.Net;
using Discord.WebSocket;
using Microsoft.Extensions.DependencyInjection;
using Volte.Core.Commands;
Expand All @@ -27,8 +28,31 @@ await dbl.GetTextChannel(265156286406983680).SendMessageAsync(
}

public async Task Guilds(SocketGuild guild) {
if (Config.GetBlacklistedOwners().Contains(guild.OwnerId)) {
/*if (Config.GetBlacklistedOwners().Contains(guild.OwnerId)) {
await guild.LeaveAsync();
return;
}*/

var embed = new EmbedBuilder()
.WithTitle("Hey there!")
.WithAuthor(guild.Owner)
.WithColor(Config.GetSuccessColor())
.WithDescription("Thanks for inviting me! Here's some basic instructions on how to set me up.")
.AddField("Set your admin role", "$adminrole {roleName}", true)
.AddField("Set your moderator role", "$modrole {roleName}", true)
.AddField("Permissions",
"It is recommended to give me admin permission, to avoid any permission errors that may happen." +
"\nYou *can* get away with just send messages, ban members, kick members, and the like if you don't want to give me admin.")
.AddField("Support Server", "[Join my support Discord here](https://discord.gg/H8bcFr2)");

try {
await embed.SendTo(guild.Owner);
}
catch (HttpException e) when (e.DiscordCode.Equals(50007)) {
var c = guild.TextChannels?.First();
if (c != null) {
await embed.SendTo(c);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Volte/Core/Services/WelcomeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal async Task Join(SocketGuildUser user) {
var welcomeMessage = config.WelcomeMessage
.Replace("{ServerName}", user.Guild.Name)
.Replace("{UserName}", user.Username)
.Replace("{UserMention}", user.Mention)
.Replace("{OwnerMention}", user.Guild.Owner.Mention)
.Replace("{UserTag}", user.Discriminator);

Expand All @@ -36,6 +37,7 @@ internal async Task Leave(SocketGuildUser user) {
var leavingMessage = config.LeavingMessage
.Replace("{ServerName}", user.Guild.Name)
.Replace("{UserName}", user.Username)
.Replace("{UserMention}", user.Mention)
.Replace("{OwnerMention}", user.Guild.Owner.Mention)
.Replace("{UserTag}", user.Discriminator);

Expand Down

0 comments on commit c24601b

Please sign in to comment.