-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed issues with subscription * Changed dev settings
- Loading branch information
1 parent
f165e20
commit ff55dce
Showing
7 changed files
with
96 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Text.RegularExpressions; | ||
using Discord.Commands; | ||
using Tuck.Model; | ||
using System.Collections.Generic; | ||
using Discord; | ||
using Hangfire; | ||
using Tuck.Services; | ||
|
||
namespace Tuck.Modules | ||
{ | ||
[Group("wbuff")] | ||
public class SubscriptionModule : ModuleBase<SocketCommandContext> | ||
{ | ||
[Command("subscribe")] | ||
[RequireContext(ContextType.Guild)] | ||
public async Task AddSubscription(ulong guildId) { | ||
using(var context = new TuckContext()) { | ||
|
||
if(context.Subscriptions.AsQueryable().Where(s => s.GuildId == Context.Guild.Id).Any()) { | ||
await ReplyAsync("The subscription was **not** added. A subscription already exists. Do unsubscribe to change the server subscribe too."); | ||
return; | ||
} | ||
|
||
var subscription = new Subscription() { | ||
GuildId = Context.Guild.Id, | ||
ChannelId = Context.Channel.Id, | ||
TargetGuildId = guildId | ||
}; | ||
|
||
await context.AddAsync(subscription); | ||
await context.SaveChangesAsync(); | ||
await ReplyAsync("The subscription was added"); | ||
} | ||
} | ||
|
||
[Command("unsubscribe")] | ||
[RequireContext(ContextType.Guild)] | ||
public async Task Subscription() { | ||
using(var context = new TuckContext()) { | ||
var mathces = context.Subscriptions.AsQueryable().Where(t => t.GuildId == Context.Guild.Id); | ||
context.RemoveRange(mathces); | ||
await context.SaveChangesAsync(); | ||
await ReplyAsync("The subscription was removed"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,4 +58,4 @@ private ServiceProvider ConfigureServices() | |
.BuildServiceProvider(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters